Support Xdebug extension

pull/5/head
Emilien Mantel 2015-07-27 18:09:52 +02:00
parent a4e5720e83
commit 2e4bcd0996
8 changed files with 251 additions and 2 deletions

View File

@ -0,0 +1,52 @@
#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;
use Data::Dumper;
use constant {
PREFIX_KEY => 'php_'
};
my $html = get('http://xdebug.org/docs/all_settings');
my @inis = ();
my $y = 0;
my $ini;
foreach(split("\n", $html))
{
chomp;
if($y)
{
$y = 0;
/<span class='default'>(.+?)<\/span>/;
$ini->{default} = $1;
}
if(/class='name'>(.+)</)
{
$ini = {};
my $a = $1;
$a =~ s/\./_/g;
$ini->{php_key} = $a;
$ini->{key} = sprintf('%s%s', PREFIX_KEY, $a);
$ini->{var} = sprintf('{{ %s }}', $ini->{key});
push(@inis, $ini);
$y = 1;
}
}
print STDERR "============ defaults/main.yml ===============\n";
foreach my $p (@inis)
{
printf("%s: '%s'\n", $p->{key}, $p->{default});
}
print STDERR "============ xdebug.ini.j2 ===============\n";
foreach my $p (@inis)
{
printf("%s=%s\n", $p->{php_key}, $p->{var});
}

View File

