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

WORKDIR /ansible in the Dockerfile #2

Closed eill closed 4 years ago

eill commented 5 years ago

Hello, William!

The documentation for your image recommends mounting playbook directory to the /ansible path, but the workdir in the docker image is set to the /, so to execute playbook we need to call "ansible-playbook /ansible/playbook.yml".

Unfortunately, ansible looks for config files into $(pwd) and predefined config dirs, and thus we need explicitly mount all the configuration files (like ansible.cfg) to the /etc/ansible or other default search directories. What do you think about changing WORKDIR in the Dockerfiles to the /ansible?

I think it may be useful, but I'm not sure how it would affect the existing pipelines, so I'm not submitting a PR yet.

willhallonline commented 5 years ago

Hey Timur. This, I guess depends on the structure of your projects. I normally have an ./ansible directory inside projects so I can keep other things in the project, however, it may make more sense to do it from the local directory that you are in. I will look at changing it, I don't believe that it should make that much impact on others.

willhallonline commented 5 years ago

I should also add. Thanks for raising the issue and contributing. 😄 👍