Over a year ago, I wrote about the possibility to create a YAML/Bash hybrid
file, that contains YAML configuration settings and a bash executable
Lately, I started using a slight modification of this that allows to execute
ansible playbooks with
./playbook.yaml as if they were executables.
The heart of this workflow is the command-line tool
we want to pass additional arguments to the command when invoking a playbook,
--ask-vault-pass, or a custom
Adding the shebang line
will not work. By default, the full line is taken as the name of the executable,
including the space and the arguments.
Therefore, to work around this limitation, we need to create an additional bash
#!/bin/bash ansible-playbook --ask-vault-pass "$@"
Add whatever argument you need. The script acts as a slim wrapper with the sole
purpose to add additional arguments. The path of the playbook is passed via
The final piece, is the appropriate shebang line for the playbook, e.g.,
#!/path/to/ansible-deploy - hosts: - all tasks: - ping:
This might also interest you