chriswayg/docker-alpine-ansible
Alpine Linux Docker container for Ansible playbook and role testing.
4.8K
Alpine Linux (latest) Docker container for Ansible playbook and role testing.
This image is built on Docker Hub automatically any time a commit is made or merged to the master
branch. But if you need to build the image on your own locally, do the following:
cd
into the repository directory.docker build -t local-alpine-ansible .
Pull this image from Docker Hub: docker pull chriswayg/docker-alpine-ansible
(or use the tag you built earlier, e.g. local-alpine-ansible
).
Run a container from the image: (to test my Ansible roles, I add in a volume mounted from the current working directory).
docker run --detach --privileged --name alpine_ansible_1 \
--volume=$(pwd):/etc/ansible/roles/role_under_test:rw \
chriswayg/docker-alpine-ansible
Use Ansible inside the container:
- docker exec --tty alpine_ansible_1 ansible --version
- docker exec --tty alpine_ansible_1 ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check
- docker exec --tty alpine_ansible_1 ansible-playbook -vv /etc/ansible/roles/role_under_test/tests/test.yml
I use Docker to test my Ansible roles and playbooks on multiple OSes using CI tools like Travis. This container allows me to test roles and playbooks using Ansible running locally inside the container.
Important Note: I use this image for testing in an isolated environment — not for production — and the settings and configuration used may not be suitable for a secure and performant production environment. Use on production servers at your own risk!
docker-{distro}-ansible
docker pull chriswayg/docker-alpine-ansible