Improvements (#13)

- Store configuration in local facts
- Better socket generator
- php_admin_value/php_value
- Manages PHP 7.4 on Debian
This commit is contained in:
Emilien M
2019-12-26 14:13:00 +01:00
committed by GitHub
parent 9738ae9614
commit a19adf5150
13 changed files with 135 additions and 60 deletions

View File

@@ -16,9 +16,10 @@
- curl
- lsb-release
- nginx
- vim
- name: INCLUDE_TASKS | Sury
include_tasks: Debian/sury.yml
when:
(ansible_distribution_major_version is version('9', 'eq')) and
(php_version is version('7.1', 'ge'))
((ansible_distribution_major_version is version('9', 'eq')) and (php_version is version('7.1', 'ge'))) or
((ansible_distribution_major_version is version('10', 'eq')) and (php_version is version('7.4', 'ge')))

View File

@@ -15,22 +15,27 @@ http {
root /var/www;
{% if php_fpm_poold.0.status_path is defined %}
location = {{ php_fpm_poold.0.status_path }} {
{% if ansible_local.hanxhx_php.fpm_pool.0.status_path is defined %}
location = {{ ansible_local.hanxhx_php.fpm_pool.0.status_path }} {
include fastcgi.conf;
fastcgi_pass unix:{{ php_default_fpm_sock }};
fastcgi_pass unix:{{ ansible_local.hanxhx_php.fpm_pool.0.listen }};
}
{% endif %}
{% if php_fpm_poold.0.ping_path is defined %}
location = {{ php_fpm_poold.0.ping_path }} {
{% if ansible_local.hanxhx_php.fpm_pool.0.ping_path is defined %}
location = {{ ansible_local.hanxhx_php.fpm_pool.0.ping_path }} {
include fastcgi.conf;
fastcgi_pass unix:{{ php_default_fpm_sock }};
fastcgi_pass unix:{{ ansible_local.hanxhx_php.fpm_pool.0.listen }};
}
{% endif %}
location = /ini.php {
include fastcgi.conf;
fastcgi_pass unix:{{ ansible_local.hanxhx_php.fpm_pool.1.listen }};
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass unix:{{ php_default_fpm_sock }};
fastcgi_pass unix:{{ ansible_local.hanxhx_php.fpm_pool.0.listen }};
}
}
}

View File

@@ -4,7 +4,7 @@
vars:
vhost: 'test.local'
php_extra_packages:
- '{{ php_package_prefix }}recode'
- '{{ php_package_prefix }}pgsql'
php_install_xdebug: true
php_ini_fpm:
display_errors: 'Off'
@@ -12,7 +12,7 @@
error_reporting: 'E_ALL'
php_fpm_poold:
- pool_name: 'test_ansible'
listen: '{{ php_default_fpm_sock }}'
listen: '/run/php/php-ansible1.sock'
pm: 'dynamic'
pm_max_children: 250
pm_start_servers: 10
@@ -21,16 +21,25 @@
status_path: '/status'
ping_path: '/ping'
ping_response: 'ok'
php_flag:
- name: 'test_ansible2'
user: 'foo'
php_value:
display_errors: 'Off'
php_admin_flag:
memory_limit: '128M'
php_admin_value:
memory_limit: '98M'
pre_tasks:
- name: INCLUDE_TASKS | Pre tasks related to OS
include_tasks: "includes/pre_{{ ansible_os_family }}.yml"
- name: USER | Create PHP user
user:
name: 'foo'
system: yes
create_home: no
shell: '/usr/sbin/nologin'
tasks:
- name: TEMPLATE | Nginx site config
@@ -112,6 +121,11 @@
dest: /var/www/phpinfo.php
content: '<?php phpinfo();'
- name: COPY | Add ini test file
copy:
dest: /var/www/ini.php
content: '<?php echo ini_get("memory_limit") . "\n";'
- name: SHELL | Check vhost
shell: "curl -v -H 'Host: {{ vhost }}' http://127.0.0.1/phpinfo.php 2> /dev/null | grep h1 | grep -o 'PHP Version {{ php_version }}' | sed -r 's/<//g'"
args:
@@ -120,6 +134,14 @@
register: c
failed_when: c.stdout == ''
- name: SHELL | Check custom php value
shell: "curl -H 'Host: {{ vhost }}' http://127.0.0.1/ini.php 2> /dev/null"
args:
warn: false
changed_when: false
register: c
failed_when: 'php_fpm_poold.1.php_admin_value.memory_limit not in c.stdout'
- name: URI | Check ping
uri:
url: "http://localhost{{ php_fpm_poold.0.ping_path }}"