Commit 89b0faae authored by David Wilson's avatar David Wilson

Workaround for global state in yum_repository module; closes #154.

parent 305e0248
...@@ -96,6 +96,15 @@ def monkey_fail_json(self, **kwargs): ...@@ -96,6 +96,15 @@ def monkey_fail_json(self, **kwargs):
raise ModuleError(kwargs.get('msg'), kwargs) raise ModuleError(kwargs.get('msg'), kwargs)
def module_fixups(mod):
"""
Apply fixups for known problems with mainline Ansible modules.
"""
if mod.__name__ == 'ansible.modules.packaging.os.yum_repository':
# https://github.com/dw/mitogen/issues/154
mod.YumRepo.repofile = mod.configparser.RawConfigParser()
def run_module(module, raw_params=None, args=None, env=None): def run_module(module, raw_params=None, args=None, env=None):
""" """
Set up the process environment in preparation for running an Ansible Set up the process environment in preparation for running an Ansible
...@@ -120,6 +129,7 @@ def run_module(module, raw_params=None, args=None, env=None): ...@@ -120,6 +129,7 @@ def run_module(module, raw_params=None, args=None, env=None):
try: try:
mod = __import__(module, {}, {}, ['']) mod = __import__(module, {}, {}, [''])
module_fixups(mod)
# Ansible modules begin execution on import. Thus the above __import__ # Ansible modules begin execution on import. Thus the above __import__
# will cause either Exit or ModuleError to be raised. If we reach the # will cause either Exit or ModuleError to be raised. If we reach the
# line below, the module did not execute and must already have been # line below, the module did not execute and must already have been
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment