Create more plays do enable and disable confs.

This commit is contained in:
shell 2024-11-19 18:37:19 +01:00
parent 5a9ba7442c
commit f224d9227a
3 changed files with 40 additions and 11 deletions

View file

@ -112,6 +112,13 @@ apache_options: "-Indexes +FollowSymLinks"
The default values for the `AllowOverride` and `Options` directives for the `documentroot` directory of each vhost. A vhost can overwrite these values by specifying `allow_override` or `options`.
```yaml
apache_confs_enabled: []
apache_confss_disabled: []
```
Same as Apache mods. But this is for additional confs. The corresponding direcotry is `mods-available` inside the apache apache configuration directory.
```yaml
apache_mods_enabled:
- rewrite

View file

@ -47,6 +47,12 @@ apache_mods_enabled:
- ssl
apache_mods_disabled: []
# Enable additional configs
apache_confs_enabled: []
# Disable these configs
apache_confs_disabled: []
# Set initial apache state. Recommended values: `started` or `stopped`
apache_state: started

View file

@ -1,58 +1,74 @@
---
- name: Configure Apache.
lineinfile:
ansible.builtin.lineinfile:
dest: "{{ apache_server_root }}/ports.conf"
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
state: present
mode: 0644
mode: "0644"
with_items: "{{ apache_ports_configuration_items }}"
notify: restart apache
- name: Enable Apache mods.
file:
ansible.builtin.file:
src: "{{ apache_server_root }}/mods-available/{{ item }}.load"
dest: "{{ apache_server_root }}/mods-enabled/{{ item }}.load"
state: link
mode: 0644
mode: "0644"
with_items: "{{ apache_mods_enabled }}"
notify: restart apache
- name: Disable Apache mods.
file:
ansible.builtin.file:
path: "{{ apache_server_root }}/mods-enabled/{{ item }}.load"
state: absent
with_items: "{{ apache_mods_disabled }}"
notify: restart apache
- name: Enable Apache confs.
ansible.builtin.file:
src: "{{ apache_server_root }}/confs-available/{{ item }}.load"
dest: "{{ apache_server_root }}/confs-enabled/{{ item }}.load"
state: link
mode: "0644"
with_items: "{{ apache_confs_enabled }}"
notify: restart apache
- name: Disable Apache confs..
ansible.builtin.file:
path: "{{ apache_server_root }}/confs-enabled/{{ item }}.load"
state: absent
with_items: "{{ apache_confs_disabled }}"
notify: restart apache
- name: Check whether certificates defined in vhosts exist.
stat: "path={{ item.certificate_file }}"
ansible.builtin.stat: "path={{ item.certificate_file }}"
register: apache_ssl_certificates
with_items: "{{ apache_vhosts_ssl }}"
no_log: "{{ apache_ssl_no_log }}"
- name: Add apache vhosts configuration.
template:
ansible.builtin.template:
src: "{{ apache_vhosts_template }}"
dest: "{{ apache_conf_path }}/sites-available/{{ apache_vhosts_filename }}"
owner: root
group: root
mode: 0644
mode: "0644"
notify: restart apache
when: apache_create_vhosts | bool
- name: Add vhost symlink in sites-enabled.
file:
ansible.builtin.file:
src: "{{ apache_conf_path }}/sites-available/{{ apache_vhosts_filename }}"
dest: "{{ apache_conf_path }}/sites-enabled/{{ apache_vhosts_filename }}"
state: link
mode: 0644
mode: "0644"
force: "{{ ansible_check_mode }}"
notify: restart apache
when: apache_create_vhosts | bool
- name: Remove default vhost in sites-enabled.
file:
ansible.builtin.file:
path: "{{ apache_conf_path }}/sites-enabled/{{ apache_default_vhost_filename }}"
state: absent
notify: restart apache