I have a bunch or docker containers running on my local machine and would like to test ansible on those - acting as my remote hosts.
But I have not been able to find any guides for this. For now I am trying to configure a single container to have SSH enabled using: https://docs.docker.com/engine/examples/running_ssh_service/
but I am struggling with getting that to work. Currently I have
localhost:32768
in /etc/ansible/hosts but it seems it just runs my ansible tasks on my host and not on my running container.
So is it even possible to test ansible on a bunch of docker containers on the same machine?
For local docker connection you can use docker connection plugin.
hosts:
[cont]
container-name1
container-name2
[cont:vars]
ansible_connection=docker
playbook:
- hosts: cont
tasks:
- command: "echo 'hello, container'"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With