From 7a2e74177cbbfa6814ae27c277027937c9704e87 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Tue, 25 Oct 2016 13:32:46 +0200 Subject: [PATCH] library/roles/php-fpm: Manage options set in php.ini. Lots of defaults in the pool template. No need to define tens of options anymore. --- php-fpm/defaults/main.yml | 7 +++++-- php-fpm/tasks/main.yml | 12 ++++++++++++ php-fpm/templates/php-fpm-pool.conf.j2 | 6 ------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/php-fpm/defaults/main.yml b/php-fpm/defaults/main.yml index 1db3fc42..93644c6a 100644 --- a/php-fpm/defaults/main.yml +++ b/php-fpm/defaults/main.yml @@ -16,6 +16,9 @@ phpfpm_base_dir: '/etc/php{{ php_version }}/fpm' php_fpm_packages: - 'php{{ php_version }}-fpm' +#php_global_settings: +# - { option='', value='', state='' } + # Main confign file settings # It can be 'syslog' phpfpm_logdir: /var/log/php-fpm @@ -33,8 +36,8 @@ phpfpm_event_mechanism: epoll # Pools settings -phpfpm_default_pool_name: "www" -phpfpm_remove_default_pool: False +phpfpm_default_pool_name: "php-fpm" +phpfpm_remove_default_pool: True phpfpm_use_default_template: True phpfpm_create_users: True phpfpm_default_user: php-fpm diff --git a/php-fpm/tasks/main.yml b/php-fpm/tasks/main.yml index 95513f52..89a7559a 100644 --- a/php-fpm/tasks/main.yml +++ b/php-fpm/tasks/main.yml @@ -21,6 +21,18 @@ notify: Reload php-fpm tags: [ 'php', 'php_ini' ] +- name: Modify the global php settings + ini_file: dest={{ phpfpm_base_dir }}/php.ini section={{ item.section | default('PHP') }} option={{ item.option }} value={{ item.value }} backup=yes state={{ item.state | default('present') }} + with_items: '{{ php_global_settings | default([]) }}' + notify: Reload php-fpm + tags: [ 'php', 'php_ini' ] + +- name: Modify the global php cli settings + ini_file: dest=/etc/php{{ php_version}}/cli/php.ini section={{ item.section | default('PHP') }} option={{ item.option }} value={{ item.value }} backup=yes state={{ item.state | default('present') }} + with_items: '{{ php_global_settings | default([]) }}' + notify: Reload php-fpm + tags: [ 'php', 'php_ini' ] + - name: Activate the memcache sessions support and redundancy if needed action: configfile path={{ phpfpm_base_dir }}/conf.d/20-memcache.ini key={{ item.prop }} value='{{ item.value }}' when: phpfpm_use_memcache_redundancy_sessions diff --git a/php-fpm/templates/php-fpm-pool.conf.j2 b/php-fpm/templates/php-fpm-pool.conf.j2 index 76c5cc52..ea4be76a 100644 --- a/php-fpm/templates/php-fpm-pool.conf.j2 +++ b/php-fpm/templates/php-fpm-pool.conf.j2 @@ -118,9 +118,7 @@ pm.max_requests = {{ item.pm_max_requests | default('10000') }} ; anything, but it may not be a good idea to use the .php extension or it ; may conflict with a real PHP file. ; Default Value: not set -{% if item.pm_status_enabled %} pm.status_path = {{ item.pm_status_path | default('/status') }} -{% endif %} ; The ping URI to call the monitoring page of FPM. If this value is not set, no ; URI will be recognized as a ping page. This could be used to test from outside @@ -132,16 +130,12 @@ pm.status_path = {{ item.pm_status_path | default('/status') }} ; anything, but it may not be a good idea to use the .php extension or it ; may conflict with a real PHP file. ; Default Value: not set -{% if item.ping_enabled %} ping.path = {{ item.ping_path | default('/ping') }} -{% endif %} ; This directive may be used to customize the response of a ping request. The ; response is formatted as text/plain with a 200 response code. ; Default Value: pong -{% if item.ping_enabled %} ping.response = {{ item.ping_response | default('www') }} -{% endif %} access.log = /var/log/php-fpm/$pool-access.log