3. What is Event Driven Ansible?
> a new way to enhance and expand automation. It improves
IT speed and agility, while enabling consistency and
resilience.
IFTT for sysadmins
9. Rulebook
---
- name: Listen for events on a webhook
hosts: all
## Define our source for events
sources:
- ansible.eda.webhook:
host: 0.0.0.0
port: 5000
## Define the conditions we are looking for
rules:
- name: Say Hello
condition: event.payload.message == "Ansible is super cool"
## Define the action we should take should the condition be met
action:
run_playbook:
name: say-what.yml
13. Add a Playbook and Inventory
playbook:
- hosts: localhost
connection: local
tasks:
- debug:
msg: "Thank you, my friend!"
inventory
localhost
14. Running it
> ansible-rulebook --rulebook webhook-rule.yml -i inventory.yml --verbose
INFO:ansible_rulebook.app:Starting sources
INFO:ansible_rulebook.app:Starting rules
INFO:ansible_rulebook.engine:run_ruleset
...
INFO:ansible_rulebook.engine:load source
INFO:ansible_rulebook.engine:load source filters
INFO:ansible_rulebook.engine:Calling main in ansible.eda.webhook
INFO:ansible_rulebook.engine:Waiting for event from Listen for events on a webhook
15. Using it
What I do
> curl -d "{"message": "Ansible is super cool"}" http://127.0.0.1:5000/endpoint
What Event Driven Ansible does
INFO:ansible_rulebook.engine:action args: {'name': 'say-what.yml'}
INFO:ansible_rulebook.builtin:running Ansible playbook: say-what.yml
INFO:ansible_rulebook.builtin:ruleset: Listen for events on a webhook, rule: Say Hello
INFO:ansible_rulebook.builtin:Calling Ansible runner
PLAY [say thanks] **************************************************************
TASK [Gathering Facts] *********************************************************
ok: [localhost]
TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": "say what"
}