mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
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
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
cred1: "AWX-Collection-tests-job_template-cred1-{{ test_id }}"
|
||||
cred2: "AWX-Collection-tests-job_template-cred2-{{ test_id }}"
|
||||
cred3: "AWX-Collection-tests-job_template-cred3-{{ test_id }}"
|
||||
inv1: "AWX-Collection-tests-job_template-inv-{{ test_id }}"
|
||||
proj1: "AWX-Collection-tests-job_template-proj-{{ test_id }}"
|
||||
jt1: "AWX-Collection-tests-job_template-jt1-{{ test_id }}"
|
||||
jt2: "AWX-Collection-tests-job_template-jt2-{{ test_id }}"
|
||||
@@ -25,6 +26,11 @@
|
||||
- Ansible Galaxy
|
||||
register: result
|
||||
|
||||
- name: Create an inventory
|
||||
inventory:
|
||||
name: "{{ inv1 }}"
|
||||
organization: "{{ org_name }}"
|
||||
|
||||
- name: Create a Demo Project
|
||||
project:
|
||||
name: "{{ proj1 }}"
|
||||
@@ -104,7 +110,7 @@
|
||||
job_template:
|
||||
name: "{{ jt1 }}"
|
||||
project: "{{ proj1 }}"
|
||||
inventory: Demo Inventory
|
||||
inventory: "{{ inv1 }}"
|
||||
playbook: hello_world.yml
|
||||
credentials:
|
||||
- "{{ cred1 }}"
|
||||
@@ -119,6 +125,63 @@
|
||||
that:
|
||||
- "jt1_result is changed"
|
||||
|
||||
- name: Create Job Template 1 with exists
|
||||
job_template:
|
||||
name: "{{ jt1 }}"
|
||||
project: "{{ proj1 }}"
|
||||
inventory: "{{ inv1 }}"
|
||||
playbook: hello_world.yml
|
||||
credentials:
|
||||
- "{{ cred1 }}"
|
||||
- "{{ cred2 }}"
|
||||
instance_groups:
|
||||
- "{{ group_name1 }}"
|
||||
job_type: run
|
||||
state: exists
|
||||
register: jt1_result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "jt1_result is not changed"
|
||||
|
||||
- name: Delete Job Template 1
|
||||
job_template:
|
||||
name: "{{ jt1 }}"
|
||||
project: "{{ proj1 }}"
|
||||
inventory: "{{ inv1 }}"
|
||||
playbook: hello_world.yml
|
||||
credentials:
|
||||
- "{{ cred1 }}"
|
||||
- "{{ cred2 }}"
|
||||
instance_groups:
|
||||
- "{{ group_name1 }}"
|
||||
job_type: run
|
||||
state: absent
|
||||
register: jt1_result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "jt1_result is changed"
|
||||
|
||||
- name: Create Job Template 1 with exists
|
||||
job_template:
|
||||
name: "{{ jt1 }}"
|
||||
project: "{{ proj1 }}"
|
||||
inventory: "{{ inv1 }}"
|
||||
playbook: hello_world.yml
|
||||
credentials:
|
||||
- "{{ cred1 }}"
|
||||
- "{{ cred2 }}"
|
||||
instance_groups:
|
||||
- "{{ group_name1 }}"
|
||||
job_type: run
|
||||
state: exists
|
||||
register: jt1_result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "jt1_result is changed"
|
||||
|
||||
- name: Add a credential to this JT
|
||||
job_template:
|
||||
name: "{{ jt1 }}"
|
||||
@@ -218,7 +281,7 @@
|
||||
name: "{{ jt2 }}"
|
||||
organization: Default
|
||||
project: "{{ proj1 }}"
|
||||
inventory: Demo Inventory
|
||||
inventory: "{{ inv1 }}"
|
||||
playbook: hello_world.yml
|
||||
credential: "{{ cred3 }}"
|
||||
job_type: run
|
||||
@@ -236,7 +299,7 @@
|
||||
name: "{{ jt2 }}"
|
||||
organization: Default
|
||||
project: "{{ proj1 }}"
|
||||
inventory: Demo Inventory
|
||||
inventory: "{{ inv1 }}"
|
||||
playbook: hello_world.yml
|
||||
credential: "{{ cred3 }}"
|
||||
job_type: run
|
||||
@@ -384,7 +447,7 @@
|
||||
job_template:
|
||||
name: "{{ jt2 }}"
|
||||
project: "{{ proj1 }}"
|
||||
inventory: Demo Inventory
|
||||
inventory: "{{ inv1 }}"
|
||||
playbook: hello_world.yml
|
||||
credential: "{{ cred3 }}"
|
||||
job_type: run
|
||||
@@ -444,6 +507,12 @@
|
||||
organization: Default
|
||||
state: absent
|
||||
|
||||
- name: Delete an inventory
|
||||
inventory:
|
||||
name: "{{ inv1 }}"
|
||||
organization: "{{ org_name }}"
|
||||
state: absent
|
||||
|
||||
- name: "Remove the organization"
|
||||
organization:
|
||||
name: "{{ org_name }}"
|
||||
|
||||
Reference in New Issue
Block a user