parent
0010b7e06c
commit
5c61b567a3
@ -0,0 +1,65 @@ |
|||||||
|
--- |
||||||
|
- name: Remove default nginx vhost config file (if configured). |
||||||
|
file: |
||||||
|
path: "{{ nginx_default_vhost_path }}" |
||||||
|
state: absent |
||||||
|
when: nginx_remove_default_vhost |
||||||
|
notify: restart nginx |
||||||
|
|
||||||
|
- name: Ensure nginx_vhost_path exists. |
||||||
|
file: |
||||||
|
path: "{{ nginx_vhost_path }}" |
||||||
|
state: directory |
||||||
|
notify: reload nginx |
||||||
|
|
||||||
|
- name: Ensure nginx_vhost_enabled_path exists. |
||||||
|
file: |
||||||
|
path: "{{ nginx_vhost_enabled_path }}" |
||||||
|
state: directory |
||||||
|
notify: reload nginx |
||||||
|
|
||||||
|
- name: Add managed vhost config files. |
||||||
|
template: |
||||||
|
src: "{{ item.template|default(nginx_vhost_template) }}" |
||||||
|
dest: "{{ nginx_vhost_path }}/{{ item.filename|default(item.server_name.split(' ')[0] ~ '.conf') }}" |
||||||
|
force: yes |
||||||
|
owner: root |
||||||
|
group: root |
||||||
|
mode: 0644 |
||||||
|
when: item.state|default('present') != 'absent' |
||||||
|
with_items: "{{ nginx_vhosts }}" |
||||||
|
notify: reload nginx |
||||||
|
|
||||||
|
- name: Remove managed vhost config files. |
||||||
|
file: |
||||||
|
path: "{{ nginx_vhost_path }}/{{ item.filename|default(item.server_name.split(' ')[0] ~ '.conf') }}" |
||||||
|
state: absent |
||||||
|
when: item.state|default('present') == 'absent' |
||||||
|
with_items: "{{ nginx_vhosts }}" |
||||||
|
notify: reload nginx |
||||||
|
|
||||||
|
- name: Remove legacy vhosts.conf file. |
||||||
|
file: |
||||||
|
path: "{{ nginx_vhost_path }}/vhosts.conf" |
||||||
|
state: absent |
||||||
|
notify: reload nginx |
||||||
|
|
||||||
|
- name: manage the symlink in sites-enabled, enable |
||||||
|
file: |
||||||
|
path: "{{ nginx_vhost_enabled_path }}/{{ item.filename|default(item.server_name.split(' ')[0] ~ '.conf') }}" |
||||||
|
src: "{{ nginx_vhost_path }}/{{ item.filename|default(item.server_name.split(' ')[0] ~ '.conf') }}" |
||||||
|
state: link |
||||||
|
when: item.enabled|default('true') == 'true' |
||||||
|
with_items: "{{ nginx_vhosts }}" |
||||||
|
notify: reload nginx |
||||||
|
|
||||||
|
- name: manage the symlink in sites-enabled, disable |
||||||
|
file: |
||||||
|
path: "{{ nginx_vhost_enabled_path }}/{{ item.filename|default(item.server_name.split(' ')[0] ~ '.conf') }}" |
||||||
|
state: absent |
||||||
|
when: item.enabled|default('true') == 'false' |
||||||
|
with_items: "{{ nginx_vhosts }}" |
||||||
|
notify: reload nginx |
||||||
|
|
||||||
|
|
||||||
|
|
Reference in new issue