Skip to content

Commit 8fb5862

Browse files
authored
Allow lookup_organization to find teams and resources from different orgs
1 parent 6f7d5ca commit 8fb5862

File tree

2 files changed

+49
-1
lines changed
  • awx_collection

2 files changed

+49
-1
lines changed

awx_collection/plugins/modules/role.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def main():
268268
for resource in value:
269269
# Attempt to look up project based on the provided name, ID, or named URL and lookup data
270270
lookup_key = key
271-
if key == 'organizations' or key == 'users':
271+
if key == 'organizations' or key == 'users' or key == 'teams':
272272
lookup_data_populated = {}
273273
else:
274274
lookup_data_populated = lookup_data

awx_collection/tests/integration/targets/role/tasks/main.yml

+48
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
wfjt_name: "AWX-Collection-tests-role-project-wfjt-{{ test_id }}"
1414
team_name: "AWX-Collection-tests-team-team-{{ test_id }}"
1515
team2_name: "AWX-Collection-tests-team-team-{{ test_id }}2"
16+
org2_name: "AWX-Collection-tests-organization-{{ test_id }}2"
1617

1718
- block:
1819
- name: Create a User
@@ -209,6 +210,40 @@
209210
that:
210211
- "result is changed"
211212

213+
- name: Create a 2nd organization
214+
organization:
215+
name: "{{ org2_name }}"
216+
217+
- name: Create a project in 2nd Organization
218+
project:
219+
name: "{{ project_name }}"
220+
organization: "{{ org2_name }}"
221+
scm_type: git
222+
scm_url: https://github.com/ansible/test-playbooks
223+
wait: true
224+
register: project_info
225+
226+
- name: Add Joe and teams to the update role of the default Project with lookup from the 2nd Organization
227+
role:
228+
user: "{{ username }}"
229+
users:
230+
- "{{ username }}2"
231+
teams:
232+
- "{{ team_name }}"
233+
- "{{ team2_name }}"
234+
role: update
235+
lookup_organization: "{{ org2_name }}"
236+
project: "{{ project_name }}"
237+
state: "{{ item }}"
238+
register: result
239+
with_items:
240+
- "present"
241+
- "absent"
242+
243+
- assert:
244+
that:
245+
- "result is changed"
246+
212247
always:
213248
- name: Delete a User
214249
user:
@@ -252,3 +287,16 @@
252287
organization: Default
253288
state: absent
254289
register: result
290+
291+
- name: Delete the 2nd project
292+
project:
293+
name: "{{ project_name }}"
294+
organization: "{{ org2_name }}"
295+
state: absent
296+
register: result
297+
298+
- name: Delete the 2nd organization
299+
organization:
300+
name: "{{ org2_name }}"
301+
state: absent
302+
register: result

0 commit comments

Comments
 (0)