|
@@ -1,16 +1,20 @@
|
1
|
|
-- name: Create directory for blog HTML
|
2
|
|
- file: state=directory path=/var/www/{{ domain }} group=www-data owner={{ main_user_name }}
|
|
1
|
+- name: Create directories for HTML documents
|
|
2
|
+ file: state=directory path={{ item }} group=www-data owner={{ main_user_name }}
|
|
3
|
+ with_items: "{{ virtual_domains | json_query('[*].doc_root') | unique }}"
|
3
|
4
|
|
4
|
|
-- name: Rename existing Apache blog virtualhost
|
5
|
|
- command: mv /etc/apache2/sites-available/{{ domain }} /etc/apache2/sites-available/{{ domain }}.conf removes=/etc/apache2/sites-available/{{ domain }}
|
|
5
|
+- name: Create the Apache sites config file
|
|
6
|
+ template:
|
|
7
|
+ src=etc_apache2_sites-available_blog.j2
|
|
8
|
+ dest=/etc/apache2/sites-available/{{ item.name }}.conf
|
|
9
|
+ owner=root
|
|
10
|
+ group=root
|
|
11
|
+ with_items: "{{ virtual_domains }}"
|
6
|
12
|
|
7
|
|
-- name: Remove old sites-enabled/{{ domain }} symlink (new one will be created by a2ensite)
|
8
|
|
- file: path=/etc/apache2/sites-enabled/{{ domain }} state=absent
|
|
13
|
+- name: Remove old sites-enabled symlinks (new ones will be created by a2ensite)
|
|
14
|
+ file: path=/etc/apache2/sites-enabled/{{ item }}.conf state=absent
|
|
15
|
+ with_items: "{{ virtual_domains | json_query('[*].name') }}"
|
9
|
16
|
|
10
|
|
-- name: Configure the Apache HTTP server for the blog
|
11
|
|
- template: src=etc_apache2_sites-available_blog.j2 dest=/etc/apache2/sites-available/{{ domain }}.conf group=root owner=root
|
12
|
|
-
|
13
|
|
-- name: Enable blog site
|
14
|
|
- command: a2ensite {{ domain }}.conf creates=/etc/apache2/sites-enabled/{{ domain }}.conf
|
|
17
|
+- name: Enable Apache sites (creates new sites-enabled symlinks)
|
|
18
|
+ command: a2ensite {{ item }}.conf creates=/etc/apache2/sites-enabled/{{ item }}.conf
|
15
|
19
|
notify: restart apache
|
16
|
|
-
|
|
20
|
+ with_items: "{{ virtual_domains | json_query('[*].name') }}"
|