mirror of
https://github.com/geerlingguy/ansible-role-apache
synced 2025-01-18 15:30:19 +01:00
Create more plays do enable and disable confs.
This commit is contained in:
parent
5a9ba7442c
commit
f224d9227a
3 changed files with 40 additions and 11 deletions
|
@ -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`.
|
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
|
```yaml
|
||||||
apache_mods_enabled:
|
apache_mods_enabled:
|
||||||
- rewrite
|
- rewrite
|
||||||
|
|
|
@ -47,6 +47,12 @@ apache_mods_enabled:
|
||||||
- ssl
|
- ssl
|
||||||
apache_mods_disabled: []
|
apache_mods_disabled: []
|
||||||
|
|
||||||
|
# Enable additional configs
|
||||||
|
apache_confs_enabled: []
|
||||||
|
|
||||||
|
# Disable these configs
|
||||||
|
apache_confs_disabled: []
|
||||||
|
|
||||||
# Set initial apache state. Recommended values: `started` or `stopped`
|
# Set initial apache state. Recommended values: `started` or `stopped`
|
||||||
apache_state: started
|
apache_state: started
|
||||||
|
|
||||||
|
|
|
@ -1,58 +1,74 @@
|
||||||
---
|
---
|
||||||
- name: Configure Apache.
|
- name: Configure Apache.
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
dest: "{{ apache_server_root }}/ports.conf"
|
dest: "{{ apache_server_root }}/ports.conf"
|
||||||
regexp: "{{ item.regexp }}"
|
regexp: "{{ item.regexp }}"
|
||||||
line: "{{ item.line }}"
|
line: "{{ item.line }}"
|
||||||
state: present
|
state: present
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
with_items: "{{ apache_ports_configuration_items }}"
|
with_items: "{{ apache_ports_configuration_items }}"
|
||||||
notify: restart apache
|
notify: restart apache
|
||||||
|
|
||||||
- name: Enable Apache mods.
|
- name: Enable Apache mods.
|
||||||
file:
|
ansible.builtin.file:
|
||||||
src: "{{ apache_server_root }}/mods-available/{{ item }}.load"
|
src: "{{ apache_server_root }}/mods-available/{{ item }}.load"
|
||||||
dest: "{{ apache_server_root }}/mods-enabled/{{ item }}.load"
|
dest: "{{ apache_server_root }}/mods-enabled/{{ item }}.load"
|
||||||
state: link
|
state: link
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
with_items: "{{ apache_mods_enabled }}"
|
with_items: "{{ apache_mods_enabled }}"
|
||||||
notify: restart apache
|
notify: restart apache
|
||||||
|
|
||||||
- name: Disable Apache mods.
|
- name: Disable Apache mods.
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: "{{ apache_server_root }}/mods-enabled/{{ item }}.load"
|
path: "{{ apache_server_root }}/mods-enabled/{{ item }}.load"
|
||||||
state: absent
|
state: absent
|
||||||
with_items: "{{ apache_mods_disabled }}"
|
with_items: "{{ apache_mods_disabled }}"
|
||||||
notify: restart apache
|
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.
|
- name: Check whether certificates defined in vhosts exist.
|
||||||
stat: "path={{ item.certificate_file }}"
|
ansible.builtin.stat: "path={{ item.certificate_file }}"
|
||||||
register: apache_ssl_certificates
|
register: apache_ssl_certificates
|
||||||
with_items: "{{ apache_vhosts_ssl }}"
|
with_items: "{{ apache_vhosts_ssl }}"
|
||||||
no_log: "{{ apache_ssl_no_log }}"
|
no_log: "{{ apache_ssl_no_log }}"
|
||||||
|
|
||||||
- name: Add apache vhosts configuration.
|
- name: Add apache vhosts configuration.
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: "{{ apache_vhosts_template }}"
|
src: "{{ apache_vhosts_template }}"
|
||||||
dest: "{{ apache_conf_path }}/sites-available/{{ apache_vhosts_filename }}"
|
dest: "{{ apache_conf_path }}/sites-available/{{ apache_vhosts_filename }}"
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
notify: restart apache
|
notify: restart apache
|
||||||
when: apache_create_vhosts | bool
|
when: apache_create_vhosts | bool
|
||||||
|
|
||||||
- name: Add vhost symlink in sites-enabled.
|
- name: Add vhost symlink in sites-enabled.
|
||||||
file:
|
ansible.builtin.file:
|
||||||
src: "{{ apache_conf_path }}/sites-available/{{ apache_vhosts_filename }}"
|
src: "{{ apache_conf_path }}/sites-available/{{ apache_vhosts_filename }}"
|
||||||
dest: "{{ apache_conf_path }}/sites-enabled/{{ apache_vhosts_filename }}"
|
dest: "{{ apache_conf_path }}/sites-enabled/{{ apache_vhosts_filename }}"
|
||||||
state: link
|
state: link
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
force: "{{ ansible_check_mode }}"
|
force: "{{ ansible_check_mode }}"
|
||||||
notify: restart apache
|
notify: restart apache
|
||||||
when: apache_create_vhosts | bool
|
when: apache_create_vhosts | bool
|
||||||
|
|
||||||
- name: Remove default vhost in sites-enabled.
|
- name: Remove default vhost in sites-enabled.
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: "{{ apache_conf_path }}/sites-enabled/{{ apache_default_vhost_filename }}"
|
path: "{{ apache_conf_path }}/sites-enabled/{{ apache_default_vhost_filename }}"
|
||||||
state: absent
|
state: absent
|
||||||
notify: restart apache
|
notify: restart apache
|
||||||
|
|
Loading…
Reference in a new issue