diff --git a/tripleoclient/utils.py b/tripleoclient/utils.py index 99425d9b8..e269b5273 100644 --- a/tripleoclient/utils.py +++ b/tripleoclient/utils.py @@ -56,7 +56,8 @@ def run_ansible_playbook(logger, ansible_config=None, retries=True, connection='smart', - output_callback='json'): + output_callback='json', + python_interpreter=None): """Simple wrapper for ansible-playbook :param logger: logger instance @@ -83,6 +84,10 @@ def run_ansible_playbook(logger, :param output_callback: Callback for output format. Defaults to "json" :type output_callback: String + + :param python_interpreter: Absolute path for the Python interpreter + on the host where Ansible is run. + :type python_interpreter: String """ env = os.environ.copy() cleanup = False @@ -105,6 +110,9 @@ 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): diff --git a/tripleoclient/v1/undercloud_preflight.py b/tripleoclient/v1/undercloud_preflight.py index 2bf5bd332..f6a6f12b7 100644 --- a/tripleoclient/v1/undercloud_preflight.py +++ b/tripleoclient/v1/undercloud_preflight.py @@ -112,13 +112,15 @@ def _check_diskspace(upgrade=False): else: playbook = 'undercloud-disk-space.yaml' + python_interpreter = "/usr/bin/python{}".format(sys.version_info[0]) utils.run_ansible_playbook(logger=LOG, workdir=constants.ANSIBLE_VALIDATION_DIR, playbook=playbook, inventory='undercloud,', retries=False, connection='local', - output_callback='validation_output') + output_callback='validation_output', + python_interpreter=python_interpreter) def _check_hostname():