Dockerized Ubuntu Artful (17.10) for Ansible playbook and role tests.
This image is intended solely for automated testing of Ansible playbooks and roles as a local process inside a container running on a CI server such as Jenkins or Travis. It is neither configured nor intended for use in any secure or production environment, and any use is at your own risk.
First, Install Docker, then choose which image to use.
Any time a commit is merged to the master
branch of this repo, or any time there is a rebuild of the upstream OS container, an Automatic Build will occur on Docker Hub. You can use this be pulling the image to your local machine:
sudo docker pull yawpitch/docker-ansible-ubuntu-artful:latest
For convenience, a make pull
target has been provided to do this for you. You can also both pull & verify the current Docker Hub image with the following command:
make test-hub
This will ensure that a container launched with from the image at minimum contains the ansible
command.
If you wish to build the image on your local machine, git clone
this repo, cd
into the repo, and then run:
sudo docker build -t docker-ansible-ubuntu-artful .
For convenience, a make build
target has been provided to do this for you. You can also both build & verify a local image of the current repo with the following command:
make test-local
This will ensure that a container launched with from the image at minimum contains the ansible
command.
First, Run a container from the image:
docker run --detach --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro [IMAGE NAME]:latest
To test Ansible roles, add in a volume mounted from the current working directory of the role:
docker run --detach --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro --volume=`pwd`:/etc/ansible/roles/role_under_test:ro [IMAGE NAME]:latest
Then use docker exec
to acccess Ansible inside the container:
docker exec --tty [container_id] env TERM=xterm ansible --version
docker exec --tty [container_id] env TERM=xterm ansible-playbook /path/to/ansible/playbook.yml --syntax-check
Maintained by Michael Morehouse (yawpitch), slightly modified from the work of Jeff Geerling, author of Ansible for DevOps.