We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
apache2_module hangs with "WARNING: The following essential module will be disabled."
I have this code in my playbook:

```
- apache2_module: name={{item}} state=absent
  with_items:
    - autoindex
    - negotiation
```

However someone decided that autoindex and negotiation both are "essential", so when I try to disable them I get this warning:

```
# a2dismod autoindex
WARNING: The following essential module will be disabled.
This might result in unexpected behavior and should NOT be done
unless you know exactly what you are doing!
 autoindex

To continue type in the phrase 'Yes, do as I say!' or retry by passing '-f':
```

and expects me to actually type "Yes, do as I say!" (WTF?!?) if I don't provide "-f". The ansible module does not provide that -f parameter, so it locks up.

As weird as that is, I think there _at least_ should be a "force=true" option in apache2_module - or -f should be default.

(Not sure if that's true for all "a2dismod" instances because there is a suspiciously low amount of Google results (none). It is at least there for apache2 currently installed from dotdeb.org)


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `web_infrastructure/apache2_module.py`
Content:
```
1 #!/usr/bin/python
2 #coding: utf-8 -*-
3 
4 # (c) 2013-2014, Christian Berendt <berendt@b1-systems.de>
5 #
6 # This module is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This software is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this software.  If not, see <http://www.gnu.org/licenses/>.
18 
19 DOCUMENTATION = '''
20 ---
21 module: apache2_module
22 version_added: 1.6
23 author: "Christian Berendt (@berendt)"
24 short_description: enables/disables a module of the Apache2 webserver
25 description:
26    - Enables or disables a specified module of the Apache2 webserver.
27 options:
28    name:
29      description:
30         - name of the module to enable/disable
31      required: true
32    state:
33      description:
34         - indicate the desired state of the resource
35      choices: ['present', 'absent']
36      default: present
37 
38 requirements: ["a2enmod","a2dismod"]
39 '''
40 
41 EXAMPLES = '''
42 # enables the Apache2 module "wsgi"
43 - apache2_module: state=present name=wsgi
44 
45 # disables the Apache2 module "wsgi"
46 - apache2_module: state=absent name=wsgi
47 '''
48 
49 import re
50 
51 def _disable_module(module):
52     name = module.params['name']
53     a2dismod_binary = module.get_bin_path("a2dismod")
54     if a2dismod_binary is None:
55         module.fail_json(msg="a2dismod not found.  Perhaps this system does not use a2dismod to manage apache")
56 
57     result, stdout, stderr = module.run_command("%s %s" % (a2dismod_binary, name))
58 
59     if re.match(r'.*\b' + name + r' already disabled', stdout, re.S|re.M):
60         module.exit_json(changed = False, result = "Success")
61     elif result != 0:
62         module.fail_json(msg="Failed to disable module %s: %s" % (name, stdout))
63     else:
64         module.exit_json(changed = True, result = "Disabled")
65 
66 def _enable_module(module):
67     name = module.params['name']
68     a2enmod_binary = module.get_bin_path("a2enmod")
69     if a2enmod_binary is None:
70         module.fail_json(msg="a2enmod not found.  Perhaps this system does not use a2enmod to manage apache")
71 
72     result, stdout, stderr = module.run_command("%s %s" % (a2enmod_binary, name))
73 
74     if re.match(r'.*\b' + name + r' already enabled', stdout, re.S|re.M):
75         module.exit_json(changed = False, result = "Success")
76     elif result != 0:
77         module.fail_json(msg="Failed to enable module %s: %s" % (name, stdout))
78     else:
79         module.exit_json(changed = True, result = "Enabled")
80 
81 def main():
82     module = AnsibleModule(
83         argument_spec = dict(
84             name  = dict(required=True),
85             state = dict(default='present', choices=['absent', 'present'])
86         ),
87     )
88 
89     if module.params['state'] == 'present':
90         _enable_module(module)
91 
92     if module.params['state'] == 'absent':
93         _disable_module(module)
94 
95 # import module snippets
96 from ansible.module_utils.basic import *
97 if __name__ == '__main__':
98     main()
99
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/web_infrastructure/apache2_module.py b/web_infrastructure/apache2_module.py
--- a/web_infrastructure/apache2_module.py
+++ b/web_infrastructure/apache2_module.py
@@ -29,6 +29,12 @@
      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 @@
 
 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 @@
     module = AnsibleModule(
         argument_spec = dict(
             name  = dict(required=True),
+            force = dict(required=False, type='bool', default=False),
             state = dict(default='present', choices=['absent', 'present'])
         ),
     )

{"golden_diff": "diff --git a/web_infrastructure/apache2_module.py b/web_infrastructure/apache2_module.py\n--- a/web_infrastructure/apache2_module.py\n+++ b/web_infrastructure/apache2_module.py\n@@ -29,6 +29,12 @@\n      description:\n         - name of the module to enable/disable\n      required: true\n+   force:\n+     description:\n+        - force disabling of default modules and override Debian warnings\n+     required: false\n+     choices: ['yes', 'no']\n+     default: no\n    state:\n      description:\n         - indicate the desired state of the resource\n@@ -50,10 +56,14 @@\n \n def _disable_module(module):\n     name = module.params['name']\n+    force = module.params['force']\n     a2dismod_binary = module.get_bin_path(\"a2dismod\")\n     if a2dismod_binary is None:\n         module.fail_json(msg=\"a2dismod not found.  Perhaps this system does not use a2dismod to manage apache\")\n \n+    if force:\n+        a2dismod_binary += ' -f'\n+\n     result, stdout, stderr = module.run_command(\"%s %s\" % (a2dismod_binary, name))\n \n     if re.match(r'.*\\b' + name + r' already disabled', stdout, re.S|re.M):\n@@ -82,6 +92,7 @@\n     module = AnsibleModule(\n         argument_spec = dict(\n             name  = dict(required=True),\n+            force = dict(required=False, type='bool', default=False),\n             state = dict(default='present', choices=['absent', 'present'])\n         ),\n     )\n", "issue": "apache2_module hangs with \"WARNING: The following essential module will be disabled.\"\nI have this code in my playbook:\n\n```\n- apache2_module: name={{item}} state=absent\n  with_items:\n    - autoindex\n    - negotiation\n```\n\nHowever someone decided that autoindex and negotiation both are \"essential\", so when I try to disable them I get this warning:\n\n```\n# a2dismod autoindex\nWARNING: The following essential module will be disabled.\nThis might result in unexpected behavior and should NOT be done\nunless you know exactly what you are doing!\n autoindex\n\nTo continue type in the phrase 'Yes, do as I say!' or retry by passing '-f':\n```\n\nand expects me to actually type \"Yes, do as I say!\" (WTF?!?) if I don't provide \"-f\". The ansible module does not provide that -f parameter, so it locks up.\n\nAs weird as that is, I think there _at least_ should be a \"force=true\" option in apache2_module - or -f should be default.\n\n(Not sure if that's true for all \"a2dismod\" instances because there is a suspiciously low amount of Google results (none). It is at least there for apache2 currently installed from dotdeb.org)\n\n", "before_files": [{"content": "#!/usr/bin/python\n#coding: utf-8 -*-\n\n# (c) 2013-2014, Christian Berendt <berendt@b1-systems.de>\n#\n# This module is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this software.  If not, see <http://www.gnu.org/licenses/>.\n\nDOCUMENTATION = '''\n---\nmodule: apache2_module\nversion_added: 1.6\nauthor: \"Christian Berendt (@berendt)\"\nshort_description: enables/disables a module of the Apache2 webserver\ndescription:\n   - Enables or disables a specified module of the Apache2 webserver.\noptions:\n   name:\n     description:\n        - name of the module to enable/disable\n     required: true\n   state:\n     description:\n        - indicate the desired state of the resource\n     choices: ['present', 'absent']\n     default: present\n\nrequirements: [\"a2enmod\",\"a2dismod\"]\n'''\n\nEXAMPLES = '''\n# enables the Apache2 module \"wsgi\"\n- apache2_module: state=present name=wsgi\n\n# disables the Apache2 module \"wsgi\"\n- apache2_module: state=absent name=wsgi\n'''\n\nimport re\n\ndef _disable_module(module):\n    name = module.params['name']\n    a2dismod_binary = module.get_bin_path(\"a2dismod\")\n    if a2dismod_binary is None:\n        module.fail_json(msg=\"a2dismod not found.  Perhaps this system does not use a2dismod to manage apache\")\n\n    result, stdout, stderr = module.run_command(\"%s %s\" % (a2dismod_binary, name))\n\n    if re.match(r'.*\\b' + name + r' already disabled', stdout, re.S|re.M):\n        module.exit_json(changed = False, result = \"Success\")\n    elif result != 0:\n        module.fail_json(msg=\"Failed to disable module %s: %s\" % (name, stdout))\n    else:\n        module.exit_json(changed = True, result = \"Disabled\")\n\ndef _enable_module(module):\n    name = module.params['name']\n    a2enmod_binary = module.get_bin_path(\"a2enmod\")\n    if a2enmod_binary is None:\n        module.fail_json(msg=\"a2enmod not found.  Perhaps this system does not use a2enmod to manage apache\")\n\n    result, stdout, stderr = module.run_command(\"%s %s\" % (a2enmod_binary, name))\n\n    if re.match(r'.*\\b' + name + r' already enabled', stdout, re.S|re.M):\n        module.exit_json(changed = False, result = \"Success\")\n    elif result != 0:\n        module.fail_json(msg=\"Failed to enable module %s: %s\" % (name, stdout))\n    else:\n        module.exit_json(changed = True, result = \"Enabled\")\n\ndef main():\n    module = AnsibleModule(\n        argument_spec = dict(\n            name  = dict(required=True),\n            state = dict(default='present', choices=['absent', 'present'])\n        ),\n    )\n\n    if module.params['state'] == 'present':\n        _enable_module(module)\n\n    if module.params['state'] == 'absent':\n        _disable_module(module)\n\n# import module snippets\nfrom ansible.module_utils.basic import *\nif __name__ == '__main__':\n    main()\n", "path": "web_infrastructure/apache2_module.py"}], "after_files": [{"content": "#!/usr/bin/python\n#coding: utf-8 -*-\n\n# (c) 2013-2014, Christian Berendt <berendt@b1-systems.de>\n#\n# This module is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this software.  If not, see <http://www.gnu.org/licenses/>.\n\nDOCUMENTATION = '''\n---\nmodule: apache2_module\nversion_added: 1.6\nauthor: \"Christian Berendt (@berendt)\"\nshort_description: enables/disables a module of the Apache2 webserver\ndescription:\n   - Enables or disables a specified module of the Apache2 webserver.\noptions:\n   name:\n     description:\n        - name of the module to enable/disable\n     required: true\n   force:\n     description:\n        - force disabling of default modules and override Debian warnings\n     required: false\n     choices: ['yes', 'no']\n     default: no\n   state:\n     description:\n        - indicate the desired state of the resource\n     choices: ['present', 'absent']\n     default: present\n\nrequirements: [\"a2enmod\",\"a2dismod\"]\n'''\n\nEXAMPLES = '''\n# enables the Apache2 module \"wsgi\"\n- apache2_module: state=present name=wsgi\n\n# disables the Apache2 module \"wsgi\"\n- apache2_module: state=absent name=wsgi\n'''\n\nimport re\n\ndef _disable_module(module):\n    name = module.params['name']\n    force = module.params['force']\n    a2dismod_binary = module.get_bin_path(\"a2dismod\")\n    if a2dismod_binary is None:\n        module.fail_json(msg=\"a2dismod not found.  Perhaps this system does not use a2dismod to manage apache\")\n\n    if force:\n        a2dismod_binary += ' -f'\n\n    result, stdout, stderr = module.run_command(\"%s %s\" % (a2dismod_binary, name))\n\n    if re.match(r'.*\\b' + name + r' already disabled', stdout, re.S|re.M):\n        module.exit_json(changed = False, result = \"Success\")\n    elif result != 0:\n        module.fail_json(msg=\"Failed to disable module %s: %s\" % (name, stdout))\n    else:\n        module.exit_json(changed = True, result = \"Disabled\")\n\ndef _enable_module(module):\n    name = module.params['name']\n    a2enmod_binary = module.get_bin_path(\"a2enmod\")\n    if a2enmod_binary is None:\n        module.fail_json(msg=\"a2enmod not found.  Perhaps this system does not use a2enmod to manage apache\")\n\n    result, stdout, stderr = module.run_command(\"%s %s\" % (a2enmod_binary, name))\n\n    if re.match(r'.*\\b' + name + r' already enabled', stdout, re.S|re.M):\n        module.exit_json(changed = False, result = \"Success\")\n    elif result != 0:\n        module.fail_json(msg=\"Failed to enable module %s: %s\" % (name, stdout))\n    else:\n        module.exit_json(changed = True, result = \"Enabled\")\n\ndef main():\n    module = AnsibleModule(\n        argument_spec = dict(\n            name  = dict(required=True),\n            force = dict(required=False, type='bool', default=False),\n            state = dict(default='present', choices=['absent', 'present'])\n        ),\n    )\n\n    if module.params['state'] == 'present':\n        _enable_module(module)\n\n    if module.params['state'] == 'absent':\n        _disable_module(module)\n\n# import module snippets\nfrom ansible.module_utils.basic import *\nif __name__ == '__main__':\n    main()\n", "path": "web_infrastructure/apache2_module.py"}]}