2015-07-15 20:18:51 +07:00
|
|
|
---
|
|
|
|
|
2016-01-12 20:40:09 +07:00
|
|
|
- name: FAIL | Check vhost and SSL/TLS support
|
|
|
|
fail: msg="Missmatch configuration for vhost {{ item.name if item.name is string else item.name[0] }}"
|
2016-01-12 21:01:01 +07:00
|
|
|
when: >
|
|
|
|
item.proto is defined and
|
|
|
|
'https' in item.proto and
|
|
|
|
item.ssl_name is not defined
|
2016-01-12 20:40:09 +07:00
|
|
|
with_items: nginx_vhosts
|
|
|
|
|
2015-11-04 15:16:59 +07:00
|
|
|
- name: FILE | Create root directory
|
|
|
|
file: >
|
|
|
|
path={{ nginx_root }}
|
|
|
|
state=directory
|
|
|
|
|
2015-11-05 21:38:18 +07:00
|
|
|
- name: FILE | Create root public folders (foreach nginx_vhosts)
|
2015-07-30 18:02:21 +07:00
|
|
|
file: >
|
2015-10-22 15:25:30 +07:00
|
|
|
path={{ nginx_root }}/{{ item.name if item.name is string else item.name[0] }}/public
|
2015-07-30 18:02:21 +07:00
|
|
|
state=directory
|
|
|
|
owner={{ item.owner | default('www-data') }}
|
|
|
|
group={{ item.group | default('www-data') }}
|
|
|
|
mode={{ item.mode | default('0755') }}
|
2015-07-15 20:18:51 +07:00
|
|
|
with_items: nginx_vhosts
|
2015-11-30 18:16:17 +07:00
|
|
|
when: >
|
|
|
|
item.root is not defined and
|
2016-01-22 15:46:43 +07:00
|
|
|
(item.template is defined and item.template not in nginx_templates_no_dir) and
|
2015-12-01 21:46:57 +07:00
|
|
|
(item.delete is not defined or not item.delete) and
|
|
|
|
item.redirect_to is not defined
|
2015-07-15 20:18:51 +07:00
|
|
|
|
|
|
|
- name: TEMPLATE | Create vhosts
|
2015-07-30 18:02:21 +07:00
|
|
|
template: >
|
2015-12-01 21:46:57 +07:00
|
|
|
src=etc/nginx/sites-available/{{ item.template if item.redirect_to is not defined else '_redirect' }}.j2
|
2015-10-22 15:25:30 +07:00
|
|
|
dest=/etc/nginx/sites-available/{{ item.name if item.name is string else item.name[0] }}
|
2015-07-15 20:18:51 +07:00
|
|
|
with_items: nginx_vhosts
|
|
|
|
notify: reload nginx
|
2015-07-31 06:02:37 +07:00
|
|
|
when: item.delete is not defined or not item.delete
|
2015-07-15 20:18:51 +07:00
|
|
|
|
2015-07-30 18:02:21 +07:00
|
|
|
- name: FILE | Delete vhosts
|
2015-11-30 20:41:35 +07:00
|
|
|
file: path=/etc/nginx/sites-available/{{ item.name if item.name is string else item.name[0] }} state=absent
|
2015-07-30 18:02:21 +07:00
|
|
|
with_items: nginx_vhosts
|
|
|
|
notify: reload nginx
|
|
|
|
when: item.delete is defined and item.delete
|
|
|
|
|
|
|
|
- name: FILE | Enable vhosts
|
|
|
|
file: >
|
2015-10-22 15:25:30 +07:00
|
|
|
src=/etc/nginx/sites-available/{{ item.name if item.name is string else item.name[0] }}
|
|
|
|
dest=/etc/nginx/sites-enabled/{{ item.name if item.name is string else item.name[0] }}
|
2015-07-30 18:02:21 +07:00
|
|
|
state=link
|
2015-07-15 20:18:51 +07:00
|
|
|
with_items: nginx_vhosts
|
|
|
|
notify: reload nginx
|
2015-07-31 06:02:37 +07:00
|
|
|
when: >
|
|
|
|
((item.enable is not defined) or
|
|
|
|
(item.enable is defined and item.enable)) and
|
|
|
|
(item.delete is not defined or not item.delete)
|
2015-07-15 20:18:51 +07:00
|
|
|
|
2015-07-30 18:02:21 +07:00
|
|
|
- name: FILE | Disable vhosts
|
2015-11-30 20:41:35 +07:00
|
|
|
file: path=/etc/nginx/sites-enabled/{{ item.name if item.name is string else item.name[0] }} state=absent
|
2015-07-15 20:18:51 +07:00
|
|
|
with_items: nginx_vhosts
|
2015-07-30 18:02:21 +07:00
|
|
|
notify: reload nginx
|
2015-11-30 20:41:35 +07:00
|
|
|
when: (item.enable is defined and not item.enable) or (item.delete is defined and item.delete)
|
2015-07-30 18:02:21 +07:00
|
|
|
|
2016-01-21 23:08:01 +07:00
|
|
|
- name: FILE | Delete default vhost when explicitely defined
|
|
|
|
file: >
|
|
|
|
path=/etc/nginx/sites-enabled/default
|
|
|
|
state=absent
|
|
|
|
notify: reload nginx
|
|
|
|
when: nginx_default_vhost is not none
|
|
|
|
|
|
|
|
- name: FILE | Auto set default vhost
|
|
|
|
file: >
|
|
|
|
src=/etc/nginx/sites-available/default
|
|
|
|
dest=/etc/nginx/sites-enabled/default
|
|
|
|
state=link
|
|
|
|
notify: reload nginx
|
|
|
|
when: nginx_default_vhost is none
|