summaryrefslogtreecommitdiffstats
path: root/awx_collection/plugins/modules
diff options
context:
space:
mode:
authorSean Sullivan <ssulliva@redhat.com>2023-06-14 19:53:24 +0200
committerGitHub <noreply@github.com>2023-06-14 19:53:24 +0200
commita47bbb54791ad48ede6ca469612ab8f8ad408bdd (patch)
treedbe6ce4da7792e90d6345222016735593941abef /awx_collection/plugins/modules
parentFix ARM builds (#14125) (diff)
downloadawx-a47bbb54791ad48ede6ca469612ab8f8ad408bdd.tar.xz
awx-a47bbb54791ad48ede6ca469612ab8f8ad408bdd.zip
bugfix collection role module target_teams and instance_groups options (#14119)
Diffstat (limited to 'awx_collection/plugins/modules')
-rw-r--r--awx_collection/plugins/modules/role.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/awx_collection/plugins/modules/role.py b/awx_collection/plugins/modules/role.py
index d98337cac4..a8b01530d2 100644
--- a/awx_collection/plugins/modules/role.py
+++ b/awx_collection/plugins/modules/role.py
@@ -245,12 +245,11 @@ def main():
resources.setdefault(resource_group, []).append(module.params.get(old_name))
if module.params.get('lookup_organization') is not None:
resources['lookup_organization'] = module.params.get('lookup_organization')
-
- # Change workflows and target_teams key to its endpoint name.
+ if module.params.get('instance_groups') is not None:
+ resources['instance_groups'] = module.params.get('instance_groups')
+ # Change workflows to its endpoint name.
if 'workflows' in resources:
resources['workflow_job_templates'] = resources.pop('workflows')
- if 'target_teams' in resources:
- resources['teams'] = resources.pop('target_teams')
# Set lookup data to use
lookup_data = {}
@@ -267,17 +266,21 @@ def main():
for key, value in resources.items():
for resource in value:
# Attempt to look up project based on the provided name or ID and lookup data
- if key in resources:
- if key == 'organizations' or key == 'users':
- lookup_data_populated = {}
- else:
- lookup_data_populated = lookup_data
- data = module.get_one(key, name_or_id=resource, data=lookup_data_populated)
+ lookup_key = key
+ if key == 'organizations' or key == 'users':
+ lookup_data_populated = {}
+ else:
+ lookup_data_populated = lookup_data
+ if key == 'target_teams':
+ lookup_key = 'teams'
+ data = module.get_one(lookup_key, name_or_id=resource, data=lookup_data_populated)
if data is None:
missing_items.append(resource)
else:
if key == 'users' or key == 'teams':
actor_data.setdefault(key, []).append(data)
+ elif key == 'target_teams':
+ resource_data.setdefault('teams', []).append(data)
else:
resource_data.setdefault(key, []).append(data)
if len(missing_items) > 0: