utils: pass python interpreter to run_ansible_playbook
It's required to run TripleO Validation playbooks with Python3 on the Undercloud. blueprint python-3 Change-Id: I0600218163269409ae35ca34ffdfedb57926424e
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user