Browse Source

Merge "Expose ansible ssh_user variable to the run action"

changes/74/782574/23
Zuul 1 month ago
committed by Gerrit Code Review
parent
commit
bb23468ee5
3 changed files with 13 additions and 6 deletions
  1. +3
    -2
      validations_libs/ansible.py
  2. +4
    -2
      validations_libs/tests/test_validation_actions.py
  3. +6
    -2
      validations_libs/validation_actions.py

+ 3
- 2
validations_libs/ansible.py View File

@ -150,7 +150,8 @@ class Ansible(object):
env['ANSIBLE_GATHER_TIMEOUT'] = 45
env['ANSIBLE_SSH_RETRIES'] = 3
env['ANSIBLE_PIPELINING'] = True
env['ANSIBLE_REMOTE_USER'] = ssh_user
if ssh_user:
env['ANSIBLE_REMOTE_USER'] = ssh_user
env['ANSIBLE_STDOUT_CALLBACK'] = output_callback
env['ANSIBLE_LIBRARY'] = os.path.expanduser(
'~/.ansible/plugins/modules:'
@ -277,7 +278,7 @@ class Ansible(object):
def run(self, playbook, inventory, workdir, playbook_dir=None,
connection='smart', output_callback=None,
base_dir=constants.DEFAULT_VALIDATIONS_BASEDIR,
ssh_user='root', key=None, module_path=None,
ssh_user=None, key=None, module_path=None,
limit_hosts=None, tags=None, skip_tags=None,
verbosity=0, quiet=False, extra_vars=None,
gathering_policy='smart',


+ 4
- 2
validations_libs/tests/test_validation_actions.py View File

@ -92,7 +92,8 @@ class TestValidationActions(TestCase):
'gathering_policy': 'explicit',
'log_path': None,
'run_async': False,
'python_interpreter': None
'python_interpreter': None,
'ssh_user': None
}
playbook = ['fake.yaml']
@ -137,7 +138,8 @@ class TestValidationActions(TestCase):
'ansible_artifact_path': '/tmp/',
'log_path': None,
'run_async': False,
'python_interpreter': None
'python_interpreter': None,
'ssh_user': None
}
playbook = ['fake.yaml']


+ 6
- 2
validations_libs/validation_actions.py View File

@ -212,7 +212,8 @@ class ValidationActions(object):
log_path=None, python_interpreter=None,
skip_list=None,
callback_whitelist=None,
output_callback='validation_stdout'):
output_callback='validation_stdout',
ssh_user=None):
"""Run one or multiple validations by name(s) or by group(s)
:param validation_name: A list of validation names
@ -272,6 +273,8 @@ class ValidationActions(object):
validations executions (Validations, Duration, Host_Group,
Status, Status_by_Host, UUID and Unreachable_Hosts)
:rtype: ``list``
:param ssh_user: Ssh user for Ansible remote connection
:type ssh_user: ``string``
:Example:
@ -361,7 +364,8 @@ class ValidationActions(object):
ansible_artifact_path=artifacts_dir,
log_path=log_path,
run_async=run_async,
python_interpreter=python_interpreter)
python_interpreter=python_interpreter,
ssh_user=ssh_user)
results.append({'playbook': _playbook,
'rc_code': _rc,
'status': _status,


Loading…
Cancel
Save