initial commit

This commit is contained in:
Ludovic Cartier
2024-12-17 17:20:50 +01:00
parent a24d032a03
commit 4c65e9c8b4
17 changed files with 315 additions and 2 deletions

66
tasks/vhost.yml Normal file
View File

@@ -0,0 +1,66 @@
---
- 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