Browse Source

Expose ansible ssh_user variable to the run action

Change-Id: I6ae1f55ea261064b418e25cd4cf255f386a20fb3
changes/60/784960/4
matbu 10 months ago
parent
commit
d83be8b169
  1. 5
      validations_libs/ansible.py
  2. 6
      validations_libs/tests/test_validation_actions.py
  3. 8
      validations_libs/validation_actions.py

5
validations_libs/ansible.py

@ -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',

6
validations_libs/tests/test_validation_actions.py

@ -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']

8
validations_libs/validation_actions.py

@ -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