jmal98 / ansiblecm

A Docker based Ansible control machine for running playbooks in a consistent environment.
Apache License 2.0
42 stars 25 forks source link

How to use it without running playbooks directly #4

Closed ricardogaspar2 closed 3 years ago

ricardogaspar2 commented 6 years ago

Hi, I was looking for a docker image with all the needed software to run an ansible CM and I found yours. But I noticed that I couldn't log in to the container directly (via bash: $ docker run -it jmal98/ansiblecm bash) only execute commands/playbooks directly.

Is there a way to access the container via bash and do whatever I need (like changing the inventory, install modules, add playbooks, etc.) ?

Thanks in advance.

jmal98 commented 6 years ago

Hi, thanks for considering this image for your tasks.

The way this image is built, the playbook is bind mounted in from the host so there shouldn't be a need to login to the container while its running to perform modifications. The container is expected to be 100% ephemeral and all updates to the playbook are made on the host.

If you want to connect to a running instance of this container image, you could use docker exec -it CONTAINER_ID sh which will open up a shell in it where you can perform any tasks to that container. Just keep in mind that any changes you make will not be persisted. If you would like to make permanent changes to the image, simply create a new image using this one as a base in your Dockerfile (i.e. FROM jmal98/ansiblecm:2.6.1).

If you haven't done so already, you can give the https://github.com/jmal98/ansiblecm/blob/master/DEMO.md a try locally as it demonstrates how to use this image against a set of Docker containers acting as "machines" and you can get a feel for how the playbook can be modified locally and executed against the "machines" using this image.

lilasquared commented 5 years ago

@jmal98 is it possible to use this container to create encrypted strings for use with ansible-vault?

lilasquared commented 5 years ago

nevermind the answer is yes :+1: