> I'm almost surprised that you can't add a shebang line pointing to Ansible at the top of your YAML.
You actually can do that, with something like:
#!/usr/bin/env ansible-playbook
---
- hosts: localhost
tasks:
- debug: var=ansible_distribution_release
It works pretty nicely, just remember to make your playbook file executable. It's a bit cumbersome though since you cannot use `ansible-playbook` arguments like `--limit`, `--diff`, `--check` and so on to have better control over the playbook execution.
Ansible really should have ditched the YAML format a long time ago. The YAML is practically designed to be executable; I'm almost surprised that you can't add a shebang line pointing to Ansible at the top of your YAML. I'm actually a little surprised they've never offered an option to write parts of your Ansible setup in Python.
I would love to make some of my roles and my playbook into Python code. I am forever googling the syntax to set up a loop in Ansible YAML, as well as how to make dependencies between roles, which is pretty cleanly solved with Python modules (just import and execute the role at the top of your new role).