diff --git a/web_infrastructure/apache2_module.py b/web_infrastructure/apache2_module.py index ecc176a20b3..7616c6f88b3 100644 --- a/web_infrastructure/apache2_module.py +++ b/web_infrastructure/apache2_module.py @@ -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']) ), )