@ -22,6 +22,9 @@ You should look at [default vars](defaults/main.yml).
- `php_extra_packages`: additional php packages to install (default is an empty list). - `php_extra_packages`: additional php packages to install (default is an empty list).
- `php_ini`: manage php.ini (php-fpm), as key/value. - `php_ini`: manage php.ini (php-fpm), as key/value.
#### Xdebug
- `php_install_xdebug`: boolean, install [Xdebug](http://xdebug.org)
#### OpCache settings (PHP >= 5.5) #### OpCache settings (PHP >= 5.5)
@ -53,6 +56,60 @@ See [apc doc](https://secure.php.net/manual/en/apc.configuration.php)
- `php_apc_slam_defense` - `php_apc_slam_defense`
- `php_apc_stat_ctime` - `php_apc_stat_ctime`
# Xdebug settings
See [Xdebug doc](http://xdebug.org/docs/all_settings)
- `php_xdebug_auto_trace`
- `php_xdebug_cli_color`
- `php_xdebug_collect_assignments`
- `php_xdebug_collect_includes`
- `php_xdebug_collect_params`
- `php_xdebug_collect_return`
- `php_xdebug_collect_vars`
- `php_xdebug_coverage_enable`
- `php_xdebug_default_enable`
- `php_xdebug_dump_globals`
- `php_xdebug_dump_once`
- `php_xdebug_dump_undefined`
- `php_xdebug_extended_info`
- `php_xdebug_file_link_format`
- `php_xdebug_force_display_errors`
- `php_xdebug_force_error_reporting`
- `php_xdebug_halt_level`
- `php_xdebug_idekey`
- `php_xdebug_manual_url`
- `php_xdebug_max_nesting_level`
- `php_xdebug_overload_var_dump`
- `php_xdebug_profiler_append`
- `php_xdebug_profiler_enable`
- `php_xdebug_profiler_enable_trigger`
- `php_xdebug_profiler_enable_trigger_value`
- `php_xdebug_profiler_output_dir`
- `php_xdebug_profiler_output_name`
- `php_xdebug_remote_autostart`
- `php_xdebug_remote_connect_back`
- `php_xdebug_remote_cookie_expire_time`
- `php_xdebug_remote_enable`
- `php_xdebug_remote_handler`
- `php_xdebug_remote_host`
- `php_xdebug_remote_log`
- `php_xdebug_remote_mode`
- `php_xdebug_remote_port`
- `php_xdebug_scream`
- `php_xdebug_show_exception_trace`
- `php_xdebug_show_local_vars`
- `php_xdebug_show_mem_delta`
- `php_xdebug_trace_enable_trigger`
- `php_xdebug_trace_enable_trigger_value`
- `php_xdebug_trace_format`
- `php_xdebug_trace_options`
- `php_xdebug_trace_output_dir`
- `php_xdebug_trace_output_name`
- `php_xdebug_var_display_max_children`
- `php_xdebug_var_display_max_data`
- `php_xdebug_var_display_max_depth`
### Read only vars ### Read only vars

View File

@ -1,6 +1,7 @@
--- ---
php_install_fpm: true php_install_fpm: true
php_install_xdebug: false
php_extra_packages: [] php_extra_packages: []
# php.ini config # php.ini config
@ -35,6 +36,56 @@ php_apc_file_update_protection: "0"
php_apc_slam_defense: "0" php_apc_slam_defense: "0"
php_apc_stat_ctime: "1" php_apc_stat_ctime: "1"
# Xdebug
php_xdebug_auto_trace: '0'
php_xdebug_cli_color: '0'
php_xdebug_collect_assignments: '0'
php_xdebug_collect_includes: '1'
php_xdebug_collect_params: '0'
php_xdebug_collect_return: '0'
php_xdebug_collect_vars: '0'
php_xdebug_coverage_enable: '1'
php_xdebug_default_enable: '1'
php_xdebug_dump_globals: '1'
php_xdebug_dump_once: '1'
php_xdebug_dump_undefined: '0'
php_xdebug_extended_info: '1'
php_xdebug_file_link_format: 'xdebug://%f@%l'
php_xdebug_force_display_errors: '0'
php_xdebug_force_error_reporting: '0'
php_xdebug_halt_level: '0'
php_xdebug_idekey: '*complex*'
php_xdebug_manual_url: 'http://www.php.net'
php_xdebug_max_nesting_level: '100'
php_xdebug_overload_var_dump: '1'
php_xdebug_profiler_append: '0'
php_xdebug_profiler_enable: '0'
php_xdebug_profiler_enable_trigger: '0'
php_xdebug_profiler_enable_trigger_value: '""'
php_xdebug_profiler_output_dir: '/tmp'
php_xdebug_profiler_output_name: 'cachegrind.out.%p'
php_xdebug_remote_autostart: '0'
php_xdebug_remote_connect_back: '0'
php_xdebug_remote_cookie_expire_time: '3600'
php_xdebug_remote_enable: '0'
php_xdebug_remote_handler: 'dbgp'
php_xdebug_remote_host: 'localhost'
php_xdebug_remote_log: 'xdebug.remote_log'
php_xdebug_remote_mode: 'req'
php_xdebug_remote_port: '9000'
php_xdebug_scream: '0'
php_xdebug_show_exception_trace: '0'
php_xdebug_show_local_vars: '0'
php_xdebug_show_mem_delta: '0'
php_xdebug_trace_enable_trigger: '0'
php_xdebug_trace_enable_trigger_value: '""'
php_xdebug_trace_format: '0'
php_xdebug_trace_options: '0'
php_xdebug_trace_output_dir: '/tmp'
php_xdebug_trace_output_name: 'trace.%c'
php_xdebug_var_display_max_children: '128'
php_xdebug_var_display_max_data: '512'
php_xdebug_var_display_max_depth: '3'
# PHP-FPM # PHP-FPM
php_fpm_poold: php_fpm_poold:

View File

@ -2,3 +2,4 @@
- name: restart php-fpm - name: restart php-fpm
action: service name=php5-fpm state=restarted action: service name=php5-fpm state=restarted
when: php_install_fpm

View File

@ -6,10 +6,19 @@
- php_packages - php_packages
- php_extra_packages - php_extra_packages
- name: COMMAND | Get PHP extension dir
command: php-config --extension-dir
changed_when: false
register: php_extension_dir
- name: INCLUDE | PHP-FPM - name: INCLUDE | PHP-FPM
include: fpm.yml include: fpm.yml
when: php_install_fpm when: php_install_fpm
- name: INCLUDE | Xdebug
include: xdebug.yml
when: php_install_xdebug
- name: SHELL | Get PHP version on apt - name: SHELL | Get PHP version on apt
shell: LANG=C apt-cache policy php5 2>&1 | awk '/Candidate:/ { print $2 }' shell: LANG=C apt-cache policy php5 2>&1 | awk '/Candidate:/ { print $2 }'
register: php_apt_version register: php_apt_version

13
tasks/xdebug.yml 100644
View File

@ -0,0 +1,13 @@
---
- name: APT | Install php-xdebug
apt: pkg=php5-xdebug state=latest update_cache=yes cache_valid_time=3600
- name: SHELL | Get Xdebug version
shell: dpkg -l | awk '$2 ~ /^php5-xdebug$/ { print $3 }'
changed_when: false
register: xdebug_version
- name: TEMPLATE | Deploy module configurations
template: src=etc/php5/mods-available/xdebug.ini.j2 dest=/etc/php5/mods-available/xdebug.ini owner=root mode=0644
notify: restart php-fpm

View File

@ -0,0 +1,65 @@
; --------------------------------------
; {{ ansible_managed }}
; --------------------------------------
; configuration for php xdebug module
; priority=20
zend_extension={{ php_extension_dir.stdout }}/xdebug.so
{% if xdebug_version.stdout|version_compare('2.3', 'gt') %}
{% endif %}
xdebug_auto_trace={{ php_xdebug_auto_trace }}
xdebug_cli_color={{ php_xdebug_cli_color }}
xdebug_collect_assignments={{ php_xdebug_collect_assignments }}
xdebug_collect_includes={{ php_xdebug_collect_includes }}
xdebug_collect_params={{ php_xdebug_collect_params }}
xdebug_collect_return={{ php_xdebug_collect_return }}
xdebug_collect_vars={{ php_xdebug_collect_vars }}
xdebug_coverage_enable={{ php_xdebug_coverage_enable }}
xdebug_default_enable={{ php_xdebug_default_enable }}
xdebug_dump_globals={{ php_xdebug_dump_globals }}
xdebug_dump_once={{ php_xdebug_dump_once }}
xdebug_dump_undefined={{ php_xdebug_dump_undefined }}
xdebug_extended_info={{ php_xdebug_extended_info }}
xdebug_file_link_format={{ php_xdebug_file_link_format }}
xdebug_force_display_errors={{ php_xdebug_force_display_errors }}
xdebug_force_error_reporting={{ php_xdebug_force_error_reporting }}
xdebug_halt_level={{ php_xdebug_halt_level }}
xdebug_idekey={{ php_xdebug_idekey }}
xdebug_manual_url={{ php_xdebug_manual_url }}
xdebug_max_nesting_level={{ php_xdebug_max_nesting_level }}
xdebug_overload_var_dump={{ php_xdebug_overload_var_dump }}
xdebug_profiler_append={{ php_xdebug_profiler_append }}
xdebug_profiler_enable={{ php_xdebug_profiler_enable }}
xdebug_profiler_enable_trigger={{ php_xdebug_profiler_enable_trigger }}
{% if xdebug_version.stdout|version_compare('2.3', 'gt') %}
xdebug_profiler_enable_trigger_value={{ php_xdebug_profiler_enable_trigger_value }}
{% endif %}
xdebug_profiler_output_dir={{ php_xdebug_profiler_output_dir }}
xdebug_profiler_output_name={{ php_xdebug_profiler_output_name }}
xdebug_remote_autostart={{ php_xdebug_remote_autostart }}
xdebug_remote_connect_back={{ php_xdebug_remote_connect_back }}
xdebug_remote_cookie_expire_time={{ php_xdebug_remote_cookie_expire_time }}
xdebug_remote_enable={{ php_xdebug_remote_enable }}
xdebug_remote_handler={{ php_xdebug_remote_handler }}
xdebug_remote_host={{ php_xdebug_remote_host }}
xdebug_remote_log={{ php_xdebug_remote_log }}
xdebug_remote_mode={{ php_xdebug_remote_mode }}
xdebug_remote_port={{ php_xdebug_remote_port }}
xdebug_scream={{ php_xdebug_scream }}
xdebug_show_exception_trace={{ php_xdebug_show_exception_trace }}
xdebug_show_local_vars={{ php_xdebug_show_local_vars }}
xdebug_show_mem_delta={{ php_xdebug_show_mem_delta }}
xdebug_trace_enable_trigger={{ php_xdebug_trace_enable_trigger }}
{% if xdebug_version.stdout|version_compare('2.3', 'gt') %}
xdebug_trace_enable_trigger_value={{ php_xdebug_trace_enable_trigger_value }}
{% endif %}
xdebug_trace_format={{ php_xdebug_trace_format }}
xdebug_trace_options={{ php_xdebug_trace_options }}
xdebug_trace_output_dir={{ php_xdebug_trace_output_dir }}
xdebug_trace_output_name={{ php_xdebug_trace_output_name }}
xdebug_var_display_max_children={{ php_xdebug_var_display_max_children }}
xdebug_var_display_max_data={{ php_xdebug_var_display_max_data }}
xdebug_var_display_max_depth={{ php_xdebug_var_display_max_depth }}

View File

@ -5,6 +5,7 @@
vhost: 'test.local' vhost: 'test.local'
php_extra_packages: php_extra_packages:
- 'php5-memcached' - 'php5-memcached'
php_install_xdebug: true
pre_tasks: pre_tasks:
- name: APT | Install nginx - name: APT | Install nginx
apt: pkg=nginx state=present update_cache=yes cache_valid_time=3600 apt: pkg=nginx state=present update_cache=yes cache_valid_time=3600
@ -15,9 +16,9 @@
register: nginx_version register: nginx_version
changed_when: false changed_when: false
- set_fact: nginx_include="fastcgi_params" - set_fact: nginx_include="fastcgi_params"
when: "{{ nginx_version.stdout | version_compare('1.6', '<', true) }}" when: nginx_version.stdout | version_compare('1.6', '<', true)
- set_fact: nginx_include="fastcgi.conf" - set_fact: nginx_include="fastcgi.conf"
when: "{{ nginx_version.stdout | version_compare('1.6', '>=', true) }}" when: nginx_version.stdout | version_compare('1.6', '>=', true)
- name: COPY | Vhost - name: COPY | Vhost
copy: > copy: >
dest=/etc/nginx/sites-enabled/{{ vhost }} dest=/etc/nginx/sites-enabled/{{ vhost }}