role is functionnal, we can create more pools

This commit is contained in:
2021-10-18 21:27:58 +02:00
parent ddb3a9c856
commit 7572c99edc
6 changed files with 49 additions and 26 deletions

View File

@@ -13,8 +13,8 @@ None
Role Variables
--------------
php_version: default 73
php_poolname: default www (version will be appended)
php_version: default 74
php_fpm_pool_user: default apache
php_fpm_pool_group: default apache
php_fpm_listen_url: default 127.0.0.1:90{{ php_version }}
@@ -35,17 +35,34 @@ Example Playbook
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
vars:
httpd_server_name: foobar.fr
php_version: 73
php_packages:
- php73-php-imap
- php73-php-pear
roles:
- apache
- php-fpm
roles:
- role: tconstans.php-fpm
vars:
php_poolname: pool1
php_listen_url: "/srv/pool1/php-fpm.sock"
php_version: 74
php_packages:
- php{{ php_version }}-php-mbstring
- php{{ php_version }}-php-mysqlnd
- php{{ php_version }}-php-pdo
- php{{ php_version }}-php-xml
- php{{ php_version }}-php-gd
- php{{ php_version }}-php-posix
- php{{ php_version }}-php-ldap
- php{{ php_version }}-php-curl
- php{{ php_version }}-php-iconv
- php{{ php_version }}-php-openssl
- php{{ php_version }}-php-zip
- php{{ php_version }}-php-zlib
- php{{ php_version }}-php-ctype
- role: tconstans.php-fpm
vars:
php_poolname: pool2
php_listen_url: "/srv/pool2/php-fpm.sock"
php_version: 80
php_packages:
- php{{ php_version }}-php-zip
License
-------

View File

@@ -1,11 +1,12 @@
---
# defaults file for php-fpm
php_version: 73
php_poolname: www
php_version: 74
php_fpm_pool_user: apache
php_fpm_pool_group: apache
php_fpm_listen_url: 127.0.0.1:90{{ php_version }}
php_pm: static
php_pm_max_children: 1000
php_pm_max_children: 100
php_pm_max_requests: 10000
php_pm_status_url: /phpstatus
php_packages: [ 'php{{ php_version }}-php-common' ]

View File

@@ -2,5 +2,5 @@
# handlers file for php-fpm
- name: restart php-fpm
service:
name: php-fpm
name: php{{ php_version }}-php-fpm
state: restarted

View File

@@ -15,6 +15,14 @@
option: enabled
value: 1
- name: create socket directory if needed
file:
path: "{{ php_listen_url|dirname }}"
state: directory
owner: "{{ php_fpm_pool_user }}"
when: php_listen_url[0] == '/'
- name: install php-fpm
yum:
name:
@@ -26,18 +34,18 @@
name: "{{ php_packages }}"
state: present
- name: disable default pool
copy:
content: ""
dest: "/etc/opt/remi/php{{ php_version }}/php-fpm.d/www.conf"
notify: restart php-fpm
- name: configure php-fpm pool 2
template:
src: www.conf
dest: /etc/opt/remi/php{{ php_version }}/php-fpm.d/www_{{ php_version }}.conf
dest: /etc/opt/remi/php{{ php_version }}/php-fpm.d/{{ php_poolname }}_{{ php_version }}.conf
notify: restart php-fpm
- name: create log symlink
file:
src: /var/opt/remi/php{{ php_version }}/log/php-fpm
dest: /var/log/php-fpm
state: link
- name: start and enable service
service:
name: php{{php_version}}-php-fpm

View File

@@ -1,3 +0,0 @@
<FilesMatch \.php$>
SetHandler proxy:fcgi://{{ php_fpm_listen_url }}
</FilesMatch>

View File

@@ -1,4 +1,4 @@
[www{{php_version}}]
[{{ php_poolname}}_{{ php_version }}]
user = {{ php_fpm_pool_user }}
group = {{ php_fpm_pool_group }}
listen = {{ php_fpm_listen_url }}