From ede935b45d0965438e1cd0ff2b27dd54c85e3590 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Wed, 9 Oct 2019 16:25:05 +0200 Subject: [PATCH] php-fpm: fix the path of the session files. --- library/roles/php-fpm/defaults/main.yml | 2 +- library/roles/php-fpm/tasks/main.yml | 16 +++++++++------- .../roles/php-fpm/templates/php-fpm-pool.conf.j2 | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/library/roles/php-fpm/defaults/main.yml b/library/roles/php-fpm/defaults/main.yml index 44896d22..b10a8c3d 100644 --- a/library/roles/php-fpm/defaults/main.yml +++ b/library/roles/php-fpm/defaults/main.yml @@ -68,7 +68,7 @@ phpfpm_default_extensions: ".php" phpfpm_default_context: '/' phpfpm_default_session_handler: 'files' phpfpm_default_session_prefix: '/var/lib/php' -phpfpm_session_prefix: '{{ phpfpm_default_session_prefix }}' +phpfpm_default_session_dir: '{{ phpfpm_default_session_prefix }}/sessions' phpfpm_default_define_custom_variables: False phpfpm_use_memcache_redundancy_sessions: False diff --git a/library/roles/php-fpm/tasks/main.yml b/library/roles/php-fpm/tasks/main.yml index fa29e7c8..09435172 100644 --- a/library/roles/php-fpm/tasks/main.yml +++ b/library/roles/php-fpm/tasks/main.yml @@ -2,7 +2,7 @@ # php as a standalone service - name: Install the Ubuntu PHP PPA apt_repository: repo={{ php_ppa }} state=present update_cache=yes - when: php_from_ppa + when: php_from_ppa | bool tags: [ 'php', 'php_ppa' ] - name: Remove the Ubuntu PHP PPA @@ -37,28 +37,30 @@ - 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 + when: phpfpm_use_memcache_redundancy_sessions | bool with_items: '{{ memcache_session }}' notify: Reload php-fpm tags: [ 'php', 'php_ini' ] - name: remove php-fpm default pool file: dest={{ phpfpm_base_dir }}/pool.d/www.conf state=absent - when: phpfpm_remove_default_pool + when: phpfpm_remove_default_pool | bool notify: Restart php-fpm tags: php - name: Create the users under the php-fpm processes will run user: name={{ item.user }} comment="{{ item.user }}" home=/dev/null createhome=no shell=/sbin/nologin with_items: '{{ phpfpm_pools }}' - when: phpfpm_create_users + when: phpfpm_create_users | bool notify: Restart php-fpm tags: [ 'php', 'fpm_pool' ] - name: Create the directories where to store the sessions files. One for each pool file: dest={{ phpfpm_session_prefix }}/{{ item.pool_name }} owner={{ item.user }} group=root mode=0750 state=directory with_items: '{{ phpfpm_pools }}' - when: phpfpm_use_default_template + when: + - phpfpm_session_prefix is defined + - phpfpm_use_default_template | bool tags: [ 'php', 'fpm_pool' ] - name: Create the directories where to store the log files @@ -77,13 +79,13 @@ - name: Install the php-fpm pools template: src=php-fpm-pool.conf.j2 dest={{ phpfpm_base_dir }}/pool.d/{{ item.pool_name }}.conf owner=root group=root mode=0444 with_items: '{{ phpfpm_pools }}' - when: phpfpm_use_default_template + when: phpfpm_use_default_template | bool notify: Restart php-fpm tags: [ 'php', 'fpm_conf', 'fpm_pool', 'fpm_pool_conf' ] - name: Ensure that the php-fpm service is started and enabled service: name=php{{ php_version }}-fpm state=started enabled=yes - when: phpfpm_service_enabled + when: phpfpm_service_enabled | bool tags: php - name: Ensure that the php-fpm service is stopped and disabled diff --git a/library/roles/php-fpm/templates/php-fpm-pool.conf.j2 b/library/roles/php-fpm/templates/php-fpm-pool.conf.j2 index df3c45dd..c9362ed6 100644 --- a/library/roles/php-fpm/templates/php-fpm-pool.conf.j2 +++ b/library/roles/php-fpm/templates/php-fpm-pool.conf.j2 @@ -284,7 +284,7 @@ php_value[session.save_handler] = '{{ item.session_save_handler | default('files {% if phpfpm_session_prefix is defined %} php_value[session.save_path] = '{{ phpfpm_session_prefix }}/{{ item.pool_name }}' {% else %} -php_value[session.save_path] = '/var/lib/php/www' +php_value[session.save_path] = '{{ phpfpm_default_session_dir }}' {% endif %} {% if item.define_custom_variables is defined and item.define_custom_variables %} {% for php_var in phpfpm_php_variables %}