diff --git a/defaults/main.yml b/defaults/main.yml index 71e4f38..bece1dd 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -31,11 +31,11 @@ nginx_helper_dir: '{{ nginx_etc_dir}}/helper' # # PHP -nginx_php5: false -nginx_php7: false -nginx_php5_sockets: +nginx_php56: false +nginx_php70: false +nginx_php56_sockets: - unix_socket: "/run/php5-fpm.sock" -nginx_php7_sockets: +nginx_php70_sockets: - unix_socket: "/run/php/php7.0-fpm.sock" nginx_upstreams: [] diff --git a/doc/php.md b/doc/php.md index 965a7aa..f011018 100644 --- a/doc/php.md +++ b/doc/php.md @@ -1,8 +1,8 @@ PHP === -- `nginx_php5` and `nginx_php7`: boolean if you need to preconfigure PHP (default: false) -- `nginx_php_sockets`: list of sockets (see bellow) +- `nginx_php56` and `nginx_php70`: boolean if you need to preconfigure PHP (default: false) +- `nginx_php##_sockets`: list of sockets (see bellow) You should see [Nginx upstream module doc](http://nginx.org/en/docs/http/ngx_http_upstream_module.html). diff --git a/tasks/upstream.yml b/tasks/upstream.yml index 27c274b..593dd8b 100644 --- a/tasks/upstream.yml +++ b/tasks/upstream.yml @@ -4,7 +4,7 @@ template: > src=etc/nginx/upstream/php.conf.j2 dest="{{ nginx_etc_dir }}/conf.d/php.conf" - when: nginx_php5 or nginx_php7 + when: nginx_php56 or nginx_php70 notify: reload nginx - name: TEMPLATE | Deploy other upstreams diff --git a/templates/etc/nginx/sites-available/_php.j2 b/templates/etc/nginx/sites-available/_php.j2 index 95e410f..aa16be5 100644 --- a/templates/etc/nginx/sites-available/_php.j2 +++ b/templates/etc/nginx/sites-available/_php.j2 @@ -1,10 +1,10 @@ {% extends "_base.j2" %} {% macro phpv(version) %} -{% if version == 5 %} -{{ nginx_upstream_php5 -}} -{% elif version == 7 %} -{{ nginx_upstream_php7 -}} +{% if version == 56 %} +{{ nginx_upstream_php56 -}} +{% elif version == 70 %} +{{ nginx_upstream_php70 -}} {% else %} {# Hack... define another upstream #} {{ version -}} @@ -13,10 +13,10 @@ {% if item.php_version is defined %} {% set php_upstream = phpv(item.php_version) %} -{% elif nginx_php5 %} -{% set php_upstream = phpv(5) %} -{% elif nginx_php7 %} -{% set php_upstream = phpv(7) %} +{% elif nginx_php56 %} +{% set php_upstream = phpv(56) %} +{% elif nginx_php70 %} +{% set php_upstream = phpv(70) %} {% endif %} {% block template_index %} diff --git a/templates/etc/nginx/upstream/php.conf.j2 b/templates/etc/nginx/upstream/php.conf.j2 index 834fb06..08afcb8 100644 --- a/templates/etc/nginx/upstream/php.conf.j2 +++ b/templates/etc/nginx/upstream/php.conf.j2 @@ -2,9 +2,9 @@ # {{ ansible_managed }} # -{% if nginx_php5 %} -upstream {{ nginx_upstream_php5 }} { -{% for item in nginx_php5_sockets %} +{% if nginx_php56 %} +upstream {{ nginx_upstream_php56 }} { +{% for item in nginx_php56_sockets %} {% if item.unix_socket is defined %} server unix:{{ item.unix_socket }} weight={{ item.weight | default('1') }}; {% else %} @@ -14,9 +14,9 @@ upstream {{ nginx_upstream_php5 }} { } {% endif %} -{% if nginx_php7 %} -upstream {{ nginx_upstream_php7 }} { -{% for item in nginx_php7_sockets %} +{% if nginx_php70 %} +upstream {{ nginx_upstream_php70 }} { +{% for item in nginx_php70_sockets %} {% if item.unix_socket is defined %} server unix:{{ item.unix_socket }} weight={{ item.weight | default('1') }}; {% else %} diff --git a/tests/includes/pre_Debian.yml b/tests/includes/pre_Debian.yml index abbe21c..d3eb893 100644 --- a/tests/includes/pre_Debian.yml +++ b/tests/includes/pre_Debian.yml @@ -21,7 +21,9 @@ - fcgiwrap - nghttp2 - php5-fpm + - php5-sqlite - php7.0-fpm + - php7.0-sqlite3 - strace - vim diff --git a/tests/includes/pre_FreeBSD.yml b/tests/includes/pre_FreeBSD.yml index 8ae6c1d..b4da2d2 100644 --- a/tests/includes/pre_FreeBSD.yml +++ b/tests/includes/pre_FreeBSD.yml @@ -4,8 +4,8 @@ set_fact: nginx_pkgng_package: 'nginx-devel' nginx_user: 'www' - nginx_php7: false - nginx_php5_sockets: + nginx_php70: false + nginx_php56_sockets: - host: '127.0.0.1' port: 9000 diff --git a/tests/test.yml b/tests/test.yml index 92229d2..263891c 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -17,8 +17,8 @@ nginx_worker_processes: 1 # Ansible+FreeBSD can't detect CPU number nginx_apt_package: 'nginx-extras' nginx_backports: true - nginx_php5: true - nginx_php7: true + nginx_php56: true + nginx_php70: true nginx_upstreams: - name: 'test' servers: @@ -147,7 +147,7 @@ '/': - 'alias /var/tmp;' - name: 'test-php.local' - php_version: 7 + php_version: 70 upstream_params: - 'fastcgi_param FOO bar;' redirect_from: diff --git a/vars/main.yml b/vars/main.yml index 419a315..c296632 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -33,5 +33,5 @@ nginx_templates_no_dir: - '_owncloud' - '_proxy' -nginx_upstream_php5: 'php5' -nginx_upstream_php7: 'php7' +nginx_upstream_php56: 'php56' +nginx_upstream_php70: 'php70'