[FreeBSD] restart nginx on vhost config changed
parent
72edbe8656
commit
3087154335
|
@ -7,3 +7,7 @@
|
||||||
|
|
||||||
- name: real-reload nginx
|
- name: real-reload nginx
|
||||||
service: name=nginx state=reloaded
|
service: name=nginx state=reloaded
|
||||||
|
|
||||||
|
- name: restart nginx freebsd
|
||||||
|
service: name=nginx state=restarted
|
||||||
|
when: ansible_distribution == "FreeBSD"
|
||||||
|
|
|
@ -44,13 +44,13 @@
|
||||||
src=etc/nginx/sites-available/{{ item.template if item.redirect_to is not defined else '_redirect' }}.j2
|
src=etc/nginx/sites-available/{{ item.template if item.redirect_to is not defined else '_redirect' }}.j2
|
||||||
dest={{ nginx_etc_dir }}/sites-available/{{ item.filename | default(item.name if item.name is string else item.name[0]) }}
|
dest={{ nginx_etc_dir }}/sites-available/{{ item.filename | default(item.name if item.name is string else item.name[0]) }}
|
||||||
with_items: "{{ nginx_vhosts }}"
|
with_items: "{{ nginx_vhosts }}"
|
||||||
notify: reload nginx
|
notify: ['reload nginx', 'restart nginx freebsd']
|
||||||
when: item.delete is not defined or not item.delete
|
when: item.delete is not defined or not item.delete
|
||||||
|
|
||||||
- name: FILE | Delete vhosts
|
- name: FILE | Delete vhosts
|
||||||
file: path={{ nginx_etc_dir }}/sites-available/{{ item.filename | default(item.name if item.name is string else item.name[0]) }} state=absent
|
file: path={{ nginx_etc_dir }}/sites-available/{{ item.filename | default(item.name if item.name is string else item.name[0]) }} state=absent
|
||||||
with_items: "{{ nginx_vhosts }}"
|
with_items: "{{ nginx_vhosts }}"
|
||||||
notify: reload nginx
|
notify: ['reload nginx', 'restart nginx freebsd']
|
||||||
when: item.delete is defined and item.delete
|
when: item.delete is defined and item.delete
|
||||||
|
|
||||||
- name: FILE | Enable vhosts
|
- name: FILE | Enable vhosts
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
dest={{ nginx_etc_dir }}/sites-enabled/{{ item.filename | default(item.name if item.name is string else item.name[0]) }}
|
dest={{ nginx_etc_dir }}/sites-enabled/{{ item.filename | default(item.name if item.name is string else item.name[0]) }}
|
||||||
state=link
|
state=link
|
||||||
with_items: "{{ nginx_vhosts }}"
|
with_items: "{{ nginx_vhosts }}"
|
||||||
notify: reload nginx
|
notify: ['reload nginx', 'restart nginx freebsd']
|
||||||
when: >
|
when: >
|
||||||
((item.enable is not defined) or
|
((item.enable is not defined) or
|
||||||
(item.enable is defined and item.enable)) and
|
(item.enable is defined and item.enable)) and
|
||||||
|
@ -68,14 +68,14 @@
|
||||||
- name: FILE | Disable vhosts
|
- name: FILE | Disable vhosts
|
||||||
file: path={{ nginx_etc_dir}}/sites-enabled/{{ item.filename | default(item.name if item.name is string else item.name[0]) }} state=absent
|
file: path={{ nginx_etc_dir}}/sites-enabled/{{ item.filename | default(item.name if item.name is string else item.name[0]) }} state=absent
|
||||||
with_items: "{{ nginx_vhosts }}"
|
with_items: "{{ nginx_vhosts }}"
|
||||||
notify: reload nginx
|
notify: ['reload nginx', 'restart nginx freebsd']
|
||||||
when: (item.enable is defined and not item.enable) or (item.delete is defined and item.delete)
|
when: (item.enable is defined and not item.enable) or (item.delete is defined and item.delete)
|
||||||
|
|
||||||
- name: FILE | Delete default vhost when explicitely defined
|
- name: FILE | Delete default vhost when explicitely defined
|
||||||
file: >
|
file: >
|
||||||
path={{ nginx_etc_dir }}/sites-enabled/default
|
path={{ nginx_etc_dir }}/sites-enabled/default
|
||||||
state=absent
|
state=absent
|
||||||
notify: reload nginx
|
notify: ['reload nginx', 'restart nginx freebsd']
|
||||||
when: nginx_default_vhost is not none
|
when: nginx_default_vhost is not none
|
||||||
|
|
||||||
- name: FILE | Auto set default vhost
|
- name: FILE | Auto set default vhost
|
||||||
|
@ -83,5 +83,5 @@
|
||||||
src={{ nginx_etc_dir }}/sites-available/default
|
src={{ nginx_etc_dir }}/sites-available/default
|
||||||
dest={{ nginx_etc_dir }}/sites-enabled/default
|
dest={{ nginx_etc_dir }}/sites-enabled/default
|
||||||
state=link
|
state=link
|
||||||
notify: reload nginx
|
notify: ['reload nginx', 'restart nginx freebsd']
|
||||||
when: nginx_default_vhost is none
|
when: nginx_default_vhost is none
|
||||||
|
|
Loading…
Reference in New Issue