Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create more plays do enable and disable confs. #260

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_conf_enabled: []
apache_conf_disabled: []
```

Same as Apache mods. But this is for additional confs. The corresponding direcotry is `conf-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
apache_conf_enabled: []

# Disable these configs
apache_conf_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 }}/conf-available/{{ item }}.conf"
dest: "{{ apache_server_root }}/conf-enabled/{{ item }}.conf"
state: link
mode: "0644"
with_items: "{{ apache_conf_enabled }}"
notify: restart apache

- name: Disable Apache confs..
ansible.builtin.file:
path: "{{ apache_server_root }}/conf-enabled/{{ item }}.conf"
state: absent
with_items: "{{ apache_conf_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