From eb6192c050780be18f349312d667a62a1bb6e33e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20Nilsen?= Date: Tue, 19 Apr 2016 23:44:08 +0200 Subject: [PATCH] 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 --- web_infrastructure/apache2_module.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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']) ), )