common/tasks/apache/install.yml

94 lines
2.7 KiB
YAML
Raw Normal View History

2020-01-20 18:00:02 +00:00
---
- name: Install Apache
apt:
2020-01-21 13:01:44 +00:00
name: apache2
2020-01-20 18:00:02 +00:00
- name: Create directories for Apache configuration
file:
state: directory
path: '{{ item }}'
2021-09-01 20:53:48 +00:00
mode: 'u=rwx,go=rx'
2020-01-20 18:00:02 +00:00
owner: root
group: root
with_items:
- '{{ common__apache__conf_dir }}'
2020-07-13 20:09:31 +00:00
- '{{ common__apache__conf_available_dir }}'
- '{{ common__apache__conf_enabled_dir }}'
2020-01-20 18:00:02 +00:00
- '{{ common__apache__available_dir }}'
- '{{ common__apache__enabled_dir }}'
2020-02-06 14:47:51 +00:00
- '{{ common__apache__snippets_dir }}'
2020-07-14 21:01:08 +00:00
notify: common | Restart Apache
2020-01-20 18:00:02 +00:00
2020-01-22 22:00:40 +00:00
- name: Configure Apache ports
template:
src: templates/apache/ports.conf
2020-02-06 14:59:32 +00:00
dest: '{{ common__apache__conf_dir }}/ports.conf'
2021-09-01 20:53:48 +00:00
mode: 'u=rw,go=r'
2020-01-22 22:00:40 +00:00
owner: root
group: root
notify: common | Restart Apache
2020-07-14 20:54:52 +00:00
- name: Disable Apache logging
file:
state: absent
path: '{{ common__apache__conf_enabled_dir }}/other-vhosts-access-log.conf'
2020-07-14 21:01:08 +00:00
notify: common | Restart Apache
2020-07-14 20:54:52 +00:00
2020-07-13 20:09:31 +00:00
- name: Install Apache log config
copy:
src: 'files/apache/syslog.conf'
dest: '{{ common__apache__conf_available_dir }}/syslog.conf'
2021-09-01 20:53:48 +00:00
mode: 'u=rw,go=r'
2020-07-13 20:09:31 +00:00
owner: root
group: root
notify: common | Restart Apache
- name: Enable Apache log config
file:
state: link
src: '{{ common__apache__conf_available_dir }}/syslog.conf'
dest: '{{ common__apache__conf_enabled_dir }}/syslog.conf'
owner: root
group: root
notify: common | Restart Apache
2020-07-14 20:55:19 +00:00
- name: Disable directory listing
lineinfile:
path: '{{ common__apache__conf_dir }}/apache2.conf'
regexp: '^Options Indexes FollowSymLinks$'
line: 'Options FollowSymLinks'
notify: common | Restart Apache
2020-01-20 18:00:02 +00:00
- 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 11:48:55 +00:00
2020-01-21 12:10:58 +00:00
- name: Enable Apache modules
command: '/usr/sbin/a2enmod "{{ item }}"'
register: common__apache__enable_apache_modules_result
changed_when: >
common__apache__enable_apache_modules_result.stdout is search('Enabling module')
with_items: '{{ common__apache__modules }}'
notify: common | Restart Apache
2020-01-21 11:48:55 +00:00
- name: Add Apache sites
template:
src: 'templates/apache/{{ item.type }}.conf'
dest: '{{ common__apache__available_dir }}/{{ item.domain }}.conf'
2021-09-01 20:53:48 +00:00
mode: 'u=rw,go=r'
2020-01-21 11:48:55 +00:00
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 11:58:09 +00:00
changed_when: >
common__apache__enable_apache_sites_result.stdout is search('Enabling site')
2020-01-21 11:48:55 +00:00
with_items: '{{ common__apache__sites }}'
notify: common | Restart Apache