2015-05-28 11:32:57 +02:00
|
|
|
---
|
|
|
|
# php as a standalone service
|
2016-08-01 14:19:36 +02:00
|
|
|
- name: Install the Ubuntu PHP PPA
|
|
|
|
apt_repository: repo={{ php_ppa }} state=present update_cache=yes
|
|
|
|
when: php_from_ppa
|
|
|
|
tags: [ 'php', 'php_ppa' ]
|
|
|
|
|
|
|
|
- name: Remove the Ubuntu PHP PPA
|
|
|
|
apt_repository: repo={{ php_ppa }} state=absent update_cache=yes
|
|
|
|
when: not php_from_ppa
|
|
|
|
tags: [ 'php', 'php_ppa' ]
|
|
|
|
|
2015-05-29 19:42:43 +02:00
|
|
|
- name: Install the php-fpm package
|
2019-03-26 16:47:30 +01:00
|
|
|
apt: pkg={{ php_fpm_packages }} state=present update_cache=yes cache_valid_time=3600
|
2016-03-17 21:35:04 +01:00
|
|
|
tags: php
|
2015-05-28 11:32:57 +02:00
|
|
|
|
2018-09-16 13:51:34 +02:00
|
|
|
- name: Install additional php packages
|
2019-03-26 16:47:30 +01:00
|
|
|
apt: pkg={{ php_additional_packages | default([]) }} state=present update_cache=yes cache_valid_time=3600
|
2018-09-16 13:51:34 +02:00
|
|
|
tags: php
|
|
|
|
|
2015-05-28 11:32:57 +02:00
|
|
|
- name: Set the timezone if we have one
|
|
|
|
ini_file: dest={{ phpfpm_base_dir }}/php.ini section=Date option=date.timezone value={{ timezone }} backup=yes
|
|
|
|
when: timezone is defined
|
|
|
|
notify: Reload php-fpm
|
2016-03-17 21:35:04 +01:00
|
|
|
tags: [ 'php', 'php_ini' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
2016-10-25 13:32:46 +02:00
|
|
|
- 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
|
2016-12-19 12:16:42 +01:00
|
|
|
ini_file: dest={{ phpfpm_cli_dir }}/php.ini section={{ item.section | default('PHP') }} option={{ item.option }} value={{ item.value }} backup=yes state={{ item.state | default('present') }}
|
2017-01-27 01:59:20 +01:00
|
|
|
with_items: '{{ php_cli_global_settings | default([]) }}'
|
2016-10-25 13:32:46 +02:00
|
|
|
tags: [ 'php', 'php_ini' ]
|
|
|
|
|
2015-09-04 15:02:57 +02:00
|
|
|
- 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 }}'
|
2015-09-03 02:36:22 +02:00
|
|
|
when: phpfpm_use_memcache_redundancy_sessions
|
2016-03-17 21:35:04 +01:00
|
|
|
with_items: '{{ memcache_session }}'
|
2015-09-03 02:36:22 +02:00
|
|
|
notify: Reload php-fpm
|
2016-03-17 21:35:04 +01:00
|
|
|
tags: [ 'php', 'php_ini' ]
|
2015-09-03 02:36:22 +02:00
|
|
|
|
2015-05-28 11:32:57 +02:00
|
|
|
- name: remove php-fpm default pool
|
|
|
|
file: dest={{ phpfpm_base_dir }}/pool.d/www.conf state=absent
|
|
|
|
when: phpfpm_remove_default_pool
|
|
|
|
notify: Restart php-fpm
|
2016-03-17 21:35:04 +01:00
|
|
|
tags: php
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- 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
|
2016-03-17 21:35:04 +01:00
|
|
|
with_items: '{{ phpfpm_pools }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
when: phpfpm_create_users
|
|
|
|
notify: Restart php-fpm
|
2016-03-17 21:35:04 +01:00
|
|
|
tags: [ 'php', 'fpm_pool' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- 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
|
2016-03-17 21:35:04 +01:00
|
|
|
with_items: '{{ phpfpm_pools }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
when: phpfpm_use_default_template
|
2016-03-17 21:35:04 +01:00
|
|
|
tags: [ 'php', 'fpm_pool' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- name: Create the directories where to store the log files
|
|
|
|
file: dest={{ phpfpm_logdir }} owner=root group=root mode=0750 state=directory
|
2016-03-17 21:35:04 +01:00
|
|
|
tags: [ 'php', 'fpm_pool' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- name: Install the php-fpm logrotate file
|
|
|
|
template: src=php-fpm.logrotate.j2 dest=/etc/logrotate.d/php-fpm owner=root group=root mode=0444
|
2016-03-17 21:35:04 +01:00
|
|
|
tags: [ 'php', 'fpm_conf' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- name: Install the php-fpm main config file
|
|
|
|
template: src=php-fpm.conf.j2 dest={{ phpfpm_base_dir }}/php-fpm.conf owner=root group=root mode=0444
|
|
|
|
notify: Restart php-fpm
|
2016-03-17 21:35:04 +01:00
|
|
|
tags: [ 'php', 'fpm_conf', 'fpm_pool' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- 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
|
2016-03-17 21:35:04 +01:00
|
|
|
with_items: '{{ phpfpm_pools }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
when: phpfpm_use_default_template
|
|
|
|
notify: Restart php-fpm
|
2016-03-17 21:35:04 +01:00
|
|
|
tags: [ 'php', 'fpm_conf', 'fpm_pool', 'fpm_pool_conf' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- name: Ensure that the php-fpm service is started and enabled
|
2016-08-01 17:22:51 +02:00
|
|
|
service: name=php{{ php_version }}-fpm state=started enabled=yes
|
2016-03-17 21:35:04 +01:00
|
|
|
when: phpfpm_service_enabled
|
|
|
|
tags: php
|
|
|
|
|
|
|
|
- name: Ensure that the php-fpm service is stopped and disabled
|
2016-08-01 17:22:51 +02:00
|
|
|
service: name=php{{ php_version }}-fpm state=stopped enabled=no
|
2016-03-17 21:35:04 +01:00
|
|
|
when: not phpfpm_service_enabled
|
|
|
|
tags: php
|
2015-05-28 11:32:57 +02:00
|
|
|
|