Ansible inside Docker for consistent running of ansible inside local machine or CI/CD system. ansible-docker is based on Will Hall's gorgeous docker-ansible project.
ansible vs ansible-coreAll installs include Mitogen mainly due to the performance improvements that Mitogen awards you. You can read more about it inside the Mitogen for Ansible documentation.
These are the latest Ansible Core versions running within the containers:
Ansible Images| Tag | Dockerfile | Image Size |
|---|---|---|
2.13-alpine | Dockerfile | |
2.13-ubuntu-20.04 | Dockerfile | |
2.13-ubuntu-22.04 | Dockerfile | |
| Tag | Dockerfile | Image Size |
|---|---|---|
2.15-alpine | Dockerfile | |
2.15-ubuntu-22.04 | Dockerfile | |
| Tag | Dockerfile | Image Size |
|---|---|---|
2.16-alpine | Dockerfile | |
2.16-ubuntu-22.04 | Dockerfile | |
kubernetes.core Collection| Tag | Dockerfile | Image Size |
|---|---|---|
2.16-core | Dockerfile | |
| Tag | Dockerfile | Image Size |
|---|---|---|
2.17-alpine | Dockerfile | |
kubernetes.core Collection| Tag | Dockerfile | Image Size |
|---|---|---|
2.17-core | Dockerfile | |
| Tag | Dockerfile | Image Size |
|---|---|---|
2.18-alpine | Dockerfile | |
kubernetes.core Collection| Tag | Dockerfile | Image Size |
|---|---|---|
2.18-core | Dockerfile | |
To leverage Mitogen to accelerate your playbook runs, add this to your ansible.cfg:
Please investigate in your container the location of ansible_mitogen (it is different per container). You can do this via:
your_container="ansible-docker:2.18-alpine"
docker run --rm -it "barisgece/${your_container}" /bin/sh -c "find / -type d | grep "ansible_mitogen/plugins" | sort | head -n 1"
and then configuring your own ansible.cfg like:
[defaults]
strategy_plugins = /usr/local/lib/python3.6/site-packages/ansible_mitogen/plugins/
strategy = mitogen_linear
$~ docker buildx build --platform linux/amd64,linux/arm64 -t barisgece/ansible-docker:2.18-alpine --push . # or --load .
$~ docker buildx build --platform linux/amd64,linux/arm64 -t barisgece/ansible-docker:2.18-core --push . # or --load .
You will likely need to mount required directories into your container to make it run (or build on top of what is here).
$~ docker run --rm -it barisgece/ansible-docker:2.18-alpine /bin/sh
$~ docker run --rm -it -v $(pwd):/ansible -v ~/.ssh/id_rsa:/root/id_rsa barisgece/ansible-docker:2.18-alpine /bin/sh
$~ docker run --rm -it -v $(pwd):/ansible -v ~/.ssh/id_rsa:/root/id_rsa barisgece/ansible-docker:2.18-alpine ansible-playbook playbook.yml
You can put these inside your dotfiles (~/.bashrc or ~/.zshrc to make handy aliases).
alias docker-ansible-cli='docker run --rm -it -v $(pwd):/ansible -v ~/.ssh/id_rsa:/root/.ssh/id_rsa --workdir=/ansible barisgece/ansible-docker:2.18-alpine /bin/sh'
alias docker-ansible-cmd='docker run --rm -it -v $(pwd):/ansible -v ~/.ssh/id_rsa:/root/.ssh/id_rsa --workdir=/ansible barisgece/ansible-docker:2.18-alpine'
use with:
$~ docker-ansible-cli ansible-playbook -u playbook.yml
docker-ansible base project creator Will Hall - GitHubContent type
Image
Digest
sha256:8a3d57379…
Size
74.2 MB
Last updated
over 3 years ago
docker pull barisgece/ansible-docker