4 Commits

Author SHA1 Message Date
Emilien Mantel
3fdc16578c Improve file deletions 2015-11-30 14:41:35 +01:00
Emilien Mantel
1d56fc249d Deleted vhost don't need a template 2015-11-30 12:16:17 +01:00
Emilien Mantel
bfe4a315f9 Vhost dir 2015-11-05 15:38:18 +01:00
Emilien Mantel
9fcba824f5 Create root directory 2015-11-04 09:16:59 +01:00
3 changed files with 26 additions and 7 deletions

View File

@@ -55,7 +55,7 @@ You can see many examples in: [tests/test.yml](tests/test.yml).
#### Common
- `name`: (M) Domain or list of domain used.
- `template`: (M) template used to create vhost
- `template`: (M) template used to create vhost. Optional if you set `delete` to true.
- `enable`: (O) Enable the vhost (default is true)
- `delete`: (O) Delete the vhost (default is false)
- `redirect_from`: (O) Domain list to redirect to the first `name`. You can use this key to redirect non-www to www

View File

@@ -1,6 +1,24 @@
---
- name: FILE | Create root directory
file: >
path={{ nginx_root }}
state=directory
- name: FILE | Create root folders (foreach nginx_vhosts)
file: >
path={{ nginx_root }}/{{ item.name if item.name is string else item.name[0] }}
state=directory
owner={{ item.owner | default('www-data') }}
group={{ item.group | default('www-data') }}
mode={{ item.mode | default('0755') }}
with_items: nginx_vhosts
when: >
item.root is not defined and
(item.template is defined and item.template != '_proxy') and
(item.delete is not defined or not item.delete)
- name: FILE | Create root public folders (foreach nginx_vhosts)
file: >
path={{ nginx_root }}/{{ item.name if item.name is string else item.name[0] }}/public
state=directory
@@ -8,7 +26,10 @@
group={{ item.group | default('www-data') }}
mode={{ item.mode | default('0755') }}
with_items: nginx_vhosts
when: item.root is not defined and item.template != '_proxy'
when: >
item.root is not defined and
(item.template is defined and item.template != '_proxy') and
(item.delete is not defined or not item.delete)
- name: TEMPLATE | Create vhosts
template: >
@@ -23,8 +44,7 @@
# with_fileglob: "web/*"
- name: FILE | Delete vhosts
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 if item.name is string else item.name[0] }} state=absent
file: path=/etc/nginx/sites-available/{{ item.name if item.name is string else item.name[0] }} state=absent
with_items: nginx_vhosts
notify: reload nginx
when: item.delete is defined and item.delete
@@ -42,10 +62,10 @@
(item.delete is not defined or not item.delete)
- name: FILE | Disable vhosts
file: dest=/etc/nginx/sites-enabled/{{ item.name if item.name is string else item.name[0] }} state=absent
file: path=/etc/nginx/sites-enabled/{{ item.name if item.name is string else item.name[0] }} state=absent
with_items: nginx_vhosts
notify: reload nginx
when: item.enable is defined and not item.enable
when: (item.enable is defined and not item.enable) or (item.delete is defined and item.delete)
#- name: FILE | Create ssl dir per vhost (if needed)
# file: dest=/etc/nginx/ssl/{{ item.name }} owner=root mode=0750 state=directory

View File

@@ -49,7 +49,6 @@
template: '_proxy'
upstream_name: 'test'
- name: 'deleted.local'
template: '_base'
delete: true
roles:
- ../../