1

I'm trying to create a custom docker image using a Dockerfile. In my Dockerfile I have installed ansible and I can confirm this works from earlier experience, but when I am using the command ansible-galaxy to install a specific role or collection (collection in this case) it is NOT stored in the installed path.

OUTPUT FROM DOCKER BUILD:

(Previous steps works)
     ...
Step 11/11 : RUN ansible-galaxy collection install community.vmware
 ---> Running in e222fee67b89
Process install dependency map
Installing 'community.vmware:1.1.0' to '/home/me/.ansible/collections/ansible_collections/community/vmware'

When I try to run a container from this image the path /home/me/.ansible/collections/ansible_collections/community/vmware does not exists, so after running the container I have to use the docker exec and manually run the command ansible-galaxy collection install community.vmware.


Any help would be greatly appreciated.

Thanks.

user1098490
  • 478
  • 1
  • 4
  • 16

1 Answers1

1

Instead of running the ansible-galaxy command when building the image itself, I pull the ansible collection to my computer from GitHub and copy the collection to /usr/share/jenkins/ref/. Following the Jenkins docker documentation.

COPY .ansible/collection  /usr/share/jenkins/ref/

The jenkins docker image is built with a script which copies the files from the /usr/share/jenkins/ref/ directory to the jenkins home directory.

user1098490
  • 478
  • 1
  • 4
  • 16