mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add parameter warn_mpm_module to control when warning are raised
This commit is contained in:
parent
6fb212b104
commit
cdee15acc8
4 changed files with 63 additions and 5 deletions
|
@ -49,6 +49,11 @@ options:
|
||||||
- Ignore configuration checks about inconsistent module configuration. Especially for mpm_* modules.
|
- Ignore configuration checks about inconsistent module configuration. Especially for mpm_* modules.
|
||||||
type: bool
|
type: bool
|
||||||
default: false
|
default: false
|
||||||
|
warn_mpm_absent:
|
||||||
|
description:
|
||||||
|
- Control the behavior of the warning process for MPM modules.
|
||||||
|
type: bool
|
||||||
|
default: true
|
||||||
requirements: ["a2enmod","a2dismod"]
|
requirements: ["a2enmod","a2dismod"]
|
||||||
notes:
|
notes:
|
||||||
- This does not work on RedHat-based distributions. It does work on Debian- and SuSE-based distributions.
|
- This does not work on RedHat-based distributions. It does work on Debian- and SuSE-based distributions.
|
||||||
|
@ -78,6 +83,18 @@ EXAMPLES = '''
|
||||||
name: mpm_worker
|
name: mpm_worker
|
||||||
ignore_configcheck: true
|
ignore_configcheck: true
|
||||||
|
|
||||||
|
- name: Disable mpm_event, enable mpm_prefork and ignore warnings about missing mpm module
|
||||||
|
community.general.apache2_module:
|
||||||
|
name: "{{ item.module }}"
|
||||||
|
state: "{{ item.state }}"
|
||||||
|
warn_mpm_absent: False
|
||||||
|
ignore_configcheck: True
|
||||||
|
loop:
|
||||||
|
- module: mpm_event
|
||||||
|
state: absent
|
||||||
|
- module: mpm_prefork
|
||||||
|
state: present
|
||||||
|
|
||||||
- name: Enable dump_io module, which is identified as dumpio_module inside apache2
|
- name: Enable dump_io module, which is identified as dumpio_module inside apache2
|
||||||
community.general.apache2_module:
|
community.general.apache2_module:
|
||||||
state: present
|
state: present
|
||||||
|
@ -140,6 +157,7 @@ def _module_is_enabled(module):
|
||||||
error_msg = "Error executing %s: %s" % (control_binary, stderr)
|
error_msg = "Error executing %s: %s" % (control_binary, stderr)
|
||||||
if module.params['ignore_configcheck']:
|
if module.params['ignore_configcheck']:
|
||||||
if 'AH00534' in stderr and 'mpm_' in module.params['name']:
|
if 'AH00534' in stderr and 'mpm_' in module.params['name']:
|
||||||
|
if module.params['warn_mpm_absent']:
|
||||||
module.warnings.append(
|
module.warnings.append(
|
||||||
"No MPM module loaded! apache2 reload AND other module actions"
|
"No MPM module loaded! apache2 reload AND other module actions"
|
||||||
" will fail if no MPM module is loaded immediately."
|
" will fail if no MPM module is loaded immediately."
|
||||||
|
@ -249,6 +267,7 @@ def main():
|
||||||
force=dict(type='bool', default=False),
|
force=dict(type='bool', default=False),
|
||||||
state=dict(default='present', choices=['absent', 'present']),
|
state=dict(default='present', choices=['absent', 'present']),
|
||||||
ignore_configcheck=dict(type='bool', default=False),
|
ignore_configcheck=dict(type='bool', default=False),
|
||||||
|
warn_mpm_absent=dict(type='bool', default=True),
|
||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
---
|
||||||
|
# This test represent the misleading behavior of the following issue: https://github.com/ansible-collections/community.general/issues/635
|
||||||
|
- name: Disable MPM event module
|
||||||
|
apache2_module:
|
||||||
|
name: "{{ item.module}}"
|
||||||
|
state: "{{ item.state}}"
|
||||||
|
ignore_configcheck: true
|
||||||
|
register: disable_mpm_modules
|
||||||
|
with_items:
|
||||||
|
- { module: mpm_event, state: absent }
|
||||||
|
- { module: mpm_prefork, state: present }
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "'warnings' in disable_mpm_modules"
|
||||||
|
- disable_mpm_modules["warnings"] == [
|
||||||
|
"No MPM module loaded! apache2 reload AND other module actions will fail if no MPM module is loaded immediately.",
|
||||||
|
"No MPM module loaded! apache2 reload AND other module actions will fail if no MPM module is loaded immediately."
|
||||||
|
]
|
||||||
|
|
||||||
|
- name: Disable MPM event module
|
||||||
|
apache2_module:
|
||||||
|
name: "{{ item.module}}"
|
||||||
|
state: "{{ item.state}}"
|
||||||
|
ignore_configcheck: true
|
||||||
|
warn_mpm_absent: False
|
||||||
|
register: disable_mpm_modules
|
||||||
|
with_items:
|
||||||
|
- { module: mpm_event, state: absent }
|
||||||
|
- { module: mpm_prefork, state: present }
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "'warnings' not in disable_mpm_modules"
|
|
@ -180,7 +180,7 @@
|
||||||
- mpm_worker
|
- mpm_worker
|
||||||
- mpm_event
|
- mpm_event
|
||||||
- mpm_prefork
|
- mpm_prefork
|
||||||
ignore_errors: yes
|
ignore_errors: true
|
||||||
register: remove_with_configcheck
|
register: remove_with_configcheck
|
||||||
|
|
||||||
- name: ensure configcheck fails task with when run without mpm modules
|
- name: ensure configcheck fails task with when run without mpm modules
|
||||||
|
|
|
@ -45,3 +45,8 @@
|
||||||
that: modules_before.stdout == modules_after.stdout
|
that: modules_before.stdout == modules_after.stdout
|
||||||
when: ansible_os_family in ['Debian', 'Suse']
|
when: ansible_os_family in ['Debian', 'Suse']
|
||||||
# centos/RHEL does not have a2enmod/a2dismod
|
# centos/RHEL does not have a2enmod/a2dismod
|
||||||
|
|
||||||
|
- name: include misleading warning test
|
||||||
|
include: 635-apache2-misleading-warning.yml
|
||||||
|
when: ansible_os_family in ['Debian', 'Suse']
|
||||||
|
# centos/RHEL does not have a2enmod/a2dismod
|
Loading…
Reference in a new issue