forked from redhat-cop/agnosticd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
completion_callback.yml
41 lines (41 loc) · 1.4 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
- 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('') if __meta__ is defined and __meta__.callback is defined else '' }}
agnosticd_callback_token: >-
{{ __meta__.callback.token | default('') if __meta__ is defined and __meta__.callback is defined else '' }}
tasks:
- name: Attempt completion callback
when:
- agnosticd_callback_url != ''
- agnosticd_callback_token != ''
vars:
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
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