Better PHP and vhost management

pull/2/head
Emilien Mantel 2015-07-16 11:44:54 +02:00
parent 57882393b8
commit 5d084416e1
3 changed files with 12 additions and 13 deletions

View File

@ -14,7 +14,11 @@
server_name {{ server_name | join(' ') }};
{% endif %}
{% if item.root is defined %}
root {{ item.root }};
{% else %}
root {{ nginx_root }}/{{ item.name }}/public;
{% endif %}
{% if item.use_access_log is defined and item.use_access_log %}
access_log {{ nginx_log_dir }}/{{ item.name }}_access.log combined;

View File

@ -1,22 +1,15 @@
#
# {{ ansible_managed }}
#
{% if nginx_php_method == 'tcp' %}
upstream php {
{% if nginx_cluster_php_method is defined %}
{{ nginx_cluster_php_method }};
{% endif %}
{% 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') }};
{% endfor %}
}
{% elif nginx_php_method == 'unix' %}
upstream php {
{% for item in nginx_php_unix_sockets %}
server unix:{{ item }};
{% endfor %}
}
{% for item in nginx_php_sockets %}
{% if item.unix_socket is defined %}
server unix:{{ item.unix_socket }} weight={{ item.weight | default('1') }};
{% else %}
server {{ item.host }}:{{ item.port }} weight={{ item.weight | default('1') }} max_fails={{ item.max_fails | default('5') }} fail_timeout={{ item.fail_timeout | default('10s') }};
{% endif %}
{% endfor %}
}
# vim:filetype=nginx

View File

@ -8,6 +8,8 @@
- lineinfile: dest=/etc/hosts line="127.0.2.2 {{ nginx_vhosts|map(attribute='name')| join(' ') }}"
vars:
nginx_php: true
nginx_php_unix_sockets:
- unix_socket: "/var/run/php5-fpm.sock"
nginx_vhosts:
- name: 'test.local'
aliases: