nginx_vhosts[x].name now accepts list or string

pull/14/head
Emilien Mantel 2015-10-22 10:25:30 +02:00
parent 803f435b48
commit 70529e223d
4 changed files with 12 additions and 15 deletions

View File

@ -53,7 +53,7 @@ You can see many examples in: [tests/test.yml](tests/test.yml).
#### Common #### Common
- `name`: (M) List of domain used. The first occurence is the most important! - `name`: (M) Domain or list of domain used.
- `template`: (M) template used to create vhost - `template`: (M) template used to create vhost
- `enable`: (O) Enable the vhost (default is true) - `enable`: (O) Enable the vhost (default is true)
- `delete`: (O) Delete the vhost (default is false) - `delete`: (O) Delete the vhost (default is false)

View File

@ -2,7 +2,7 @@
- name: FILE | Create root folders (foreach nginx_vhosts) - name: FILE | Create root folders (foreach nginx_vhosts)
file: > file: >
path={{ nginx_root }}/{{ item.name[0] }}/public path={{ nginx_root }}/{{ item.name if item.name is string else item.name[0] }}/public
state=directory state=directory
owner={{ item.owner | default('www-data') }} owner={{ item.owner | default('www-data') }}
group={{ item.group | default('www-data') }} group={{ item.group | default('www-data') }}
@ -13,7 +13,7 @@
- name: TEMPLATE | Create vhosts - name: TEMPLATE | Create vhosts
template: > template: >
src=etc/nginx/sites-available/{{ item.template }}.j2 src=etc/nginx/sites-available/{{ item.template }}.j2
dest=/etc/nginx/sites-available/{{ item.name[0] }} dest=/etc/nginx/sites-available/{{ item.name if item.name is string else item.name[0] }}
with_items: nginx_vhosts with_items: nginx_vhosts
notify: reload nginx notify: reload nginx
when: item.delete is not defined or not item.delete when: item.delete is not defined or not item.delete
@ -23,16 +23,16 @@
# with_fileglob: "web/*" # with_fileglob: "web/*"
- name: FILE | Delete vhosts - name: FILE | Delete vhosts
file: dest=/etc/nginx/sites-enabled/{{ item.name[0] }} state=absent file: dest=/etc/nginx/sites-enabled/{{ item.name if item.name is string else item.name[0] }} state=absent
file: dest=/etc/nginx/sites-available/{{ item.name[0] }} state=absent file: dest=/etc/nginx/sites-available/{{ item.name if item.name is string else item.name[0] }} state=absent
with_items: nginx_vhosts with_items: nginx_vhosts
notify: reload nginx notify: reload nginx
when: item.delete is defined and item.delete when: item.delete is defined and item.delete
- name: FILE | Enable vhosts - name: FILE | Enable vhosts
file: > file: >
src=/etc/nginx/sites-available/{{ item.name[0] }} src=/etc/nginx/sites-available/{{ item.name if item.name is string else item.name[0] }}
dest=/etc/nginx/sites-enabled/{{ item.name[0] }} dest=/etc/nginx/sites-enabled/{{ item.name if item.name is string else item.name[0] }}
state=link state=link
with_items: nginx_vhosts with_items: nginx_vhosts
notify: reload nginx notify: reload nginx
@ -42,7 +42,7 @@
(item.delete is not defined or not item.delete) (item.delete is not defined or not item.delete)
- name: FILE | Disable vhosts - name: FILE | Disable vhosts
file: dest=/etc/nginx/sites-enabled/{{ item.name[0] }} state=absent file: dest=/etc/nginx/sites-enabled/{{ item.name if item.name is string else item.name[0] }} state=absent
with_items: nginx_vhosts with_items: nginx_vhosts
notify: reload nginx notify: reload nginx
when: item.enable is defined and not item.enable when: item.enable is defined and not item.enable

View File

@ -12,7 +12,7 @@ server {
{% for port in __listen %} {% for port in __listen %}
listen {{ port }}; listen {{ port }};
{% endfor %} {% endfor %}
server_name {{ item.name | join(' ') }}; server_name {% if item.name is string %}{{ item.name }}{% else %}{{ item.name | join(' ') }}{% endif %};
{% if item.root is defined %} {% if item.root is defined %}
root {{ item.root }}; root {{ item.root }};
{% else %} {% else %}

View File

@ -30,21 +30,18 @@
- 'return 403;' - 'return 403;'
'/gunther': '/gunther':
- 'return 404;' - 'return 404;'
- name: - name: 'test-php.local'
- 'test-php.local'
upstream_params: upstream_params:
- 'fastcgi_param FOO bar;' - 'fastcgi_param FOO bar;'
redirect_from: redirect_from:
- 'www.test-php.local' - 'www.test-php.local'
template: '_php' template: '_php'
- name: - name: 'test-proxy.local'
- 'test-proxy.local'
listen: listen:
- 8080 - 8080
template: '_proxy' template: '_proxy'
upstream_name: 'test' upstream_name: 'test'
- name: - name: 'deleted.local'
- 'deleted.local'
template: '_base' template: '_base'
delete: true delete: true
roles: roles: