67 lines
1.8 KiB
YAML
67 lines
1.8 KiB
YAML
---
|
||
|
||
- name: 'nginx | configure vhosts'
|
||
template:
|
||
src: "{{ item.value.template | default('vhost.conf.j2') }}"
|
||
dest: "/etc/nginx/sites-available/{{ item.key }}.conf"
|
||
owner: root
|
||
group: root
|
||
mode: 0644
|
||
loop: "{{ nginx_vhosts | dict2items }}"
|
||
notify:
|
||
- nginx reload
|
||
tags:
|
||
- nginx
|
||
- nginx_vhost
|
||
|
||
- name: 'nginx | enable vhosts'
|
||
file:
|
||
src: "/etc/nginx/sites-available/{{ item.key }}.conf"
|
||
dest: "/etc/nginx/sites-enabled/{%if item.value.priority is defined%}{{ item.value.priority }}-{%endif%}{{ item.key }}.conf"
|
||
state: link
|
||
loop: "{{ nginx_vhosts | dict2items }}"
|
||
when: item.value.enabled is not defined or item.value.enabled
|
||
notify:
|
||
- nginx reload
|
||
tags:
|
||
- nginx
|
||
- nginx_vhost
|
||
|
||
- name: 'nginx | configure DocumentRoot'
|
||
file:
|
||
path: "{{ item.value.documentroot.path | default(nginx_documentroot_default) }}"
|
||
state: directory
|
||
owner: "{{ item.value.documentroot.user | default(nginx_user) }}"
|
||
group: "{{ item.value.documentroot.group | default(nginx_group) }}"
|
||
loop: "{{ nginx_vhosts | dict2items }}"
|
||
loop_control:
|
||
label: "{{ item.value.documentroot | default([]) }}"
|
||
when:
|
||
- item.value.enabled is undefined or item.value.enabled
|
||
- item.value.documentroot is defined
|
||
- item.value.documentroot != False
|
||
notify:
|
||
- nginx reload
|
||
tags:
|
||
- nginx
|
||
- nginx_vhost
|
||
|
||
- name: 'nginx | configure nginx logs'
|
||
file:
|
||
path: "/var/log/nginx/{{ item.value.servername }}"
|
||
state: directory
|
||
owner: root
|
||
group: adm
|
||
loop: "{{ nginx_vhosts | dict2items }}"
|
||
loop_control:
|
||
label: "{{ item.value.servername | default([]) }}"
|
||
when:
|
||
- item.value.enabled is undefined or item.value.enabled
|
||
- item.value.documentroot is defined
|
||
- item.value.documentroot != False
|
||
notify:
|
||
- nginx reload
|
||
tags:
|
||
- nginx
|
||
- nginx_vhost
|