Browse Source

Add a way to override the default validation log path

Export a log path passed by the user in order to override the default
value from the callback

Change-Id: I736c527254cf17d25eeda0a4007102838280609c
changes/75/742875/1
Mathieu Bultel 1 year ago
parent
commit
15e74046c1
  1. 6
      validations_libs/ansible.py
  2. 4
      validations_libs/validation_actions.py

6
validations_libs/ansible.py

@ -279,7 +279,8 @@ class Ansible(object):
gathering_policy='smart',
extra_env_variables=None, parallel_run=False,
callback_whitelist=None, ansible_cfg=None,
ansible_timeout=30, ansible_artifact_path=None, run_async=False):
ansible_timeout=30, ansible_artifact_path=None,
log_path=None, run_async=False):
if not playbook_dir:
playbook_dir = workdir
@ -318,6 +319,9 @@ class Ansible(object):
elif 'ANSIBLE_CONFIG' not in env and ansible_cfg:
env['ANSIBLE_CONFIG'] = ansible_cfg
if log_path:
env['VALIDATIONS_LOG_DIR'] = log_path
envvars = self._encode_envvars(env=env)
r_opts = {
'private_data_dir': workdir,

4
validations_libs/validation_actions.py

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

Loading…
Cancel
Save