This Docker container serves as a isolated testing environment for the development of Ansible roles and Playbooks and is part of a suite Docker images for that purpose. The primary use case is for Molecule testing. It is not intended for production applications.
Included Ansible developement tools
- yamllint
- ansible-lint
- flake8
- testinfra
- molecule
Upstream images will be provided automatically; however, for manual builds, the only pre-requisite is Docker installed on your system and a local checkout of this repo.
cd
to you local checkout of this repo- Run
docker build -t docker-debian10-ansible
ormake dist
These steps are only required if manual, one-off testing is used.
- Pull the image (skip if you manually built it):
docker pull thisisvantaworks/debian10-ansible:latest
- Run the container:
docker run --detach --privileged \
--name docker-debian10-ansible \
--volume=/sys/fs/cgroup:/sys/fs/cgroup:ro \
--volume=`pwd`:/etc/ansible/roles/<role_under_test>:ro \
thisisvantaworks/debian10-ansible:latest
Replace <role_under_test>
with the name of your role.
- Execute
ansible-playbook
thusly:
docker exec -it docker-debian10-ansible \
env TERM=xterm \
ansible-playbook /path/to/ansible/playbook.yml \
--syntax-check
Build the container, and perform the supplied sanity checks by using the all
make target. This is the proceedure used by automated builds to verify the container's functionality.
make all
For Playbook Testing: I highly recommend looking into Molecule
Huge thanks to Jeff Geerling, which much of this repo's content is inspired by.