-------- - Added new method to call the webhook via handler - Added inventory_hostname to webhook calls to see who is doing what - Updated messages for better readability - Added comment markers for clarity
41 lines
1004 B
YAML
41 lines
1004 B
YAML
- name: "Webhook Test 1: Long running job"
|
|
hosts: all
|
|
gather_facts: false
|
|
become: false
|
|
|
|
|
|
vars:
|
|
pause_time : 1
|
|
num_retries : 5
|
|
fail_count : 30
|
|
poll_interval : 10
|
|
|
|
webhook : "https://webhooks.thezengarden.net/webhook-callback-poc"
|
|
webhook_key : "fYnWhoF42NFsN2p5tiB3Wd65HgB1oc-Qo2jXS6TTmZov"
|
|
|
|
check_commands:
|
|
- uname -a
|
|
- uptime
|
|
- ping -c 1 127.0.0.1
|
|
|
|
|
|
tasks:
|
|
- name: Include long_running_tasks.yml
|
|
ansible.builtin.include_tasks: tasks/long_running_tasks.yml
|
|
|
|
|
|
handlers:
|
|
- name: Bob
|
|
ansible.builtin.uri:
|
|
url : "{{ webhook }}"
|
|
headers:
|
|
Authorization : "Token {{ webhook_key }}"
|
|
Content-type : 'application/json'
|
|
method : POST
|
|
status_code : 200
|
|
validate_certs : false
|
|
return_content : false
|
|
body_format : json
|
|
body : |
|
|
"{{ inventory_hostname }}": "We've reached equilibrium."
|