Examples of Event-Driven Ansible
This repository stores examples of Event-Driven Ansible, taken from: https://www.ansible.com/products/ansible-training#event-driven-automation
To try it out in a lab environment, simply follow the above link or run it in your own environment by cloning this repository.
Try it out in your own environment
- Clone this repository
git clone https://github.com/mglantz/event-driven-ansible-demo
- Install ansible-rulebook
pip3 install ansible-rulebook
dnf install java-17-openjdk
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk
- Create an inventory file to run against.
- Run setup playbook
cd event-driven-ansible-demo
ansible-playbook -i inventory.yml setup-apache.yml
- Run the website-automation example with:
ansible-rulebook --rules website-automation.yml -i inventory.yml --verbose
- Disable apache and see rulebook stdout
ansible-playbook -i inventory.yml setup-apache.yml -e httpd_state=stopped
Try out demo EDA plugin
- Clone this repository
git clone https://github.com/mglantz/event-driven-ansible-demo
- Copy demo plugin to your module directory.
cp event-driven-ansible-demo/ansible/eda/plugins/demo.py ~/.ansible/collections/ansible_collections/ansible/eda/plugins/event_source/
- Run demo rulebook
cd event-driven-ansible-demo
ansible-rulebook -i demo_inventory --rulebook demo-rulebook.yml
- Try and edit the demo.py plugin or file-missing/file-exists.yml playbooks to do something smarter.