Expose ansible ssh_user variable to the run action

Change-Id: I6ae1f55ea261064b418e25cd4cf255f386a20fb3
This commit is contained in:
matbu 2021-04-06 15:57:57 +02:00
parent 18862912b3
commit d83be8b169
3 changed files with 13 additions and 6 deletions

View File

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

View File

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

View File

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