mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-08 14:20:04 -07:00
apache2_module - multiple improvements (#3106)
* multiple improvements * added changelog fragment * comment and name in int test files * added notes to the documentation * removed the extraneous changelog frag * Update plugins/modules/web_infrastructure/apache2_module.py * adjusted doc text for sanity check * Update plugins/modules/web_infrastructure/apache2_module.py Co-authored-by: Felix Fontein <felix@fontein.de> * removed extraneous dependency in integration test Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
d974ca32ae
commit
d9533c44aa
4 changed files with 71 additions and 64 deletions
|
@ -13,40 +13,25 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
- name: install apache via apt
|
||||
apt:
|
||||
name: "{{item}}"
|
||||
state: present
|
||||
when: "ansible_os_family == 'Debian'"
|
||||
with_items:
|
||||
- apache2
|
||||
- libapache2-mod-evasive
|
||||
|
||||
- name: install apache via zypper
|
||||
community.general.zypper:
|
||||
name: apache2
|
||||
state: present
|
||||
when: "ansible_os_family == 'Suse'"
|
||||
|
||||
- name: disable userdir module
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: userdir
|
||||
state: absent
|
||||
register: userdir_first_disable
|
||||
|
||||
- name: disable userdir module, second run
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: userdir
|
||||
state: absent
|
||||
register: disable
|
||||
|
||||
- name: ensure apache2_module is idempotent
|
||||
- name: ensure community.general.apache2_module is idempotent
|
||||
assert:
|
||||
that:
|
||||
- disable is not changed
|
||||
|
||||
- name: enable userdir module
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: userdir
|
||||
state: present
|
||||
register: enable
|
||||
|
@ -57,18 +42,18 @@
|
|||
- enable is changed
|
||||
|
||||
- name: enable userdir module, second run
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: userdir
|
||||
state: present
|
||||
register: enabletwo
|
||||
|
||||
- name: ensure apache2_module is idempotent
|
||||
- name: ensure community.general.apache2_module is idempotent
|
||||
assert:
|
||||
that:
|
||||
- 'not enabletwo.changed'
|
||||
|
||||
- name: disable userdir module, final run
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: userdir
|
||||
state: absent
|
||||
register: disablefinal
|
||||
|
@ -79,13 +64,13 @@
|
|||
- 'disablefinal.changed'
|
||||
|
||||
- name: set userdir to original state
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: userdir
|
||||
state: present
|
||||
when: userdir_first_disable is changed
|
||||
|
||||
- name: ensure autoindex enabled
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: autoindex
|
||||
state: present
|
||||
|
||||
|
@ -93,55 +78,56 @@
|
|||
when: "ansible_os_family == 'Debian'"
|
||||
block:
|
||||
- name: force disable of autoindex # bug #2499
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: autoindex
|
||||
state: absent
|
||||
force: True
|
||||
|
||||
- name: reenable autoindex
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: autoindex
|
||||
state: present
|
||||
|
||||
- name: enable evasive module, test https://github.com/ansible/ansible/issues/22635
|
||||
apache2_module:
|
||||
name: evasive
|
||||
state: present
|
||||
|
||||
# mod_evasive is enabled by default upon the installation, so disable first and enable second, to preserve the config
|
||||
- name: disable evasive module
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: evasive
|
||||
state: absent
|
||||
|
||||
- name: enable evasive module, test https://github.com/ansible/ansible/issues/22635
|
||||
community.general.apache2_module:
|
||||
name: evasive
|
||||
state: present
|
||||
|
||||
- name: use identifier to enable module, fix for https://github.com/ansible/ansible/issues/33669
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: dump_io
|
||||
state: present
|
||||
ignore_errors: True
|
||||
register: enable_dumpio_wrong
|
||||
|
||||
- name: disable dump_io
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: dump_io
|
||||
identifier: dumpio_module
|
||||
state: absent
|
||||
|
||||
- name: use identifier to enable module, fix for https://github.com/ansible/ansible/issues/33669
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: dump_io
|
||||
identifier: dumpio_module
|
||||
state: present
|
||||
register: enable_dumpio_correct_1
|
||||
|
||||
- name: ensure idempotency with identifier
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: dump_io
|
||||
identifier: dumpio_module
|
||||
state: present
|
||||
register: enable_dumpio_correct_2
|
||||
|
||||
- name: disable dump_io
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: dump_io
|
||||
identifier: dumpio_module
|
||||
state: absent
|
||||
|
@ -153,7 +139,7 @@
|
|||
- enable_dumpio_correct_2 is not changed
|
||||
|
||||
- name: disable mpm modules
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
ignore_configcheck: True
|
||||
|
@ -163,7 +149,7 @@
|
|||
- mpm_prefork
|
||||
|
||||
- name: enabled mpm_event
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: mpm_event
|
||||
state: present
|
||||
ignore_configcheck: True
|
||||
|
@ -175,7 +161,7 @@
|
|||
- 'enabledmpmevent.changed'
|
||||
|
||||
- name: switch between mpm_event and mpm_worker
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: "{{ item.name }}"
|
||||
state: "{{ item.state }}"
|
||||
ignore_configcheck: True
|
||||
|
@ -186,7 +172,7 @@
|
|||
state: present
|
||||
|
||||
- name: ensure mpm_worker is already enabled
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: mpm_worker
|
||||
state: present
|
||||
register: enabledmpmworker
|
||||
|
@ -197,7 +183,7 @@
|
|||
- 'not enabledmpmworker.changed'
|
||||
|
||||
- name: try to disable all mpm modules with configcheck
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: "{{item}}"
|
||||
state: absent
|
||||
with_items:
|
||||
|
@ -214,7 +200,7 @@
|
|||
with_items: "{{ remove_with_configcheck.results }}"
|
||||
|
||||
- name: try to disable all mpm modules without configcheck
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: "{{item}}"
|
||||
state: absent
|
||||
ignore_configcheck: True
|
||||
|
@ -224,7 +210,7 @@
|
|||
- mpm_prefork
|
||||
|
||||
- name: enabled mpm_event to restore previous state
|
||||
apache2_module:
|
||||
community.general.apache2_module:
|
||||
name: mpm_event
|
||||
state: present
|
||||
ignore_configcheck: True
|
||||
|
|
|
@ -5,8 +5,22 @@
|
|||
####################################################################
|
||||
|
||||
|
||||
- name: install apache via apt
|
||||
apt:
|
||||
name: "{{item}}"
|
||||
state: present
|
||||
when: "ansible_os_family == 'Debian'"
|
||||
with_items:
|
||||
- apache2
|
||||
- libapache2-mod-evasive
|
||||
|
||||
- name:
|
||||
- name: install apache via zypper
|
||||
community.general.zypper:
|
||||
name: apache2
|
||||
state: present
|
||||
when: "ansible_os_family == 'Suse'"
|
||||
|
||||
- name: test apache2_module
|
||||
block:
|
||||
- name: get list of enabled modules
|
||||
shell: apache2ctl -M | sort
|
||||
|
@ -17,8 +31,12 @@
|
|||
- name: get list of enabled modules
|
||||
shell: apache2ctl -M | sort
|
||||
register: modules_after
|
||||
- debug: var=modules_before
|
||||
- debug: var=modules_after
|
||||
- name: modules_before
|
||||
debug:
|
||||
var: modules_before
|
||||
- name: modules_after
|
||||
debug:
|
||||
var: modules_after
|
||||
- name: ensure that all test modules are disabled again
|
||||
assert:
|
||||
that: modules_before.stdout == modules_after.stdout
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue