A simple Docker image for Ansible
- Git
- Docker
- Clone this repository:
git clone https://github.com/Dgotlieb/Ansible.git
-
In mnt/keys folder - replace the priavte key with your server key (e.g. EC2)
-
In mnt/hosts file - Change the IP address to the IP address of the machine/s you want to control.
-
Start container mounting files:
Mac / Linux users
docker run -it -v $(pwd)/mnt:/opt/ansible dgotlieb/ansible-controller:1.0.0 /bin/bash
Windows users (CMD)
docker run -it -v %cd%/mnt:/opt/ansible dgotlieb/ansible-controller:1.0.0 /bin/bash
- Restrict key permissions:
chmod 400 keys/private.pem
- Validate you can ping your hosts using Ansible:
ansible all -m ping
if you wish to build the Docker image locally, you can run the below commands:
- Build the Docker image:
docker build -t ansible-controller .
- Run the container using:
Mac / Linux users
docker run -it -v $(pwd)/mnt:/opt/ansible ansible-controller /bin/bash
Windows users (CMD)
docker run -it -v %cd%/mnt:/opt/ansible ansible-controller /bin/bash