66 lines
1.9 KiB
YAML
66 lines
1.9 KiB
YAML
---
|
|
- name: 'apache2 | vhost | configure vhosts'
|
|
template:
|
|
src: "{{ item.value.template | default('vhost.conf.j2') }}"
|
|
dest: "/etc/apache2/sites-available/{{ item.key }}.conf"
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
loop: "{{ apache2_vhosts | dict2items }}"
|
|
notify:
|
|
- apache2 reload
|
|
tags:
|
|
- apache2
|
|
- apache2_vhost
|
|
|
|
- name: 'apache2 | vhost | enable vhosts'
|
|
file:
|
|
src: "/etc/apache2/sites-available/{{ item.key }}.conf"
|
|
dest: "/etc/apache2/sites-enabled/{%if item.value.priority is defined%}{{ item.value.priority }}-{%endif%}{{ item.key }}.conf"
|
|
state: link
|
|
loop: "{{ apache2_vhosts | dict2items }}"
|
|
when: item.value.enabled is not defined or item.value.enabled
|
|
notify:
|
|
- apache2 reload
|
|
tags:
|
|
- apache2
|
|
- apache2_vhost
|
|
|
|
- name: 'apache2 | vhost | configure DocumentRoot'
|
|
file:
|
|
path: "{{ item.value.documentroot.path | default(apache2_documentroot_default) }}"
|
|
state: directory
|
|
owner: "{{ item.value.documentroot.user | default(apache2_user) }}"
|
|
group: "{{ item.value.documentroot.group | default(apache2_group) }}"
|
|
loop: "{{ apache2_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:
|
|
- apache2 reload
|
|
tags:
|
|
- apache2
|
|
- apache2_vhost
|
|
|
|
- name: 'apache2 | vhost | configure logs directory'
|
|
file:
|
|
path: "/var/log/apache2/{{ item.value.servername }}"
|
|
state: directory
|
|
owner: root
|
|
group: adm
|
|
loop: "{{ apache_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:
|
|
- apache2 reload
|
|
tags:
|
|
- apache2
|
|
- apache2_vhost
|