diff --git a/awx_collection/plugins/modules/tower_job_template.py b/awx_collection/plugins/modules/tower_job_template.py index 1f12d5aadd..d1638d7981 100644 --- a/awx_collection/plugins/modules/tower_job_template.py +++ b/awx_collection/plugins/modules/tower_job_template.py @@ -479,8 +479,13 @@ def main(): labels = module.params.get('labels') if labels is not None: association_fields['labels'] = [] + for item in labels: - association_fields['labels'].append(module.resolve_name_to_id('labels', item)) + search_fields = {'name': item} + if organization: + search_fields['organization'] = organization_id + label_id = module.get_one('labels', **{'data': search_fields}) + association_fields['labels'].append(label_id) notifications_start = module.params.get('notification_templates_started') if notifications_start is not None: diff --git a/awx_collection/plugins/modules/tower_workflow_job_template.py b/awx_collection/plugins/modules/tower_workflow_job_template.py index f0d452c7d7..5133f07f7a 100644 --- a/awx_collection/plugins/modules/tower_workflow_job_template.py +++ b/awx_collection/plugins/modules/tower_workflow_job_template.py @@ -256,8 +256,13 @@ def main(): labels = module.params.get('labels') if labels is not None: association_fields['labels'] = [] + for item in labels: - association_fields['labels'].append(module.resolve_name_to_id('labels', item)) + search_fields = {'name': item} + if organization: + search_fields['organization'] = organization_id + label_id = module.get_one('labels', **{'data': search_fields}) + association_fields['labels'].append(label_id) on_change = None new_spec = module.params.get('survey')