Event driven automation with Ansible
Magnus Glantz
Principal Specialist Solution Architect at Red Hat | author | spokesperson | linux | k8s | ansible | security
What is this all about?
Just a few weeks ago we have had a new significant development in the Ansible space, it is the introduction of Event-Driven Ansible. It includes new tools which allows you to automatically trigger automation using events. This is what many of our customers have been doing with Ansible Automation Platform, Event-Driven Ansible both makes it easier to do and available to everyone, also those doing Ansible outside of Ansible Automation Platform and AWX.
Event-Driven Ansible is in developer preview, which means that we are collecting feedback. Get engaged and influence the development of this significant piece of technology. The upstream open source project lives here: https://github.com/ansible/event-driven-ansible
As Event-Driven Ansible matures, a qualified guess is that we can look forward for more event-driven features in Ansible Automation Platform as well ;)
I am myself very excited regarding this. Read on to learn more.
Review of what Event-Driven Ansible is
Let's dive into it all. First off, there's a compliment to the Ansible playbook, and it is called a rulebook. Rulebooks gets read by ansible-rulebook, just as playbooks are read by ansible-playbook.
Rulebooks are just as playbooks written in YAML but has some different structure. Let's have a look at one.
There are three parts of a rulebook:
领英推荐
And here is what running the rulebook looks like:
ansible-rulebook --rules website-automation.yml -i inventory.yml --verbose
Try it out for yourself
You can access our free online lab to try out both the url_check example described above and another lab which uses the kafka source plugin here: https://www.ansible.com/products/ansible-training#event-driven-automation
If you want to try it out on your own systems, have a look at this repository, where I have put example rulebooks and playbooks: https://github.com/mglantz/event-driven-ansible-demo
To install ansible-rulebook, do this:
$ pip3 install ansible-rulebook
$ export JAVA_HOME=/usr/lib/jvm/java-17-openjdk
Read more
This blog from Emily Bock is an excellent read: https://www.ansible.com/blog/introducing-event-driven-ansible
Senior Advisor at Tolletaten
2 年So what you are saying if we haven't yet started with ArgoCD, perhaps we should wait and investigate an other approach with ansible that we are more familiarly with?
CEO and Founder at Deslicer | Splunk & Automation Specialist | CISSP
2 年Thanks for sharing this new project, it fits very well with next step self-tuning and self-healing automation. This will simplify a lot of complex automation triggers with the event listener! I’ll have a go with it and see what I can contribute with??
Platform engineer at Kognic
2 年So do you will be running one Ansible rulebook instance per rulle that you want to setup? It seems a bit painful as scale... Or is the answer simple and if you want something central and at scale use Ansible Automation Platform? And i should see this more of an extra tool to be run on a specific server to help out with events only related to that server? I'm not in the Ansible space anymore but it looks very useful even though the scope is limited.
Principal Specialist Solution Architect at Red Hat | author | spokesperson | linux | k8s | ansible | security
2 年First pull request to Event Driven Ansible send. Improvements for the url_check source plugin :) Join in, it's a new project, so there's a lot to do. https://github.com/ansible/event-driven-ansible/pull/47