- 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