Open julien-lecomte opened 2 years ago
Files identified in the description:
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
cc @berendt @n0trax click here for bot help
Files identified in the description:
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
I can confirm this.
It looks like the module is not checking the return code of a2enmod
; but checks the output.
A minimalistic test with 2 modules, where both are already installed and just one produces the output:
ansible [core 2.16.1]
config file = /home/zerwes/00PRIV/ansible/ansible.cfg
configured module search path = ['/home/zerwes/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/zerwes/git/ansible/rls-ansible/lib/python3.11/site-packages/ansible
ansible collection location = /home/zerwes/00PRIV/ansible/.collections:/home/zerwes/.ansible/collections:/usr/share/ansible/collections
executable location = /home/zerwes/git/ansible/rls-ansible/bin/ansible
python version = 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] (/home/zerwes/git/ansible/rls-ansible/bin/python)
jinja version = 3.1.2
libyaml = True
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye
---
- hosts: deb11-cl.zero-sys.net
tasks:
- name: a2enmod
community.general.apache2_module:
name: "{{ item }}"
state: present
ignore_configcheck: true
with_items:
- headers
- mpm_prefork
- php8.1
<192.168.101.81> (0, b'\n{"changed": false, "result": "Module headers enabled", "warnings": [], "invocation": {"module_args": {"name": "headers", "state": "present", "ignore_configcheck": true, "force": false, "identifier": "headers_module"}}}\n', b'')
ok: [deb11-cl.zero-sys.net] => (item=headers) => {
"ansible_loop_var": "item",
"changed": false,
"invocation": {
"module_args": {
"force": false,
"identifier": "headers_module",
"ignore_configcheck": true,
"name": "headers",
"state": "present"
}
},
"item": "headers",
"result": "Module headers enabled"
}
<192.168.101.81> (1, b'\n{"rc": 0, "stdout": "Considering dependency mpm_prefork for php8.1:\\nConsidering conflict mpm_event for mpm_prefork:\\nConsidering conflict mpm_worker for mpm_prefork:\\nModule mpm_prefork already enabled\\nConsidering conflict php5 for php8.1:\\nModule php8.1 already enabled\\n", "stderr": "", "failed": true, "msg": "Failed to set module php8.1 to enabled:\\nConsidering dependency mpm_prefork for php8.1:\\nConsidering conflict mpm_event for mpm_prefork:\\nConsidering conflict mpm_worker for mpm_prefork:\\nModule mpm_prefork already enabled\\nConsidering conflict php5 for php8.1:\\nModule php8.1 already enabled\\n\\nMaybe the module identifier (php8_module) was guessed incorrectly.Consider setting the \\"identifier\\" option.", "invocation": {"module_args": {"name": "php8.1", "state": "present", "ignore_configcheck": true, "force": false, "identifier": "php8_module"}}}\n', b'')
failed: [deb11-cl.zero-sys.net] (item=php8.1) => {
"ansible_loop_var": "item",
"changed": false,
"invocation": {
"module_args": {
"force": false,
"identifier": "php8_module",
"ignore_configcheck": true,
"name": "php8.1",
"state": "present"
}
},
"item": "php8.1",
"msg": "Failed to set module php8.1 to enabled:\nConsidering dependency mpm_prefork for php8.1:\nConsidering conflict mpm_event for mpm_prefork:\nConsidering conflict mpm_worker for mpm_prefork:\nModule mpm_prefork already enabled\nConsidering conflict php5 for php8.1:\nModule php8.1 already enabled\n\nMaybe the module identifier (php8_module) was guessed incorrectly.Consider setting the \"identifier\" option.",
"rc": 0,
"stderr": "",
"stderr_lines": [],
"stdout": "Considering dependency mpm_prefork for php8.1:\nConsidering conflict mpm_event for mpm_prefork:\nConsidering conflict mpm_worker for mpm_prefork:\nModule mpm_prefork already enabled\nConsidering conflict php5 for php8.1:\nModule php8.1 already enabled\n",
"stdout_lines": [
"Considering dependency mpm_prefork for php8.1:",
"Considering conflict mpm_event for mpm_prefork:",
"Considering conflict mpm_worker for mpm_prefork:",
"Module mpm_prefork already enabled",
"Considering conflict php5 for php8.1:",
"Module php8.1 already enabled"
]
}
# a2enmod php8.1; echo $?
Considering dependency mpm_prefork for php8.1:
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
Module mpm_prefork already enabled
Considering conflict php5 for php8.1:
Module php8.1 already enabled
0
Summary
The implicit contract of this ansible module is to have the apache2 module installed at the end of it's run.
In case the configuration is broken, for example with sites-enabled that require modules that are net yet activated, then the module fails.
When specifying ignore_configcheck, the module still fails, and especially doesn't install the missing module.
check_mode apart, the status of the apache a2enmod (when it exists) can be used to detect and set the apache2_module exit code.
Issue Type
Bug Report
Component Name
apache2_module
Ansible Version
Community.general Version
Configuration
OS / Environment
Debiab 10 + Debian 11
Steps to Reproduce
Expected Results
cf. description
Actual Results
Code of Conduct