mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 13:39:27 -02:30
Collection: add a test for multiple credentials on a jt
This commit is contained in:
@@ -1,27 +1,47 @@
|
|||||||
---
|
---
|
||||||
- name: Create an SCM Credential
|
- name: generate random string for project
|
||||||
|
set_fact:
|
||||||
|
cred1: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
|
cred2: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
|
cred3: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
|
proj1: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
|
jt1: "hello-world {{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
|
jt2: "hello-world {{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
|
|
||||||
|
- name: Create Credential1
|
||||||
tower_credential:
|
tower_credential:
|
||||||
name: SCM Credential for JT
|
name: "{{ cred1 }}"
|
||||||
organization: Default
|
organization: Default
|
||||||
kind: scm
|
kind: tower
|
||||||
|
|
||||||
|
- name: Create Credential2
|
||||||
|
tower_credential:
|
||||||
|
name: "{{ cred2 }}"
|
||||||
|
organization: Default
|
||||||
|
kind: ssh
|
||||||
|
|
||||||
|
- name: Create Credential3
|
||||||
|
tower_credential:
|
||||||
|
name: "{{ cred3 }}"
|
||||||
|
organization: Default
|
||||||
|
kind: ssh
|
||||||
|
|
||||||
- name: Create a Demo Project
|
- name: Create a Demo Project
|
||||||
tower_project:
|
tower_project:
|
||||||
name: Job Template Test Project
|
name: "{{ proj1 }}"
|
||||||
organization: Default
|
organization: Default
|
||||||
state: present
|
state: present
|
||||||
scm_type: git
|
scm_type: git
|
||||||
scm_url: https://github.com/ansible/ansible-tower-samples.git
|
scm_url: https://github.com/ansible/ansible-tower-samples.git
|
||||||
scm_credential: SCM Credential for JT
|
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Create a Job Template
|
- name: Create Job Template 1
|
||||||
tower_job_template:
|
tower_job_template:
|
||||||
name: "hello-world {{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
name: "{{ jt1 }}"
|
||||||
project: Job Template Test Project
|
project: "{{ proj1 }}"
|
||||||
inventory: Demo Inventory
|
inventory: Demo Inventory
|
||||||
playbook: hello_world.yml
|
playbook: hello_world.yml
|
||||||
credential: Demo Credential
|
credentials: ["{{ cred1 }}", "{{ cred2 }}"]
|
||||||
job_type: run
|
job_type: run
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
@@ -29,3 +49,78 @@
|
|||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- "result is changed"
|
||||||
|
|
||||||
|
# This doesnt work if you include the credentials parameter
|
||||||
|
- name: Delete Job Template 1
|
||||||
|
tower_job_template:
|
||||||
|
name: "{{ jt1 }}"
|
||||||
|
project: "{{ proj1 }}"
|
||||||
|
inventory: Demo Inventory
|
||||||
|
playbook: hello_world.yml
|
||||||
|
job_type: run
|
||||||
|
state: absent
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create Job Template 2
|
||||||
|
tower_job_template:
|
||||||
|
name: "{{ jt2 }}"
|
||||||
|
project: "{{ proj1 }}"
|
||||||
|
inventory: Demo Inventory
|
||||||
|
playbook: hello_world.yml
|
||||||
|
credential: "{{ cred3 }}"
|
||||||
|
job_type: run
|
||||||
|
state: present
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete Job Template 2
|
||||||
|
tower_job_template:
|
||||||
|
name: "{{ jt2 }}"
|
||||||
|
project: "{{ proj1 }}"
|
||||||
|
inventory: Demo Inventory
|
||||||
|
playbook: hello_world.yml
|
||||||
|
credential: "{{ cred3 }}"
|
||||||
|
job_type: run
|
||||||
|
state: absent
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete the Demo Project
|
||||||
|
tower_project:
|
||||||
|
name: "{{ proj1 }}"
|
||||||
|
organization: Default
|
||||||
|
state: absent
|
||||||
|
scm_type: git
|
||||||
|
scm_url: https://github.com/ansible/ansible-tower-samples.git
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: Delete Credential1
|
||||||
|
tower_credential:
|
||||||
|
name: "{{ cred1 }}"
|
||||||
|
organization: Default
|
||||||
|
kind: tower
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Delete Credential2
|
||||||
|
tower_credential:
|
||||||
|
name: "{{ cred2 }}"
|
||||||
|
organization: Default
|
||||||
|
kind: ssh
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Delete Credential3
|
||||||
|
tower_credential:
|
||||||
|
name: "{{ cred3 }}"
|
||||||
|
organization: Default
|
||||||
|
kind: ssh
|
||||||
|
state: absent
|
||||||
|
|||||||
Reference in New Issue
Block a user