From c163a426689db8c86373c933994d34997e309104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Jeanneret?= Date: Thu, 17 Jan 2019 12:19:46 +0100 Subject: [PATCH] Pass the python interpreter to the play command directly Ansible doesn't take into account any 'ANSIBLE_PYTHON_INTERPRETER' env var, as per this comment[1] back in 2016. We hence have to pass it as an extra variable directly in the command. This patch corrects I0600218163269409ae35ca34ffdfedb57926424e in order to ensure we do pass the python interpreter value correctly. [1] https://github.com/ansible/ansible/issues/6345#issuecomment-181981760 Change-Id: I48c8c532b23b9422406168cecdc9aebfe8f45651 Blueprint: python-3 --- tripleoclient/utils.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tripleoclient/utils.py b/tripleoclient/utils.py index e269b5273..7478dcdf4 100644 --- a/tripleoclient/utils.py +++ b/tripleoclient/utils.py @@ -110,16 +110,18 @@ def run_ansible_playbook(logger, elif os.path.exists(os.path.join(workdir, ansible_config)): env['ANSIBLE_CONFIG'] = os.path.join(workdir, ansible_config) - if python_interpreter is not None: - env['ANSIBLE_PYTHON_INTERPRETER'] = python_interpreter - play = os.path.join(workdir, playbook) if os.path.exists(play): cmd = ["ansible-playbook-{}".format(sys.version_info[0]), '-i', inventory, - '-c', connection, play ] + if python_interpreter is not None: + cmd.extend(['-e', 'ansible_python_interpreter=%s' % + python_interpreter]) + + cmd.extend(['-c', connection, play]) + proc = run_command_and_log(logger, cmd, env=env, retcode_only=False) proc.wait() cleanup and os.unlink(tmp_config)