forked from redhat-cop/agnosticd
-
Notifications
You must be signed in to change notification settings - Fork 1
/
completion_callback.yml
35 lines (35 loc) · 1.13 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
- name: Completion Callback
gather_facts: false
hosts: localhost
tasks:
- name: Attempt completion callback
when:
- __meta__ is defined
- __meta__.callback is defined
- __meta__.callback.url | default('') != ''
- __meta__.callback.token | default('') != ''
vars:
user_data_yaml: "{{ output_dir ~ '/user-data.yaml' }}"
user_info_yaml: "{{ output_dir ~ '/user-info.yaml' }}"
uri:
url: "{{ __meta__.callback.url }}"
method: POST
body_format: json
body:
event: complete
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 {{ __meta__.callback.token }}
# Best effort
ignore_errors: true