2020-01-20 13:00:02 -05:00
|
|
|
---
|
|
|
|
- name: Install Apache
|
|
|
|
apt:
|
|
|
|
name: apache2
|
|
|
|
|
|
|
|
- name: Create directories for Apache configuration
|
|
|
|
file:
|
|
|
|
state: directory
|
|
|
|
path: '{{ item }}'
|
|
|
|
mode: 'u=rwx,g=rx,o=rx'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
with_items:
|
|
|
|
- '{{ common__apache__conf_dir }}'
|
|
|
|
- '{{ common__apache__available_dir }}'
|
|
|
|
- '{{ common__apache__enabled_dir }}'
|
|
|
|
|
|
|
|
- name: Disable directory listing
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/apache2/apache2.conf
|
|
|
|
regexp: '^Options Indexes FollowSymLinks$'
|
|
|
|
line: 'Options FollowSymLinks'
|
|
|
|
notify: common | Restart Apache
|
|
|
|
|
|
|
|
- name: Remove Apache default site
|
|
|
|
file:
|
|
|
|
state: absent
|
|
|
|
path: '{{ common__apache__enabled_dir }}/000-default.conf'
|
|
|
|
when: common__apache__remove_default|bool
|
|
|
|
notify: common | Restart Apache
|
2020-01-21 06:48:55 -05:00
|
|
|
|
|
|
|
- name: Add Apache sites
|
|
|
|
template:
|
|
|
|
src: 'templates/apache/{{ item.type }}.conf'
|
|
|
|
dest: '{{ common__apache__available_dir }}/{{ item.domain }}.conf'
|
|
|
|
mode: 'u=rw,g=r,o=r'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
with_items: '{{ common__apache__sites }}'
|
|
|
|
notify: common | Restart Apache
|
|
|
|
|
|
|
|
- name: Enable Apache sites
|
|
|
|
command: '/usr/sbin/a2ensite "{{ item.domain }}.conf"'
|
|
|
|
register: common__apache__enable_apache_sites_result
|
2020-01-21 06:58:09 -05:00
|
|
|
changed_when: >
|
|
|
|
common__apache__enable_apache_sites_result.stdout is search('Enabling site')
|
2020-01-21 06:48:55 -05:00
|
|
|
with_items: '{{ common__apache__sites }}'
|
|
|
|
notify: common | Restart Apache
|