loopabull is an event loop driven Ansible playbook execution engine.
In other words, it triggers Ansible playbooks automatically when receiving a corresponding fedmsg message.
This repository stores the ansible playbooks and their related scripts used by the Fedora Infrastructure team.
Adding a new task to loopabull is quite easy.
For example, let's run a small/dummy python script everytime a koji build finished in staging.
The topic we want to trigger of is thus: org.fedoraproject.stg.buildsys.build.state.change
,
so we go and edit the playbook: playbooks/org.fedoraproject.stg.buildsys.build.state.change.yml
in this repository and add a debug role that has one variable: the message
received via fedmsg msg.
Then add a debug
role in playbooks/roles/debug
. Make that role install
your python script, call it with a certain environment variable and print
the output of the script for debugging.
Then, on the infrastructure's ansible repository, configure loopabull to listen to this topic (line 70): https://infrastructure.fedoraproject.org/cgit/ansible.git/tree/playbooks/groups/loopabull.yml?id=4b053dd68cc12e1823516eec481fab04f9b9166b#n70
Finally, run the ansible playbook deploying this change:
ansible-playbook /srv/web/infra/ansible/playbooks/groups/loopabull.yml -t loopabull
Note
you may have to restart things on loopabull's side:
systemctl restart loopabull loopabull@1 loopabull@2 loopabull@3 loopabull@4 loopabull@5
For every change made to this repository (for example when fixing typos, bugs
or making improvements), the playbooks/groups/loopabull.yml
playbook from
the Fedora infrastructure's ansible repo will need to be run so the underlying
clone of this repo on the system gets updated.
playbooks/groups/loopabull.yml
playbook in infra's ansible repo.)'
and double-quotes "
. The proper way to pass the message to the
script avoiding issues with quotes is to use: {{ msg | to_json | quote }}
(note the lack of quotes surrounding this, | quote
takes care of adding
them).