diff --git a/defaults/main.yml b/defaults/main.yml index 61b380d..6bf13cc 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,2 +1,4 @@ --- +workspace: /root + xhprof_output_dir: /var/tmp/xhprof diff --git a/tasks/configure.yml b/tasks/configure.yml new file mode 100644 index 0000000..5ed86b6 --- /dev/null +++ b/tasks/configure.yml @@ -0,0 +1,17 @@ +--- +- name: Ensure PHP configuration directories exist. + file: + path: "{{ item }}" + state: directory + mode: 0755 + with_items: php_xhprof_config_dirs + +- name: Copy XHProf INI into various other conf folders. + template: + src: xhprof.ini.j2 + dest: "{{ item }}/{{ php_xhprof_config_filename }}" + owner: root + group: root + mode: 0644 + with_items: php_xhprof_config_dirs + notify: restart webserver diff --git a/tasks/main.yml b/tasks/main.yml index 3ed4aa5..c1e0970 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,34 +9,56 @@ - include: setup-Debian.yml when: ansible_os_family == 'Debian' -# Install and configure XHProf. -- name: Install XHProf using PECL. - command: "pecl install {{ item }}" - register: pecl_result - changed_when: "pecl_result.rc == 0" - failed_when: "not (('already installed' in pecl_result.stdout) or ('install ok:' in pecl_result.stdout))" +- name: Download XHProf. + get_url: + url: "https://github.com/phacility/xhprof/archive/master.tar.gz" + dest: "{{ workspace }}/xhprof-master.tar.gz" + +# TODO: In 2.0, we can set the 'src' to the URL from the get_url task above and +# cut out one extra task :) +- name: Untar XHProf. + unarchive: + src: "{{ workspace }}/xhprof-master.tar.gz" + dest: "{{ workspace }}" + copy: no + +- name: Build XHProf. + shell: > + {{ item }} + chdir={{ workspace }}/xhprof-master/extension + creates={{ workspace }}/xhprof-master/extension/modules/xhprof.so with_items: - # Manual channel installation required for certain PEAR versions. - - "channel://pecl.php.net/xhprof-0.9.4" - - xhprof + - phpize + - ./configure + - make + notify: restart webserver -- name: Ensure PHP configuration directories exist. +- name: Ensure XHProf module path exists. file: - path: "{{ item }}" + path: "{{ php_xhprof_module_path }}" state: directory - mode: 0755 - with_items: php_xhprof_config_dirs - -- name: Copy XHProf INI into various other conf folders. - template: - src: xhprof.ini.j2 - dest: "{{ item }}/{{ php_xhprof_config_filename }}" owner: root group: root - mode: 0644 - with_items: php_xhprof_config_dirs + mode: 0755 + +- name: Move XHProf module into place. + shell: > + cp {{ workspace }}/xhprof-master/extension/modules/xhprof.so {{ php_xhprof_module_path }}/xhprof.so + creates={{ php_xhprof_module_path }}/xhprof.so notify: restart webserver +- name: Move XHProf PHP library into place. + shell: > + cp -r {{ workspace }}/xhprof-master/xhprof_lib {{ php_xhprof_lib_dir }} + creates={{ php_xhprof_lib_dir }}/utils/xhprof_lib.php + +- name: Move XHProf UI into place. + shell: > + cp -r {{ workspace }}/xhprof-master/xhprof_html {{ php_xhprof_html_dir }} + creates={{ php_xhprof_html_dir }}/index.php + +- include: configure.yml + - name: Ensure XHProf output directory exists. file: path: "{{ xhprof_output_dir }}" diff --git a/vars/Debian.yml b/vars/Debian.yml index d1d7e5d..466844a 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -1,4 +1,6 @@ --- +php_xhprof_module_path: /usr/lib/php5/modules + php_xhprof_lib_dir: /usr/share/php/xhprof_lib php_xhprof_html_dir: /usr/share/php/xhprof_html diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 0a063f7..7dfa749 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -1,4 +1,6 @@ --- +php_xhprof_module_path: /usr/lib64/php/modules + php_xhprof_lib_dir: /usr/share/pear/xhprof_lib php_xhprof_html_dir: /usr/share/pear/xhprof_html