diff --git a/awx_collection/plugins/lookup/tower_api.py b/awx_collection/plugins/lookup/tower_api.py index f9b6d591cf..9829507125 100644 --- a/awx_collection/plugins/lookup/tower_api.py +++ b/awx_collection/plugins/lookup/tower_api.py @@ -76,17 +76,18 @@ EXAMPLES = """ debug: msg: "Admin users: {{ query('awx.awx.tower_api', 'users', query_params={ 'is_superuser': true }) | map(attribute='username') | join(', ') }}" -- name: Lookup any users who are admins and get their objects directly - set_fact: - admin_user_object: "{{ lookup('awx.awx.tower_api', 'users', query_params={ 'is_superuser': true } ) }}" +- name: debug all organizations in a loop # use query to return a list + debug: + msg: "Organization description={{ item['description'] }} id={{ item['id'] }}" + loop: "{{ query('awx.awx.tower_api', 'organizations') }}" + loop_control: + label: "{{ item['name'] }}" - name: Make sure user 'john' is an org admin of the default org if the user exists tower_role: organization: Default role: admin user: john - state: absent - register: tower_role_revoke when: "lookup('awx.awx.tower_api', 'users', query_params={ 'username': 'john' }) | length == 1" - name: Create an inventory group with all 'foo' hosts diff --git a/awx_collection/tests/integration/targets/tower_lookup_api_plugin/tasks/main.yml b/awx_collection/tests/integration/targets/tower_lookup_api_plugin/tasks/main.yml index 0f2bef3cce..e4415e24d4 100644 --- a/awx_collection/tests/integration/targets/tower_lookup_api_plugin/tasks/main.yml +++ b/awx_collection/tests/integration/targets/tower_lookup_api_plugin/tasks/main.yml @@ -187,13 +187,12 @@ that: - "'admin' in results.msg" - - name: Lookup any users who are admins and get their objects directly - set_fact: - admin_user_object: "{{ lookup('awx.awx.tower_api', 'users', query_params={ 'is_superuser': true } ) }}" - - - assert: - that: - - "'count' not in admin_user_object" + - name: debug all organizations in a loop # use query to return a list + debug: + msg: "Organization description={{ item['description'] }} id={{ item['id'] }}" + loop: "{{ query('awx.awx.tower_api', 'organizations') }}" + loop_control: + label: "{{ item['name'] }}" - name: Make sure user 'john' is an org admin of the default org if the user exists tower_role: