Variable that has the path to the current ansible-playbook that is executing?

Question:

Is there an ansible variable that has the absolute path to the current ansible-playbook that is executing?

some context:
I’m running/creating an ansible script against localhost to configure a mysql docker and wanting to mount the data volume relative to the ansible script.

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/.

Answer:

You can use playbook_dir variable.

Leave a Reply