Skip to content

Commit 48d7473

Browse files
authored
Use templating to work around collection name restriction (#139)
1 parent 600b31e commit 48d7473

File tree

3 files changed

+51
-38
lines changed

3 files changed

+51
-38
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
*.pyc
1+
*.pyc
2+
3+
/tower_collection_actual.yml

tower_collection_smoke.j2

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
- name: Launch a Job Template
2+
{{ collection_id }}.tower_job_launch:
3+
job_template: "Demo Job Template"
4+
register: job
5+
6+
- assert:
7+
that:
8+
- "job is changed"
9+
- "job.status == 'pending'"
10+
11+
- name: List jobs w/ a matching primary key
12+
{{ collection_id }}.tower_job_list:
13+
query:
14+
id: "{{ '{{' }} job.id {{ '}}' }}"
15+
register: matching_jobs
16+
17+
- assert:
18+
that:
19+
- "{{ '{{' }} matching_jobs.count {{ '}}' }} == 1"
20+
21+
- name: List failed jobs (which don't exist)
22+
{{ collection_id }}.tower_job_list:
23+
status: failed
24+
query:
25+
id: "{{ '{{' }} job.id {{ '}}' }}"
26+
register: successful_jobs
27+
28+
- assert:
29+
that:
30+
- "{{ '{{' }} successful_jobs.count {{ '}}' }} == 0"
31+
32+
- name: Get ALL result pages!
33+
{{ collection_id }}.tower_job_list:
34+
all_pages: True
35+
register: all_page_query
36+
37+
- assert:
38+
that:
39+
- 'not all_page_query.next'

tower_collection_smoke.yml

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,15 @@
33
gather_facts: false
44
vars:
55
collection_id: awx.awx
6-
collections:
7-
- "{{ collection_id }}"
86
tasks:
9-
- name: Launch a Job Template
10-
tower_job_launch:
11-
job_template: "Demo Job Template"
12-
register: job
7+
- name: "Create playbook to call with collection FQCN"
8+
template:
9+
src: tower_collection_smoke.j2
10+
dest: tower_collection_actual.yml
1311

14-
- assert:
15-
that:
16-
- "job is changed"
17-
- "job.status == 'pending'"
12+
- include: tower_collection_actual.yml
1813

19-
- name: List jobs w/ a matching primary key
20-
tower_job_list:
21-
query: {"id": "{{ job.id }}"}
22-
register: matching_jobs
23-
24-
- assert:
25-
that:
26-
- "{{ matching_jobs.count }} == 1"
27-
28-
- name: List failed jobs (which don't exist)
29-
tower_job_list:
30-
status: failed
31-
query: {"id": "{{ job.id }}"}
32-
register: successful_jobs
33-
34-
- assert:
35-
that:
36-
- "{{ successful_jobs.count }} == 0"
37-
38-
- name: Get ALL result pages!
39-
tower_job_list:
40-
all_pages: True
41-
register: all_page_query
42-
43-
- assert:
44-
that:
45-
- 'not all_page_query.next'
14+
- name: "Delete dynamic playbook"
15+
file:
16+
path: tower_collection_actual.yml
17+
state: absent

0 commit comments

Comments
 (0)