vhost - add condition

This commit is contained in:
Ludovic Cartier
2025-10-22 16:54:56 +02:00
parent a8e9f51140
commit cb2ed5524f

View File

@@ -8,6 +8,7 @@
group: root group: root
mode: 0644 mode: 0644
loop: "{{ nginx_vhosts | dict2items }}" loop: "{{ nginx_vhosts | dict2items }}"
when: nginx_vhosts is defined
notify: notify:
- nginx reload - nginx reload
tags: tags:
@@ -20,7 +21,9 @@
dest: "/etc/nginx/sites-enabled/{%if item.value.priority is defined%}{{ item.value.priority }}-{%endif%}{{ item.key }}.conf" dest: "/etc/nginx/sites-enabled/{%if item.value.priority is defined%}{{ item.value.priority }}-{%endif%}{{ item.key }}.conf"
state: link state: link
loop: "{{ nginx_vhosts | dict2items }}" loop: "{{ nginx_vhosts | dict2items }}"
when: item.value.enabled is not defined or item.value.enabled when:
- nginx_vhosts is defined
- item.value.enabled is not defined or item.value.enabled
notify: notify:
- nginx reload - nginx reload
tags: tags:
@@ -37,6 +40,7 @@
loop_control: loop_control:
label: "{{ item.value.documentroot | default([]) }}" label: "{{ item.value.documentroot | default([]) }}"
when: when:
- nginx_vhosts is defined
- item.value.enabled is undefined or item.value.enabled - item.value.enabled is undefined or item.value.enabled
- item.value.documentroot is defined - item.value.documentroot is defined
- item.value.documentroot != False - item.value.documentroot != False
@@ -56,6 +60,7 @@
loop_control: loop_control:
label: "{{ item.value.servername | default([]) }}" label: "{{ item.value.servername | default([]) }}"
when: when:
- nginx_vhosts is defined
- item.value.enabled is undefined or item.value.enabled - item.value.enabled is undefined or item.value.enabled
- item.value.documentroot is defined - item.value.documentroot is defined
- item.value.documentroot != False - item.value.documentroot != False