Skip to content

Commit

Permalink
Issue geerlingguy#11: Install XHProf from source
Browse files Browse the repository at this point in the history
  • Loading branch information
oxyc committed Feb 29, 2016
1 parent 41da17c commit 5a1715c
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 20 deletions.
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
---
workspace: /root

xhprof_output_dir: /var/tmp/xhprof
17 changes: 17 additions & 0 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
@@ -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
62 changes: 42 additions & 20 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
2 changes: 2 additions & 0 deletions vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 2 additions & 0 deletions vars/RedHat.yml
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 5a1715c

Please sign in to comment.