On Oct 30, Erik Schwalbe wrote:
Is it possible to automatically run additional tasks after execution
of common.yml?
for example:
ansible/playbooks/test-vm.yml
---
- name: additional test-vm tasks
hosts: test-vm
...
and execute this playbook automatically with debops -l test-vm
Technically it's possible to chain multiple Ansible playbooks one after the
other. At the moment, the 'debops' script looks only at the first argument to
see if that might be a potential playbook, and passes the rest of the
arguments to 'ansible-playbook' command. Therefore you could "chain" the
main
DebOps playbook and your custom playbook like this:
debops site ansible/playbooks/test-vm.yml -l test-vm
This will execute the ~/.local/share/debops/debops/playbooks/site.yml (it's in
playbooks/playbooks/ at the moment of course, but hopefully not much longer),
and then run your custom playbook afterwards. Instead of 'site', you can use
'common' to run just the DebOps common playbook.
In the future, when the scripts are improved, this could be done easier.
Perhaps this could be specified in a config somewhere, where you could define
pre- and post- playbooks to run always unless a playbook is specified; and
better argument recognition would make that easier as well.
And you can create a small Bash wrapper script to run the above command in the
meantime.
Cheers,
Maciej