Is there an Ansible variable that has the absolute path to the current playbook that is executing?
Some context: I'm running/creating an Ansible script against localhost to configure a MySQL Docker container and wanting to mount the data volume relative to the Ansible playbook.
For example, let's say I've checkout a repository to ~/branch1/ and then I run ansible-playbook dev.yml I was thinking it should save the volume to ~/branch1/.docker_volume/. If I ran it from ~/branch2 then it should configure the volume to ~/branch2/.docker_volume/.
You can use the
playbook_dirvariable.See the documentation about special variables.
For example, given the file structure:
When running playbook.yml, the task:
Would give: