add ability to lookup unified job template by org

This commit is contained in:
sean-m-ssullivan
2021-09-23 13:25:01 -04:00
parent 33c7f0b5fc
commit c026790f55
5 changed files with 144 additions and 6 deletions

View File

@@ -5,10 +5,13 @@
- name: generate random string for schedule
set_fact:
org_name: "AWX-Collection-tests-organization-org-{{ test_id }}"
sched1: "AWX-Collection-tests-schedule-sched1-{{ test_id }}"
cred1: "AWX-Collection-tests-schedule-cred1-{{ test_id }}"
proj1: "AWX-Collection-tests-schedule-proj-{{ test_id }}"
proj1: "AWX-Collection-tests-schedule-proj1-{{ test_id }}"
proj2: "AWX-Collection-tests-schedule-proj2-{{ test_id }}"
jt1: "AWX-Collection-tests-schedule-jt1-{{ test_id }}"
jt2: "AWX-Collection-tests-schedule-jt1-{{ test_id }}"
- block:
- name: Try to create without an rrule
@@ -84,6 +87,19 @@
scm_type: git
scm_url: https://github.com/ansible/ansible-tower-samples.git
- name: "Create a new organization"
organization:
name: "{{ org_name }}"
- name: Create a Demo Project in another org
project:
name: "{{ proj2 }}"
organization: "{{ org_name }}"
allow_override: true
state: present
scm_type: git
scm_url: https://github.com/ansible/ansible-tower-samples.git
- name: Create Credential1
credential:
name: "{{ cred1 }}"
@@ -154,6 +170,24 @@
- assert:
that:
- result is changed
- name: Create a second Job Template in new org
job_template:
name: "{{ jt2 }}"
project: "{{ proj2 }}"
inventory: Demo Inventory
playbook: hello_world.yml
job_type: run
state: present
- name: Build a schedule with a job template's name in two orgs
schedule:
name: "{{ sched1 }}"
state: present
unified_job_template: "{{ jt2 }}"
rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1"
register: result
always:
- name: Delete the schedule
schedule:
@@ -167,6 +201,22 @@
playbook: hello_world.yml
state: absent
- name: Delete the jt
job_template:
name: "{{ jt2 }}"
project: "{{ proj2 }}"
playbook: hello_world.yml
state: absent
- name: Delete the Project
project:
name: "{{ proj2 }}"
organization: "{{ org_name }}"
state: absent
scm_type: git
scm_url: https://github.com/ansible/ansible-tower-samples.git
register: result
- name: Delete the Project
project:
name: "{{ proj1 }}"
@@ -182,3 +232,9 @@
organization: Default
credential_type: Red Hat Ansible Automation Platform
state: absent
- name: "Remove the organization"
organization:
name: "{{ org_name }}"
state: absent
register: result

View File

@@ -8,6 +8,7 @@
org_name: "AWX-Collection-tests-organization-org-{{ test_id }}"
scm_cred_name: "AWX-Collection-tests-workflow_job_template-scm-cred-{{ test_id }}"
demo_project_name: "AWX-Collection-tests-workflow_job_template-proj-{{ test_id }}"
demo_project_name_2: "AWX-Collection-tests-workflow_job_template-proj-{{ test_id }}_2"
jt1_name: "AWX-Collection-tests-workflow_job_template-jt1-{{ test_id }}"
jt2_name: "AWX-Collection-tests-workflow_job_template-jt2-{{ test_id }}"
approval_node_name: "AWX-Collection-tests-workflow_approval_node-{{ test_id }}"
@@ -87,6 +88,20 @@
that:
- "result is changed"
- name: Create a 2nd Demo Project in another org
project:
name: "{{ demo_project_name_2 }}"
organization: "{{ org_name }}"
state: present
scm_type: git
scm_url: https://github.com/ansible/ansible-tower-samples.git
scm_credential: "{{ scm_cred_name }}"
register: result
- assert:
that:
- "result is changed"
- name: Add an inventory
inventory:
description: Test inventory
@@ -136,6 +151,20 @@
that:
- "result is changed"
- name: Create a second Job Template in new org
job_template:
name: "{{ jt2_name }}"
project: "{{ demo_project_name_2 }}"
inventory: Demo Inventory
playbook: hello_world.yml
job_type: run
state: present
register: result
- assert:
that:
- "result is changed"
- name: Add a Survey to second Job Template
job_template:
name: "{{ jt2_name }}"
@@ -191,6 +220,7 @@
workflow_job_template_node:
identifier: leaf
unified_job_template: "{{ jt2_name }}"
lookup_organization: "{{ org_name }}"
workflow: "{{ wfjt_name }}"
- name: Create root node
@@ -616,6 +646,22 @@
job_template:
name: "{{ jt2_name }}"
project: "{{ demo_project_name }}"
organization: Default
inventory: Demo Inventory
playbook: hello_world.yml
job_type: run
state: absent
register: result
- assert:
that:
- "result is changed"
- name: Delete the second Job Template
job_template:
name: "{{ jt2_name }}"
project: "{{ demo_project_name_2 }}"
organization: "{{ org_name }}"
inventory: Demo Inventory
playbook: hello_world.yml
job_type: run
@@ -658,6 +704,16 @@
state: absent
register: result
- name: Delete the 2nd Demo Project
project:
name: "{{ demo_project_name_2 }}"
organization: "{{ org_name }}"
scm_type: git
scm_url: https://github.com/ansible/ansible-tower-samples.git
scm_credential: "{{ scm_cred_name }}"
state: absent
register: result
- assert:
that:
- "result is changed"