Skip to content

Commit

Permalink
Create more plays do enable and disable confs.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-hell committed Nov 19, 2024
1 parent 5a9ba74 commit f224d92
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ apache_mods_enabled:
- ssl
apache_mods_disabled: []

# Enable additional configs

Check failure on line 50 in defaults/main.yml

View workflow job for this annotation

GitHub Actions / Lint

50:28 [trailing-spaces] trailing spaces
apache_confs_enabled: []

# Disable these configs
apache_confs_disabled: []

# Set initial apache state. Recommended values: `started` or `stopped`
apache_state: started

Expand Down
38 changes: 27 additions & 11 deletions tasks/configure-Debian.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit f224d92

Please sign in to comment.