-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement deployment of conf files and conf files for modules
- Loading branch information
Showing
6 changed files
with
159 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
%YAML 1.2 | ||
--- | ||
argument_specs: | ||
apache_conf_item: | ||
short_description: Specification of Apache httpd conf/module item. | ||
description: Specification of Apache httpd conf/module item. | ||
options: | ||
name: | ||
description: Name of Apache's httpd configuration file(fragment). | ||
required: true | ||
type: str | ||
state: | ||
description: State of configuration file - present, absent etc. | ||
required: false | ||
type: str | ||
choices: ['present', 'absent', 'purged'] | ||
conf_content: | ||
description: Content of configuration file itself. | ||
required: false | ||
type: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
- name: Check conf configuration against spec file | ||
ansible.builtin.validate_argument_spec: | ||
argument_spec: | | ||
{{ | ||
( | ||
lookup( | ||
'ansible.builtin.file', | ||
'specs/apache_conf_argument_specs.yml' | ||
) | from_yaml | ||
)['argument_specs']['apache_conf_item']['options'] | ||
}} | ||
provided_arguments: "{{ _apache_conf_item }}" | ||
|
||
- name: Create Apache config file. | ||
ansible.builtin.copy: | ||
content: "{{ _apache_conf_item.conf_content }}" | ||
dest: "{{ apache_httpd_conf_load_dir }}/{{ _apache_conf_item.name }}.conf" | ||
owner: root | ||
group: root | ||
mode: '0644' | ||
when: | ||
- _apache_conf_item.state | default('present') == 'present' | ||
- _apache_conf_item.conf_content is defined | ||
become: true | ||
|
||
# NOTE(zstyblik): run a2en* regardless | ||
# re-add check "is in a2q STDOUT", if necessary to save cycles. | ||
- name: Enable Apache config file. | ||
ansible.builtin.command: | ||
argv: | ||
- /usr/sbin/a2enconf | ||
- -q | ||
- "{{ _apache_conf_item.name }}" | ||
register: _apache_cmd_a2enconf | ||
changed_when: "'To activate the new configuration' in _apache_cmd_a2enconf.stdout_lines" | ||
failed_when: _apache_cmd_a2enconf.rc != 0 | ||
when: | ||
- _apache_conf_item.state | default('present') == 'present' | ||
notify: restart apache | ||
become: true | ||
|
||
- name: Disable Apache config file. | ||
ansible.builtin.command: | ||
argv: | ||
- /usr/sbin/a2disconf | ||
- -q | ||
- "{{ _apache_conf_item.name }}" | ||
register: _apache_cmd_a2disconf | ||
changed_when: "'To activate the new configuration' in _apache_cmd_a2disconf.stdout_lines" | ||
failed_when: _apache_cmd_a2disconf.rc != 0 | ||
when: | ||
- _apache_conf_item.state | default('present') != 'present' | ||
- _apache_conf_item.name in _apache_a2q_confs | ||
notify: restart apache | ||
become: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
- name: Check mod configuration against spec file | ||
ansible.builtin.validate_argument_spec: | ||
argument_spec: | | ||
{{ | ||
( | ||
lookup( | ||
'ansible.builtin.file', | ||
'specs/apache_conf_argument_specs.yml' | ||
) | from_yaml | ||
)['argument_specs']['apache_conf_item']['options'] | ||
}} | ||
provided_arguments: "{{ _apache_mod_item }}" | ||
|
||
- name: Create config file for Apache module. | ||
ansible.builtin.copy: | ||
content: "{{ _apache_mod_item.conf_content }}" | ||
dest: "{{ apache_httpd_mod_load_dir }}/{{ _apache_mod_item.name }}.conf" | ||
owner: root | ||
group: root | ||
mode: '0644' | ||
when: | ||
- _apache_mod_item.state | default('present') == 'present' | ||
- _apache_mod_item.conf_content is defined | ||
become: true | ||
|
||
# NOTE(zstyblik): run a2en* regardless | ||
# re-add check "is in a2q STDOUT", if necessary to save cycles. | ||
- name: Enable Apache module. | ||
ansible.builtin.command: | ||
argv: | ||
- /usr/sbin/a2enmod | ||
- -q | ||
- "{{ _apache_mod_item.name }}" | ||
register: _apache_cmd_a2enmod | ||
changed_when: "'To activate the new configuration' in _apache_cmd_a2enmod.stdout_lines" | ||
failed_when: _apache_cmd_a2enmod.rc != 0 | ||
when: | ||
- _apache_mod_item.state | default('present') == 'present' | ||
notify: restart apache | ||
become: true | ||
|
||
- name: Disable Apache module. | ||
ansible.builtin.command: | ||
argv: | ||
- /usr/sbin/a2dismod | ||
- -q | ||
- "{{ _apache_mod_item.name }}" | ||
register: _apache_cmd_a2dismod | ||
changed_when: "'To activate the new configuration' in _apache_cmd_a2dismod.stdout_lines" | ||
failed_when: _apache_cmd_a2dismod.rc != 0 | ||
when: | ||
- _apache_mod_item.state | default('present') != 'present' | ||
- _apache_mod_item.name in _apache_a2q_mods | ||
- _apache_mod_item.name != _apache_mpm_module | ||
notify: restart apache | ||
become: true |