debops / debops-playbooks

Ansible playbooks used by DebOps project
GNU General Public License v3.0
489 stars 88 forks source link

- include: custom.yml in site.yml #341

Open niccolox opened 7 years ago

niccolox commented 7 years ago

hi

would it make sense to add a custom.yml in site.yml that hooks into the custom playbook folder? and may or may not run a custom site.yml at the end of the debops site.yml?

obviously the path to include would need to change

but, this would be a convenience

drybjed commented 7 years ago

It's complicated. The ansible-playbook command parses all included files during a playbook execution, if a specified file does not exist (which presumably would be the default case here), Ansible stops execution.

On the other hand the design principles of DebOps dictate that the official playbooks are meant to be "read-only" to faciliate upgrades, so adding an include to a custom playbook, where this included file could be anywhere on each user's host is out of the question. There are workarounds like this in various DebOps roles to support custom files, templates or even tasks, but they rely on a custom set of lookup plugins which pretty much are required to be installed manually if you don't use the official set of playbooks.

At the moment the best workaround I can offer is this: when you run the debops command, the first argument is checked by the script to see if it's potentially a playbook. The rest are passed along to the ansible-playbook command, which supports chaining multiple playbooks together. Therefore, if you have your custom playbook in the playbooks/ directory of the DebOps project directory, you can run something like this to chain your custom playbook with the site.yml playbook:

debops site playbooks/custom.yml -l <host>

If you want to run only the custom playbook, you can even do this:

debops custom -l <host>

In the long term, the are plans to upgrade the debops scripts to allow for custom playbooks to be included automatically, among other things. Right now the existing debops script is "good enough" for my needs, I'm more focused on the Ansible roles themselves. So if you want to get a crack at it, feel free to fork the repository. :-)