We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
apache2_module fails for php7.0 on Ubuntu Xenial
##### ISSUE TYPE
- Bug Report
##### COMPONENT NAME

apache2_module
##### ANSIBLE VERSION

<!--- Paste verbatim output from “ansible --version” between quotes below -->

```
ansible 2.2.0 (devel 982db58aff) last updated 2016/09/08 11:50:49 (GMT +100)
  lib/ansible/modules/core: (detached HEAD db38f0c876) last updated 2016/09/08 13:03:40 (GMT +100)
  lib/ansible/modules/extras: (detached HEAD 8bfdcfcab2) last updated 2016/09/08 11:51:00 (GMT +100)
  config file = /home/rowan/.ansible.cfg
  configured module search path = Default w/o overrides
```
##### CONFIGURATION

N/A
##### OS / ENVIRONMENT

N/A
##### SUMMARY

Ubuntu Xenial lists the php7.0 module as php7_module when running apache2ctl -M this breaks the regexp checking if the module is enabled.

I've made a work around here https://github.com/rwky/ansible-modules-core/commit/00ad6ef035a10dac7c84b7b68f04b00a739b104b but I didn't make a PR since I expect it may break other distros/versions.

Not entirely sure what the best solution to this is.
##### STEPS TO REPRODUCE

Run apache2_module with name=php7.0 state=present on a xenial server.


