diff --git a/awx_collection/plugins/modules/role.py b/awx_collection/plugins/modules/role.py index 40463746b8..f94447c75b 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 dd499b1d2f..0e8999fe96 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