Skip to content

Commit b4cc2f2

Browse files
committed
making callback method more robust
this will make sure if ansible tower is down that the workshop will provision without failure
1 parent 6ab3309 commit b4cc2f2

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

provisioner/group_vars/all.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ teardown: false
55
towerinstall: false
66
website_information: ""
77
dns_information: "No errors with DNS"
8+
callback_information: "No issue with Ansible Tower callback"
89
workshop_type: ""
910
dns_type: aws
1011
valid_dns_type:

provisioner/provision_lab.yml

+1
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@
224224
FAILURES
225225
*******************
226226
{{dns_information}}
227+
{{callback_information}}
227228
228229
- name: Print Summary Information
229230
debug:
+30-17
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
11
---
2-
- name: execute a command with tower
3-
uri:
4-
url: https://ansible.rhdemo.io/api/v2/job_templates/22/launch/
5-
validate_certs: no
6-
method: POST
7-
user: public
8-
password: public
9-
status_code: [200, 201]
10-
force_basic_auth: yes
11-
body:
12-
extra_vars:
13-
ec2_name_prefix: "{{ ec2_name_prefix }}"
14-
aws_user: "{{ aws_user }}"
15-
ec2_region: "{{ ec2_region }}"
16-
student_total: "{{ student_total }}"
17-
workshop_type: "{{ workshop_type }}"
18-
body_format: json
2+
- name: attempt callback to record data
3+
block:
4+
- name: execute a command with tower
5+
uri:
6+
url: https://ansible.rhdemo.io/api/v2/job_templates/22/launch/
7+
validate_certs: no
8+
method: POST
9+
user: public
10+
password: public
11+
status_code: [200, 201]
12+
force_basic_auth: yes
13+
body:
14+
extra_vars:
15+
ec2_name_prefix: "{{ ec2_name_prefix }}"
16+
aws_user: "{{ aws_user }}"
17+
ec2_region: "{{ ec2_region }}"
18+
student_total: "{{ student_total }}"
19+
workshop_type: "{{ workshop_type }}"
20+
body_format: json
21+
rescue:
22+
- debug:
23+
msg: 'Ansible Tower callback has failed, we will fail gracefully'
24+
25+
- name: append information to summary
26+
set_fact:
27+
callback_information: |
28+
- Ansible Tower callback failure, this workshop will not be recorded
29+
run_once: yes
30+
delegate_to: localhost
31+
delegate_facts: true

0 commit comments

Comments
 (0)