--- 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    force:
33      description:
34         - force disabling of default modules and override Debian warnings
35      required: false
36      choices: ['yes', 'no']
37      default: no
38      version_added: "2.1"
39    state:
40      description:
41         - indicate the desired state of the resource
42      choices: ['present', 'absent']
43      default: present
44 
45 requirements: ["a2enmod","a2dismod"]
46 '''
47 
48 EXAMPLES = '''
49 # enables the Apache2 module "wsgi"
50 - apache2_module: state=present name=wsgi
51 
52 # disables the Apache2 module "wsgi"
53 - apache2_module: state=absent name=wsgi
54 '''
55 
56 import re
57 
58 def _run_threaded(module):
59     control_binary = _get_ctl_binary(module)
60 
61     result, stdout, stderr = module.run_command("%s -V" % control_binary)
62 
63     if re.search(r'threaded:[ ]*yes', stdout):
64         return True
65     else:
66         return False
67 
68 def _get_ctl_binary(module):
69     for command in ['apache2ctl', 'apachectl']:
70         ctl_binary = module.get_bin_path(command)
71         if ctl_binary is not None:
72             return ctl_binary
73 
74     module.fail_json(
75       msg="None of httpd, apachectl or apach2ctl found. At least one apache control binary is necessary.")
76 
77 def _module_is_enabled(module):
78     control_binary = _get_ctl_binary(module)
79     name = module.params['name']
80 
81     result, stdout, stderr = module.run_command("%s -M" % control_binary)
82 
83     if result != 0:
84         module.fail_json(msg="Error executing %s: %s" % (control_binary, stderr))
85 
86     if re.search(r' ' + name + r'_module', stdout):
87         return True
88     else:
89         return False
90 
91 def _set_state(module, state):
92     name = module.params['name']
93     force = module.params['force']
94 
95     want_enabled = state == 'present'
96     state_string = {'present': 'enabled', 'absent': 'disabled'}[state]
97     a2mod_binary = {'present': 'a2enmod', 'absent': 'a2dismod'}[state]
98     success_msg = "Module %s %s" % (name, state_string)
99 
100     if _module_is_enabled(module) != want_enabled:
101         if module.check_mode:
102             module.exit_json(changed = True, result = success_msg)
103 
104         a2mod_binary = module.get_bin_path(a2mod_binary)
105         if a2mod_binary is None:
106             module.fail_json(msg="%s not found. Perhaps this system does not use %s to manage apache" % (a2mod_binary, a2mod_binary))
107 
108         if not want_enabled and force:
109             # force exists only for a2dismod on debian
110             a2mod_binary += ' -f'
111 
112         result, stdout, stderr = module.run_command("%s %s" % (a2mod_binary, name))
113 
114         if _module_is_enabled(module) == want_enabled:
115             module.exit_json(changed = True, result = success_msg)
116         else:
117             module.fail_json(msg="Failed to set module %s to %s: %s" % (name, state_string, stdout), rc=result, stdout=stdout, stderr=stderr)
118     else:
119         module.exit_json(changed = False, result = success_msg)
120 
121 def main():
122     module = AnsibleModule(
123         argument_spec = dict(
124             name  = dict(required=True),
125             force = dict(required=False, type='bool', default=False),
126             state = dict(default='present', choices=['absent', 'present'])
127         ),
128         supports_check_mode = True,
129     )
130 
131     name = module.params['name']
132     if name == 'cgi' and _run_threaded(module):
133         module.fail_json(msg="Your MPM seems to be threaded. No automatic actions on module %s possible." % name)
134 
135     if module.params['state'] in ['present', 'absent']:
136         _set_state(module, module.params['state'])
137 
138 # import module snippets
139 from ansible.module_utils.basic import *
140 if __name__ == '__main__':
141     main()
142
```
--- 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
@@ -80,6 +80,12 @@
 
     result, stdout, stderr = module.run_command("%s -M" % control_binary)
 
+    """
+    Work around for Ubuntu Xenial listing php7_module as php7.0
+    """
+    if name == "php7.0":
+        name = "php7"
+
     if result != 0:
         module.fail_json(msg="Error executing %s: %s" % (control_binary, stderr))

{"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@@ -80,6 +80,12 @@\n \n     result, stdout, stderr = module.run_command(\"%s -M\" % control_binary)\n \n+    \"\"\"\n+    Work around for Ubuntu Xenial listing php7_module as php7.0\n+    \"\"\"\n+    if name == \"php7.0\":\n+        name = \"php7\"\n+\n     if result != 0:\n         module.fail_json(msg=\"Error executing %s: %s\" % (control_binary, stderr))\n", "issue": "apache2_module fails for php7.0 on Ubuntu Xenial\n##### ISSUE TYPE\n- Bug Report\n##### COMPONENT NAME\n\napache2_module\n##### ANSIBLE VERSION\n\n<!--- Paste verbatim output from \u201cansible --version\u201d between quotes below -->\n\n```\nansible 2.2.0 (devel 982db58aff) last updated 2016/09/08 11:50:49 (GMT +100)\n  lib/ansible/modules/core: (detached HEAD db38f0c876) last updated 2016/09/08 13:03:40 (GMT +100)\n  lib/ansible/modules/extras: (detached HEAD 8bfdcfcab2) last updated 2016/09/08 11:51:00 (GMT +100)\n  config file = /home/rowan/.ansible.cfg\n  configured module search path = Default w/o overrides\n```\n##### CONFIGURATION\n\nN/A\n##### OS / ENVIRONMENT\n\nN/A\n##### SUMMARY\n\nUbuntu Xenial lists the php7.0 module as php7_module when running apache2ctl -M this breaks the regexp checking if the module is enabled.\n\nI've made a work around here https://github.com/rwky/ansible-modules-core/commit/00ad6ef035a10dac7c84b7b68f04b00a739b104b but I didn't make a PR since I expect it may break other distros/versions.\n\nNot entirely sure what the best solution to this is.\n##### STEPS TO REPRODUCE\n\nRun apache2_module with name=php7.0 state=present on a xenial server.\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   force:\n     description:\n        - force disabling of default modules and override Debian warnings\n     required: false\n     choices: ['yes', 'no']\n     default: no\n     version_added: \"2.1\"\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 _run_threaded(module):\n    control_binary = _get_ctl_binary(module)\n\n    result, stdout, stderr = module.run_command(\"%s -V\" % control_binary)\n\n    if re.search(r'threaded:[ ]*yes', stdout):\n        return True\n    else:\n        return False\n\ndef _get_ctl_binary(module):\n    for command in ['apache2ctl', 'apachectl']:\n        ctl_binary = module.get_bin_path(command)\n        if ctl_binary is not None:\n            return ctl_binary\n\n    module.fail_json(\n      msg=\"None of httpd, apachectl or apach2ctl found. At least one apache control binary is necessary.\")\n\ndef _module_is_enabled(module):\n    control_binary = _get_ctl_binary(module)\n    name = module.params['name']\n\n    result, stdout, stderr = module.run_command(\"%s -M\" % control_binary)\n\n    if result != 0:\n        module.fail_json(msg=\"Error executing %s: %s\" % (control_binary, stderr))\n\n    if re.search(r' ' + name + r'_module', stdout):\n        return True\n    else:\n        return False\n\ndef _set_state(module, state):\n    name = module.params['name']\n    force = module.params['force']\n\n    want_enabled = state == 'present'\n    state_string = {'present': 'enabled', 'absent': 'disabled'}[state]\n    a2mod_binary = {'present': 'a2enmod', 'absent': 'a2dismod'}[state]\n    success_msg = \"Module %s %s\" % (name, state_string)\n\n    if _module_is_enabled(module) != want_enabled:\n        if module.check_mode:\n            module.exit_json(changed = True, result = success_msg)\n\n        a2mod_binary = module.get_bin_path(a2mod_binary)\n        if a2mod_binary is None:\n            module.fail_json(msg=\"%s not found. Perhaps this system does not use %s to manage apache\" % (a2mod_binary, a2mod_binary))\n\n        if not want_enabled and force:\n            # force exists only for a2dismod on debian\n            a2mod_binary += ' -f'\n\n        result, stdout, stderr = module.run_command(\"%s %s\" % (a2mod_binary, name))\n\n        if _module_is_enabled(module) == want_enabled:\n            module.exit_json(changed = True, result = success_msg)\n        else:\n            module.fail_json(msg=\"Failed to set module %s to %s: %s\" % (name, state_string, stdout), rc=result, stdout=stdout, stderr=stderr)\n    else:\n        module.exit_json(changed = False, result = success_msg)\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        supports_check_mode = True,\n    )\n\n    name = module.params['name']\n    if name == 'cgi' and _run_threaded(module):\n        module.fail_json(msg=\"Your MPM seems to be threaded. No automatic actions on module %s possible.\" % name)\n\n    if module.params['state'] in ['present', 'absent']:\n        _set_state(module, module.params['state'])\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     version_added: \"2.1\"\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 _run_threaded(module):\n    control_binary = _get_ctl_binary(module)\n\n    result, stdout, stderr = module.run_command(\"%s -V\" % control_binary)\n\n    if re.search(r'threaded:[ ]*yes', stdout):\n        return True\n    else:\n        return False\n\ndef _get_ctl_binary(module):\n    for command in ['apache2ctl', 'apachectl']:\n        ctl_binary = module.get_bin_path(command)\n        if ctl_binary is not None:\n            return ctl_binary\n\n    module.fail_json(\n      msg=\"None of httpd, apachectl or apach2ctl found. At least one apache control binary is necessary.\")\n\ndef _module_is_enabled(module):\n    control_binary = _get_ctl_binary(module)\n    name = module.params['name']\n\n    result, stdout, stderr = module.run_command(\"%s -M\" % control_binary)\n\n    \"\"\"\n    Work around for Ubuntu Xenial listing php7_module as php7.0\n    \"\"\"\n    if name == \"php7.0\":\n        name = \"php7\"\n\n    if result != 0:\n        module.fail_json(msg=\"Error executing %s: %s\" % (control_binary, stderr))\n\n    if re.search(r' ' + name + r'_module', stdout):\n        return True\n    else:\n        return False\n\ndef _set_state(module, state):\n    name = module.params['name']\n    force = module.params['force']\n\n    want_enabled = state == 'present'\n    state_string = {'present': 'enabled', 'absent': 'disabled'}[state]\n    a2mod_binary = {'present': 'a2enmod', 'absent': 'a2dismod'}[state]\n    success_msg = \"Module %s %s\" % (name, state_string)\n\n    if _module_is_enabled(module) != want_enabled:\n        if module.check_mode:\n            module.exit_json(changed = True, result = success_msg)\n\n        a2mod_binary = module.get_bin_path(a2mod_binary)\n        if a2mod_binary is None:\n            module.fail_json(msg=\"%s not found. Perhaps this system does not use %s to manage apache\" % (a2mod_binary, a2mod_binary))\n\n        if not want_enabled and force:\n            # force exists only for a2dismod on debian\n            a2mod_binary += ' -f'\n\n        result, stdout, stderr = module.run_command(\"%s %s\" % (a2mod_binary, name))\n\n        if _module_is_enabled(module) == want_enabled:\n            module.exit_json(changed = True, result = success_msg)\n        else:\n            module.fail_json(msg=\"Failed to set module %s to %s: %s\" % (name, state_string, stdout), rc=result, stdout=stdout, stderr=stderr)\n    else:\n        module.exit_json(changed = False, result = success_msg)\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        supports_check_mode = True,\n    )\n\n    name = module.params['name']\n    if name == 'cgi' and _run_threaded(module):\n        module.fail_json(msg=\"Your MPM seems to be threaded. No automatic actions on module %s possible.\" % name)\n\n    if module.params['state'] in ['present', 'absent']:\n        _set_state(module, module.params['state'])\n\n# import module snippets\nfrom ansible.module_utils.basic import *\nif __name__ == '__main__':\n    main()\n", "path": "web_infrastructure/apache2_module.py"}]}