willhallonline / docker-ansible

Ansible inside Docker containers: Alpine, Ubuntu, Rocky & Debian with Ansible 2.16, 2.15, 2.14, 2.13, 2.12, 2.11, 2.10 and 2.9 + Mitogen
https://www.willhallonline.co.uk/project/docker/docker-ansible/
MIT License
376 stars 135 forks source link

Unable to obtain the current directory #73

Open xphsc opened 7 months ago

xphsc commented 7 months ago

image

image

willhallonline commented 7 months ago

Unfortunately, I don't have enough context to understand why this doesn't work. Can you let me know what commands you are running and how you are mounting the docker container. What it looks like it is doing is loading the "/ansible" directory (which is the default) and then you should be mounting your "playbook-resources" into that.

Does this happen on all tasks or just one?

xphsc commented 7 months ago

usage docker run --rm -it -v ~/.ssh/id_rsa:/root/.ssh/id_rsa -v ~/.ssh/id_rsa.pub:/root/.ssh/id_rsa.pub -v $(pwd):/ansible willhallonline/ansible:latest ansible-playbook -i ...

willhallonline commented 6 months ago

OK, so if you are using:

docker run --rm -it
-v ~/.ssh/id_rsa:/root/.ssh/id_rsa
-v ~/.ssh/id_rsa.pub:/root/.ssh/id_rsa.pub
-v $(pwd):/ansible
willhallonline/ansible:latest
ansible-playbook -i

This should work. I guess that I don't really know where {{ playbook_dir }} is being used, however, I would expect that it is operating either without the directory being mounted, or it is looking somewhere else for it.

xphsc commented 6 months ago

The directory exists, how can we obtain it? It is possible to use ansible natively on a Linux server, but it cannot be obtained using this Docker version of ansible

image