Files
awx/awx_collection/tests/integration/targets/application/tasks/main.yml
John Westcott IV 7f020052db Make state exists universal in collection (#13890)
Make state: exists available for all API modules

Make state:exists return the ID just like it would if it created the resource
2023-05-10 09:05:29 -03:00

131 lines
3.1 KiB
YAML

---
- name: Generate a test id
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:
app1_name: "AWX-Collection-tests-application-app1-{{ test_id }}"
app2_name: "AWX-Collection-tests-application-app2-{{ test_id }}"
app3_name: "AWX-Collection-tests-application-app3-{{ test_id }}"
- block:
- name: Create an application
application:
name: "{{ app1_name }}"
authorization_grant_type: "password"
client_type: "public"
organization: "Default"
state: present
register: result
- assert:
that:
- "result is changed"
- name: Run an application with exists
application:
name: "{{ app1_name }}"
authorization_grant_type: "password"
client_type: "public"
organization: "Default"
state: exists
register: result
- assert:
that:
- "result is not changed"
- name: Delete our application
application:
name: "{{ app1_name }}"
organization: "Default"
state: absent
register: result
- assert:
that:
- "result is changed"
- name: Run an application with exists
application:
name: "{{ app1_name }}"
authorization_grant_type: "password"
client_type: "public"
organization: "Default"
state: exists
register: result
- assert:
that:
- "result is changed"
- name: Delete our application
application:
name: "{{ app1_name }}"
organization: "Default"
state: absent
register: result
- assert:
that:
- "result is changed"
- name: Create a second application
application:
name: "{{ app2_name }}"
authorization_grant_type: "authorization-code"
client_type: "confidential"
organization: "Default"
description: "Another application"
redirect_uris:
- http://tower.com/api/v2/
- http://tower.com/api/v2/teams
state: present
register: result
- assert:
that:
- "result is changed"
- name: Create an all trusting application
application:
name: "{{ app3_name }}"
organization: "Default"
description: "All Trusting Application"
skip_authorization: true
authorization_grant_type: "password"
client_type: "confidential"
state: present
register: result
- assert:
that:
- "result is changed"
- name: Rename an inventory
application:
name: "{{ app3_name }}"
new_name: "{{ app3_name }}a"
organization: Default
state: present
register: result
- assert:
that:
- result.changed
always:
- name: Delete our application
application:
name: "{{ item }}"
organization: "Default"
state: absent
register: result
loop:
- "{{ app1_name }}"
- "{{ app2_name }}"
- "{{ app3_name }}"
- "{{ app3_name }}a"