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-04-27 02:36:32 +02:00
|
|
|
src: "{{ item.template|default(nginx_vhost_template) }}"
|
2017-06-03 16:01:09 +02:00
|
|
|
dest: "{{ nginx_vhost_path }}/{{ item.filename|default(item.server_name.split(' ')[0] ~ '.conf') }}"
|
2017-03-25 19:15:04 +01:00
|
|
|
force: yes
|
|
|
|
owner: root
|
|
|
|
group: root
|
2015-02-21 06:34:31 +01:00
|
|
|
mode: 0644
|
2017-04-21 14:46:45 +02:00
|
|
|
when: item.state|default('present') != 'absent'
|
2017-03-25 19:15:04 +01:00
|
|
|
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-06-03 16:01:09 +02:00
|
|
|
path: "{{ nginx_vhost_path }}/{{ item.filename|default(item.server_name.split(' ')[0] ~ '.conf') }}"
|
2015-02-21 06:34:31 +01:00
|
|
|
state: absent
|
2017-04-21 14:46:45 +02:00
|
|
|
when: item.state|default('present') == 'absent'
|
2017-03-25 19:15:04 +01:00
|
|
|
with_items: "{{ nginx_vhosts }}"
|
2016-09-24 17:35:18 +02:00
|
|
|
notify: reload nginx
|
2017-04-22 17:03:18 +02:00
|
|
|
|
|
|
|
- name: Remove legacy vhosts.conf file.
|
|
|
|
file:
|
|
|
|
path: "{{ nginx_vhost_path }}/vhosts.conf"
|
|
|
|
state: absent
|
|
|
|
notify: reload nginx
|