Merge "Allow to set python interper for ansible execution"
This commit is contained in:
commit
6885dba6ab
|
@ -122,7 +122,7 @@ class Ansible(object):
|
||||||
def _ansible_env_var(self, output_callback, ssh_user, workdir, connection,
|
def _ansible_env_var(self, output_callback, ssh_user, workdir, connection,
|
||||||
gathering_policy, module_path, key,
|
gathering_policy, module_path, key,
|
||||||
extra_env_variables, ansible_timeout,
|
extra_env_variables, ansible_timeout,
|
||||||
callback_whitelist, base_dir):
|
callback_whitelist, base_dir, python_interpreter):
|
||||||
"""Handle Ansible env var for Ansible config execution"""
|
"""Handle Ansible env var for Ansible config execution"""
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
|
@ -226,7 +226,9 @@ class Ansible(object):
|
||||||
if self.uuid:
|
if self.uuid:
|
||||||
env['ANSIBLE_UUID'] = 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
|
env['ANSIBLE_PYTHON_INTERPRETER'] = sys.executable
|
||||||
|
|
||||||
if gathering_policy in ('smart', 'explicit', 'implicit'):
|
if gathering_policy in ('smart', 'explicit', 'implicit'):
|
||||||
|
@ -280,7 +282,7 @@ class Ansible(object):
|
||||||
extra_env_variables=None, parallel_run=False,
|
extra_env_variables=None, parallel_run=False,
|
||||||
callback_whitelist=None, ansible_cfg=None,
|
callback_whitelist=None, ansible_cfg=None,
|
||||||
ansible_timeout=30, ansible_artifact_path=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:
|
if not playbook_dir:
|
||||||
playbook_dir = workdir
|
playbook_dir = workdir
|
||||||
|
@ -305,7 +307,8 @@ class Ansible(object):
|
||||||
env = self._ansible_env_var(output_callback, ssh_user, workdir,
|
env = self._ansible_env_var(output_callback, ssh_user, workdir,
|
||||||
connection, gathering_policy, module_path,
|
connection, gathering_policy, module_path,
|
||||||
key, extra_env_variables, ansible_timeout,
|
key, extra_env_variables, ansible_timeout,
|
||||||
callback_whitelist, base_dir)
|
callback_whitelist, base_dir,
|
||||||
|
python_interpreter)
|
||||||
if not ansible_artifact_path:
|
if not ansible_artifact_path:
|
||||||
ansible_artifact_path = constants.VALIDATION_ANSIBLE_ARTIFACT_PATH
|
ansible_artifact_path = constants.VALIDATION_ANSIBLE_ARTIFACT_PATH
|
||||||
if 'ANSIBLE_CONFIG' not in env and not ansible_cfg:
|
if 'ANSIBLE_CONFIG' not in env and not ansible_cfg:
|
||||||
|
|
|
@ -68,7 +68,7 @@ class ValidationActions(object):
|
||||||
extra_env_vars=None, ansible_cfg=None, quiet=True,
|
extra_env_vars=None, ansible_cfg=None, quiet=True,
|
||||||
workdir=None, limit_hosts=None, run_async=False,
|
workdir=None, limit_hosts=None, run_async=False,
|
||||||
base_dir=constants.DEFAULT_VALIDATIONS_BASEDIR,
|
base_dir=constants.DEFAULT_VALIDATIONS_BASEDIR,
|
||||||
log_path=None):
|
log_path=None, python_interpreter=None):
|
||||||
self.log = logging.getLogger(__name__ + ".run_validations")
|
self.log = logging.getLogger(__name__ + ".run_validations")
|
||||||
playbooks = []
|
playbooks = []
|
||||||
validations_dir = (validations_dir if validations_dir
|
validations_dir = (validations_dir if validations_dir
|
||||||
|
@ -115,7 +115,8 @@ class ValidationActions(object):
|
||||||
gathering_policy='explicit',
|
gathering_policy='explicit',
|
||||||
ansible_artifact_path=artifacts_dir,
|
ansible_artifact_path=artifacts_dir,
|
||||||
log_path=log_path,
|
log_path=log_path,
|
||||||
run_async=run_async)
|
run_async=run_async,
|
||||||
|
python_interpreter=python_interpreter)
|
||||||
results.append({'playbook': _playbook,
|
results.append({'playbook': _playbook,
|
||||||
'rc_code': _rc,
|
'rc_code': _rc,
|
||||||
'status': _status,
|
'status': _status,
|
||||||
|
|
Loading…
Reference in New Issue