PHP works

pull/2/head
Emilien Mantel 2015-07-15 16:26:27 +02:00
parent 1d025d1f35
commit 721606056d
6 changed files with 24 additions and 41 deletions

View File

@ -23,8 +23,8 @@
with_fileglob: '../templates/etc/nginx/helpers/*.j2' with_fileglob: '../templates/etc/nginx/helpers/*.j2'
notify: reload nginx notify: reload nginx
- name: INCLUDE | PHP configuration - name: INCLUDE | Upstream configuration
include: php.yml include: upstream.yml
when: nginx_php when: nginx_php
- name: INCLUDE | Vhosts configuration - name: INCLUDE | Vhosts configuration

View File

@ -1,10 +0,0 @@
---
- name: INCLUDE_VARS | Include PHP defaults vars from PHP role if unspecified
include_vars: ../../php/defaults/main.yml
when: php_fpm_socket is undefined
- name: TEMPLATE | Deploy PHP upstream (UNIX sockets) to Nginx
template: src=etc/nginx/upstream/php.conf.j2 dest=/etc/nginx/conf.d/php.conf
notify: reload nginx

View File

@ -0,0 +1,6 @@
---
- name: TEMPLATE | Deploy PHP upstream to Nginx
template: src=etc/nginx/upstream/php.conf.j2 dest=/etc/nginx/conf.d/php.conf
notify: reload nginx

View File

@ -1,26 +1,22 @@
# #
# {{ ansible_managed }} # {{ ansible_managed }}
# #
{% if nginx_php_method == 'tcp' %}
{% if nginx_php_method == 'unix' %}
upstream php {
{% for item in php_fpm_unix_sockets %}
server unix:{{ item }};
{% endfor %}
}
{% elif nginx_php_method == 'tcp' %}
upstream php { upstream php {
{% if nginx_cluster_php_method is defined %} {% if nginx_cluster_php_method is defined %}
{{ nginx_cluster_php_method }}; {{ nginx_cluster_php_method }};
{% endif %} {% endif %}
{% for item in nginx_cluster_servers %} {% for item in nginx_php_tcp_sockets %}
server {{ item.host }}:{{ item.port }} weight={{ item.weight | default('100') }} max_fails={{ item.max_fails | default('5') }} fail_timeout={{ item.fail_timeout | default('10s') }}; server {{ item.host }}:{{ item.port }} weight={{ item.weight | default('100') }} max_fails={{ item.max_fails | default('5') }} fail_timeout={{ item.fail_timeout | default('10s') }};
{% endfor %} {% endfor %}
} }
{% elif nginx_php_method == 'unix' %}
upstream php {
{% for item in nginx_php_unix_sockets %}
server unix:{{ item }};
{% endfor %}
}
{% else %} {% else %}
#
# Bad configuration...
#
{% endif %} {% endif %}
# vim:filetype=nginx # vim:filetype=nginx

View File

@ -1,14 +0,0 @@
#
# {{ ansible_managed }}
#
upstream php {
{% if nginx_cluster_php_method is defined %}
{{ nginx_cluster_php_method }};
{% endif %}
{% for item in nginx_cluster_servers %}
server {{ item.host }}:{{ item.port }} weight={{ item.weight | default('100') }} max_fails={{ item.max_fails | default('5') }} fail_timeout={{ item.fail_timeout | default('10s') }};
{% endfor %}
}
# vim:filetype=nginx

View File

@ -1,13 +1,18 @@
--- ---
- hosts: all - hosts: all
pre_tasks:
- apt: pkg=php5-fpm update_cache=yes cache_valid_time=3600 state=present
vars: vars:
nginx_php: true
nginx_vhosts: nginx_vhosts:
- name: 'test.local' - name: 'test.local'
template: 'static' template: 'static'
ssl: ssl:
use: false use: false
generatekey: false - name: 'test-php.local'
template: 'strong' template: 'wordpress'
ssl:
use: false
roles: roles:
- ../../ - ../../