From 7db9b472c3825416c4e8eb92e6a9cc089624a98b Mon Sep 17 00:00:00 2001 From: Eric Chong Date: Fri, 11 Oct 2024 11:57:30 -0400 Subject: [PATCH] Fix - also resetting lookup_data_populated when key is teams --- awx_collection/plugins/modules/role.py | 2 +- .../integration/targets/role/tasks/main.yml | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/awx_collection/plugins/modules/role.py b/awx_collection/plugins/modules/role.py index 40463746b8d4..f94447c75b22 100644 --- a/awx_collection/plugins/modules/role.py +++ b/awx_collection/plugins/modules/role.py @@ -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 diff --git a/awx_collection/tests/integration/targets/role/tasks/main.yml b/awx_collection/tests/integration/targets/role/tasks/main.yml index dd499b1d2f28..cf9686178aef 100644 --- a/awx_collection/tests/integration/targets/role/tasks/main.yml +++ b/awx_collection/tests/integration/targets/role/tasks/main.yml @@ -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 @@ -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: @@ -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 \ No newline at end of file