Browse Source

Merge "Allow to set python interper for ansible execution"

tags/1.0.4
Zuul 3 weeks ago
committed by Gerrit Code Review
parent
commit
6885dba6ab
2 changed files with 10 additions and 6 deletions
  1. +7
    -4
      validations_libs/ansible.py
  2. +3
    -2
      validations_libs/validation_actions.py

+ 7
- 4
validations_libs/ansible.py View File

@@ -122,7 +122,7 @@ class Ansible(object):
def _ansible_env_var(self, output_callback, ssh_user, workdir, connection,
gathering_policy, module_path, key,
extra_env_variables, ansible_timeout,
callback_whitelist, base_dir):
callback_whitelist, base_dir, python_interpreter):
"""Handle Ansible env var for Ansible config execution"""
cwd = os.getcwd()
env = os.environ.copy()
@@ -226,7 +226,9 @@ class Ansible(object):
if self.uuid:
env['ANSIBLE_UUID'] = self.uuid

if connection == 'local':
if python_interpreter:
env['ANSIBLE_PYTHON_INTERPRETER'] = python_interpreter
elif connection == 'local':
env['ANSIBLE_PYTHON_INTERPRETER'] = sys.executable

if gathering_policy in ('smart', 'explicit', 'implicit'):
@@ -280,7 +282,7 @@ class Ansible(object):
extra_env_variables=None, parallel_run=False,
callback_whitelist=None, ansible_cfg=None,
ansible_timeout=30, ansible_artifact_path=None,
log_path=None, run_async=False):
log_path=None, run_async=False, python_interpreter=None):

if not playbook_dir:
playbook_dir = workdir
@@ -305,7 +307,8 @@ class Ansible(object):
env = self._ansible_env_var(output_callback, ssh_user, workdir,
connection, gathering_policy, module_path,
key, extra_env_variables, ansible_timeout,
callback_whitelist, base_dir)
callback_whitelist, base_dir,
python_interpreter)
if not ansible_artifact_path:
ansible_artifact_path = constants.VALIDATION_ANSIBLE_ARTIFACT_PATH
if 'ANSIBLE_CONFIG' not in env and not ansible_cfg:


+ 3
- 2
validations_libs/validation_actions.py View File

@@ -68,7 +68,7 @@ class ValidationActions(object):
extra_env_vars=None, ansible_cfg=None, quiet=True,
workdir=None, limit_hosts=None, run_async=False,
base_dir=constants.DEFAULT_VALIDATIONS_BASEDIR,
log_path=None):
log_path=None, python_interpreter=None):
self.log = logging.getLogger(__name__ + ".run_validations")
playbooks = []
validations_dir = (validations_dir if validations_dir
@@ -115,7 +115,8 @@ class ValidationActions(object):
gathering_policy='explicit',
ansible_artifact_path=artifacts_dir,
log_path=log_path,
run_async=run_async)
run_async=run_async,
python_interpreter=python_interpreter)
results.append({'playbook': _playbook,
'rc_code': _rc,
'status': _status,


Loading…
Cancel
Save