From 87e4917f1b7ee0c6b5ea766c1c732f4f52f735ef Mon Sep 17 00:00:00 2001 From: Mathieu Bultel Date: Thu, 17 Dec 2020 09:44:27 +0100 Subject: [PATCH] Move ansible-runner version to 1.4.0 Upstream requirements in stable/train is under ansible-runner 1.4.0. This patch move the version to 1.4.0 according to openstack/requirements. It changes the backward compat version according to this version in validations_libs/ansible.py Change-Id: I311d077c13a7d95314eb83072f5652646fef1bf8 --- requirements.txt | 2 +- validations_libs/ansible.py | 2 +- validations_libs/tests/test_ansible.py | 27 +++++++++++++++++++------- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/requirements.txt b/requirements.txt index 872807a3..5e51a97b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,4 @@ pbr>=3.1.1 # Apache-2.0 six>=1.11.0 # MIT PyYAML>=3.13 # MIT ansible>=2.8,!=2.8.9,!=2.9.12,<2.10.0 -ansible-runner>=1.3.4 # Apache-2.0 +ansible-runner>=1.4.0 # Apache-2.0 diff --git a/validations_libs/ansible.py b/validations_libs/ansible.py index 34fb6b17..b43ce919 100644 --- a/validations_libs/ansible.py +++ b/validations_libs/ansible.py @@ -39,7 +39,7 @@ except NameError: try: version = pkg_resources.get_distribution("ansible_runner").version - backward_compat = (version < '1.4.4') + backward_compat = (version < '1.4.0') except pkg_resources.DistributionNotFound: backward_compat = False diff --git a/validations_libs/tests/test_ansible.py b/validations_libs/tests/test_ansible.py index b9442188..a84d0086 100644 --- a/validations_libs/tests/test_ansible.py +++ b/validations_libs/tests/test_ansible.py @@ -13,6 +13,7 @@ # under the License. # +import pkg_resources try: from unittest import mock except ImportError: @@ -23,6 +24,12 @@ from ansible_runner import Runner from validations_libs.ansible import Ansible from validations_libs.tests import fakes +try: + version = pkg_resources.get_distribution("ansible_runner").version + backward_compat = (version < '1.4.0') +except pkg_resources.DistributionNotFound: + backward_compat = False + class TestAnsible(TestCase): @@ -171,21 +178,27 @@ class TestAnsible(TestCase): workdir='/tmp', log_path='/tmp/foo' ) + opt = { 'artifact_dir': '/tmp', - 'envvars': { - 'ANSIBLE_STDOUT_CALLBACK': 'fake.py', - 'ANSIBLE_CONFIG': '/tmp/foo/artifacts/ansible.cfg', - 'VALIDATIONS_LOG_DIR': '/tmp/foo'}, 'extravars': {}, - 'fact_cache': '/tmp/foo/artifacts/', - 'fact_cache_type': 'jsonfile', 'ident': '', 'inventory': 'localhost,', 'playbook': 'existing.yaml', 'private_data_dir': '/tmp', - 'project_dir': '/tmp', 'quiet': False, 'rotate_artifacts': 256, 'verbosity': 0} + + if not backward_compat: + opt.update({ + 'envvars': { + 'ANSIBLE_STDOUT_CALLBACK': 'fake.py', + 'ANSIBLE_CONFIG': '/tmp/foo/artifacts/ansible.cfg', + 'VALIDATIONS_LOG_DIR': '/tmp/foo'}, + 'project_dir': '/tmp', + 'fact_cache': '/tmp/foo/artifacts/', + 'fact_cache_type': 'jsonfile' + }) + mock_config.assert_called_with(**opt)