Merge pull request #1542 from matburt/adding_more_extra_vars

Adding more helpful job extra vars
This commit is contained in:
Matthew Jones 2018-03-13 17:53:44 -07:00 committed by GitHub
commit 4a5f458a36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 12 deletions

View File

@ -1364,6 +1364,9 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
for name in ('awx', 'tower'):
r['{}_user_id'.format(name)] = self.created_by.pk
r['{}_user_name'.format(name)] = self.created_by.username
r['{}_user_email'.format(name)] = self.created_by.email
r['{}_user_first_name'.format(name)] = self.created_by.first_name
r['{}_user_last_name'.format(name)] = self.created_by.last_name
else:
wj = self.get_workflow_job()
if wj:

View File

@ -2217,18 +2217,7 @@ class RunAdHocCommand(BaseTask):
if ad_hoc_command.verbosity:
args.append('-%s' % ('v' * min(5, ad_hoc_command.verbosity)))
# Define special extra_vars for AWX, combine with ad_hoc_command.extra_vars
extra_vars = {
'tower_job_id': ad_hoc_command.pk,
'awx_job_id': ad_hoc_command.pk,
}
if ad_hoc_command.created_by:
extra_vars.update({
'tower_user_id': ad_hoc_command.created_by.pk,
'tower_user_name': ad_hoc_command.created_by.username,
'awx_user_id': ad_hoc_command.created_by.pk,
'awx_user_name': ad_hoc_command.created_by.username,
})
extra_vars = ad_hoc_command.awx_meta_vars()
if ad_hoc_command.extra_vars_dict:
redacted_extra_vars, removed_vars = extract_ansible_vars(ad_hoc_command.extra_vars_dict)

View File

@ -93,6 +93,12 @@ class TestMetaVars:
'awx_job_launch_type': 'manual',
'awx_user_name': 'joe',
'tower_user_name': 'joe',
'awx_user_email': '',
'tower_user_email': '',
'awx_user_first_name': '',
'tower_user_first_name': '',
'awx_user_last_name': '',
'tower_user_last_name': '',
'awx_user_id': 47,
'tower_user_id': 47
}