2015-02-21 06:34:31 +01:00
|
|
|
---
|
|
|
|
- name: Remove default nginx vhost config file (if configured).
|
|
|
|
file:
|
|
|
|
path: "{{ nginx_default_vhost_path }}"
|
|
|
|
state: absent
|
|
|
|
when: nginx_remove_default_vhost
|
2016-10-06 13:59:29 +02:00
|
|
|
notify: restart nginx
|
2015-02-21 06:34:31 +01:00
|
|
|
|
2016-09-24 17:35:18 +02:00
|
|
|
- name: Ensure nginx_vhost_path exists.
|
2016-06-04 08:03:11 +02:00
|
|
|
file:
|
|
|
|
path: "{{ nginx_vhost_path }}"
|
|
|
|
state: directory
|
2016-09-24 17:35:18 +02:00
|
|
|
notify: reload nginx
|
2016-06-04 08:03:11 +02:00
|
|
|
|
2017-03-25 19:15:04 +01:00
|
|
|
- name: Add managed vhost config files.
|
2015-02-21 06:34:31 +01:00
|
|
|
template:
|
2017-03-25 19:15:04 +01:00
|
|
|
src: vhost.j2
|
|
|
|
dest: "{{ nginx_vhost_path }}/{{ item.server_name.split(' ')[0] }}.conf"
|
|
|
|
force: yes
|
|
|
|
owner: root
|
|
|
|
group: root
|
2015-02-21 06:34:31 +01:00
|
|
|
mode: 0644
|
2017-03-25 19:15:04 +01:00
|
|
|
when: "{{ item.state|default('present') != 'absent' }}"
|
|
|
|
with_items: "{{ nginx_vhosts }}"
|
2016-09-24 17:35:18 +02:00
|
|
|
notify: reload nginx
|
2015-02-21 06:34:31 +01:00
|
|
|
|
2017-03-25 19:15:04 +01:00
|
|
|
- name: Remove managed vhost config files.
|
2015-02-21 06:34:31 +01:00
|
|
|
file:
|
2017-03-25 19:15:04 +01:00
|
|
|
path: "{{ nginx_vhost_path }}/{{ item.server_name.split(' ')[0] }}.conf"
|
2015-02-21 06:34:31 +01:00
|
|
|
state: absent
|
2017-03-25 19:15:04 +01:00
|
|
|
when: "{{ item.state|default('present') == 'absent' }}"
|
|
|
|
with_items: "{{ nginx_vhosts }}"
|
2016-09-24 17:35:18 +02:00
|
|
|
notify: reload nginx
|