Skip to content

Commit

Permalink
Fix - also resetting lookup_data_populated when key is teams
Browse files Browse the repository at this point in the history
  • Loading branch information
ecchong committed Oct 11, 2024
1 parent 825a02c commit 7db9b47
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion awx_collection/plugins/modules/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def main():
for resource in value:
# Attempt to look up project based on the provided name, ID, or named URL and lookup data
lookup_key = key
if key == 'organizations' or key == 'users':
if key == 'organizations' or key == 'users' or key == 'teams':
lookup_data_populated = {}
else:
lookup_data_populated = lookup_data
Expand Down
48 changes: 48 additions & 0 deletions awx_collection/tests/integration/targets/role/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
wfjt_name: "AWX-Collection-tests-role-project-wfjt-{{ test_id }}"
team_name: "AWX-Collection-tests-team-team-{{ test_id }}"
team2_name: "AWX-Collection-tests-team-team-{{ test_id }}2"
org2_name: "AWX-Collection-tests-organization-{{ test_id }}2"

- block:
- name: Create a User
Expand Down Expand Up @@ -209,6 +210,40 @@
that:
- "result is changed"

- name: Create a 2nd organization
organization:
name: "{{ org2_name }}"

- name: Create a project in 2nd Organization
project:
name: "{{ project_name }}"
organization: "{{ org2_name }}"
scm_type: git
scm_url: https://github.com/ansible/test-playbooks
wait: true
register: project_info

- name: Add Joe and teams to the update role of the default Project with lookup from the 2nd Organization
role:
user: "{{ username }}"
users:
- "{{ username }}2"
teams:
- "{{ team_name }}"
- "{{ team2_name }}"
role: update
lookup_organization: "{{ org2_name }}"
project: "{{ project_name }}"
state: "{{ item }}"
register: result
with_items:
- "present"
- "absent"

- assert:
that:
- "result is changed"

always:
- name: Delete a User
user:
Expand Down Expand Up @@ -252,3 +287,16 @@
organization: Default
state: absent
register: result

- name: Delete the 2nd project
project:
name: "{{ project_name }}"
organization: "{{ org2_name }}"
state: absent
register: result

- name: Delete the 2nd organization
organization:
name: "{{ org2_name }}"
state: absent
register: result

0 comments on commit 7db9b47

Please sign in to comment.