Add optional force parameter for apache2_module (#3251)
* Add optional force parameter for apache2_module Fixes #2499 * Add documentation for the force parameter * Clarify in description that -f(orce) is a Debian parameter
This commit is contained in:
parent
d91f803897
commit
7e18da79c3
1 changed files with 11 additions and 0 deletions
|
@ -29,6 +29,12 @@ options:
|
|||
description:
|
||||
- name of the module to enable/disable
|
||||
required: true
|
||||
force:
|
||||
description:
|
||||
- force disabling of default modules and override Debian warnings
|
||||
required: false
|
||||
choices: ['yes', 'no']
|
||||
default: no
|
||||
state:
|
||||
description:
|
||||
- indicate the desired state of the resource
|
||||
|
@ -50,10 +56,14 @@ import re
|
|||
|
||||
def _disable_module(module):
|
||||
name = module.params['name']
|
||||
force = module.params['force']
|
||||
a2dismod_binary = module.get_bin_path("a2dismod")
|
||||
if a2dismod_binary is None:
|
||||
module.fail_json(msg="a2dismod not found. Perhaps this system does not use a2dismod to manage apache")
|
||||
|
||||
if force:
|
||||
a2dismod_binary += ' -f'
|
||||
|
||||
result, stdout, stderr = module.run_command("%s %s" % (a2dismod_binary, name))
|
||||
|
||||
if re.match(r'.*\b' + name + r' already disabled', stdout, re.S|re.M):
|
||||
|
@ -82,6 +92,7 @@ def main():
|
|||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
name = dict(required=True),
|
||||
force = dict(required=False, type='bool', default=False),
|
||||
state = dict(default='present', choices=['absent', 'present'])
|
||||
),
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue