-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcompletion_callback.yml
59 lines (55 loc) · 1.84 KB
/
completion_callback.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
---
- name: Setup output dir
import_playbook: output_dir.yml
- name: Completion Callback
gather_facts: false
hosts: localhost
vars:
# default __meta__ to prevent errors on older ansible versions
__meta__:
callback: {}
agnosticd_callback_url: "{{ __meta__.callback.url | default('') }}"
agnosticd_callback_token: "{{ __meta__.callback.token | default('') }}"
tasks:
- name: Skip completion callback
meta: end_play
when:
- agnosticd_callback_disabled is defined
- agnosticd_callback_disabled | bool
- name: Attempt completion callback
when:
- agnosticd_callback_url != ''
- agnosticd_callback_token != ''
vars:
user_body_yaml: "{{ output_dir ~ '/user-body.yaml' }}"
user_data_yaml: "{{ output_dir ~ '/user-data.yaml' }}"
user_info_yaml: "{{ output_dir ~ '/user-info.yaml' }}"
uri:
url: "{{ agnosticd_callback_url }}"
method: POST
body_format: json
body:
event: complete
message_body: >-
{%- if user_body_yaml is file -%}
{{ lookup('file', user_body_yaml) | from_yaml | default([], true) }}
{%- else -%}
[]
{%- endif -%}
messages: >-
{%- if user_info_yaml is file -%}
{{ lookup('file', user_info_yaml) | from_yaml | default([], true) }}
{%- else -%}
[]
{%- endif -%}
data: >-
{%- if user_data_yaml is file -%}
{{ lookup('file', user_data_yaml) | from_yaml | default({}, true) }}
{%- else -%}
{}
{%- endif -%}
headers:
Authorization: Bearer {{ agnosticd_callback_token }}
validate_certs: "{{ validate_tower_certs | default(true) }}"
# Best effort
ignore_errors: true