I want to run an ansible playbook locally (host is localhost, like -i "localhost,"
) and inside the Playbook obtain the working directory from which the ansible-playbook
command was invoked.
However, when I read out the current working directory in a playbook task, I get the directory of the playbook itself.
Is there any variable I can refer to to obtain the working directory on the controlling host (which is localhost) in my case?
I can inject via a variable -e
but I would prefer to have a fall-back that if that variable is not set I can obtain it from the ([local]host) environment.
-e project_dir="$(pwd -P)"
in a shell script, did hope to come away from that.