From a1f2ec222d5b6904c2c73ad10bad1d5cbdae58ca Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sun, 2 Jun 2019 19:38:42 +0100 Subject: [PATCH] issue #590: fix test for <2.8 Ansibles. --- .../ansible/lib/modules/custom_python_uses_distro.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/ansible/lib/modules/custom_python_uses_distro.py b/tests/ansible/lib/modules/custom_python_uses_distro.py index c5ffbb84..1fc31b4e 100644 --- a/tests/ansible/lib/modules/custom_python_uses_distro.py +++ b/tests/ansible/lib/modules/custom_python_uses_distro.py @@ -2,12 +2,20 @@ # issue #590: I am an Ansible new-style Python module that tries to use # ansible.module_utils.distro. +import ansible from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils import distro + +if ansible.__version__ > '2.8': + from ansible.module_utils import distro +else: + distro = None def main(): module = AnsibleModule(argument_spec={}) - module.exit_json(info=distro.info()) + if ansible.__version__ > '2.8': + module.exit_json(info=distro.info()) + else: + module.exit_json(info={'id': None}) if __name__ == '__main__': main()