-
Notifications
You must be signed in to change notification settings - Fork 497
/
completion_callback.yml
43 lines (43 loc) · 1.43 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
- name: Completion Callback
gather_facts: false
hosts: localhost
vars:
agnosticd_callback_url: ''
agnosticd_callback_token: ''
tasks:
- name: Attempt completion callback
when:
- agnosticd_callback_url != ''
- agnosticd_callback_token != ''
vars:
user_body_yaml: "{{ [ output_dir, ACTION ~ '-user-body.yaml' ] | path_join }}"
user_data_yaml: "{{ [ output_dir, ACTION ~ '-user-data.yaml' ] | path_join }}"
user_info_yaml: "{{ [ output_dir, ACTION ~ '-user-info.yaml' ] | path_join }}"
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 }}
# Best effort
ignore_errors: true