Collection: add a test for multiple credentials on a jt

This commit is contained in:
Caleb Boylan 2020-03-13 12:09:45 -07:00
parent 7c6bef15ba
commit 16d5456d2b

View File

@ -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:
name: SCM Credential for JT
name: "{{ cred1 }}"
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
tower_project:
name: Job Template Test Project
name: "{{ proj1 }}"
organization: Default
state: present
scm_type: git
scm_url: https://github.com/ansible/ansible-tower-samples.git
scm_credential: SCM Credential for JT
register: result
- name: Create a Job Template
- name: Create Job Template 1
tower_job_template:
name: "hello-world {{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
project: Job Template Test Project
name: "{{ jt1 }}"
project: "{{ proj1 }}"
inventory: Demo Inventory
playbook: hello_world.yml
credential: Demo Credential
credentials: ["{{ cred1 }}", "{{ cred2 }}"]
job_type: run
state: present
register: result
@ -29,3 +49,78 @@
- assert:
that:
- "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