]> git.phdru.name Git - ansible.git/blob - playbooks/debian/roles/add_apache_vhost/tasks/main.yml
0c9567558ceeff6df9e3b3d25697655506e35260
[ansible.git] / playbooks / debian / roles / add_apache_vhost / tasks / main.yml
1 - name: Check vhost
2   command: "test -L /etc/apache2/sites-enabled/{{ virtual_host }}.conf"
3   failed_when: false
4   register: vhost
5   changed_when: vhost.rc != 0
6
7 - name: Configure site
8   become: true
9   template:
10     src: vhost.conf
11     dest: "/etc/apache2/sites-available/{{ virtual_host }}.conf"
12     owner: root
13     group: root
14     mode: '0640'
15     force: no
16   notify: Reload apache
17   when: vhost.rc != 0
18
19 - name: Enable site
20   become: true
21   command: "a2ensite {{ virtual_host }}"
22   notify: Reload apache
23   when: vhost.rc != 0
24
25 - name: Create directories
26   become: true
27   file:
28     path: "{{ item }}/{{ virtual_host }}"
29     state: directory
30     owner: root
31     group: www-data
32     mode: '0755'
33   loop: ['/usr/local/apache2/cgi-bin', '/usr/local/apache2/htdocs',
34          '/var/log/apache2',
35         ]
36   when: vhost.rc != 0