This program will allow users to mount Ansible roles into isolated Docker images for testing typically achieved using CI tools such as Travis CI.
The goal of this project is to facilitate better localized testing, which will secure greater success rates for development and idempotence before pushing to a public state.
This self-contained command line tool is inspired from a script by @samdoran originally inspired by @geerlingguy's ansible role tester script.
None.
- Releases will accompany compiled binaries excluding windows executables.
git clone https://github.com/fubarhouse/ansible-role-tester.git
cd ansible-role-tester
GO111MODULE=on go mod download
GO111MODULE=on go build .
mv ansible-role-tester /usr/bin/ansible-role-tester
Ansible-Role-Tester is based upon the Cobra command line framework.
You can use it by typing ansible-role-tester
, and by adding -h
or --help
you can see additional help.
By entering user names and distributions available declared in the distributions.go
file, you can selectively target any of them.
Example use:
ansible-role-tester full -u $USER -t $DISTRO
In the event you need to use an unsupported image, you can specify --custom
with the --image
, --initialise
and the --volume
flag which have sensible defaults.
Example of usage:
# Example:
ansible-role-tester full --custom --image $IMAGE --initialise $INIT --volume $VOLUME
# Practical example:
ansible-role-tester full --custom --image webdevops/ansible:latest --initialise /bin/systemd --volume /sys/fs/cgroup:/sys/fs/cgroup:ro
By specifying to run the task remotely with --remote
, the test playbooks will run directly from the host to the guest using an inventory and the docker connector.
This allows you to only have the nessisary software on the host, in the event you need to test a role against any unsupported image.
user | distro | image |
---|---|---|
fubarhouse | centos6 | fubarhouse/docker-ansible:centos-6 |
fubarhouse | centos7 | fubarhouse/docker-ansible:centos-7 |
fubarhouse | debian7 | fubarhouse/docker-ansible:wheezy |
fubarhouse | debian8 | fubarhouse/docker-ansible:jessie |
fubarhouse | debian9 | fubarhouse/docker-ansible:stretch |
fubarhouse | debian10 | fubarhouse/docker-ansible:buster |
fubarhouse | fedora24 | fubarhouse/docker-ansible:fedora-24 |
fubarhouse | fedora25 | fubarhouse/docker-ansible:fedora-25 |
fubarhouse | fedora26 | fubarhouse/docker-ansible:fedora-26 |
fubarhouse | fedora27 | fubarhouse/docker-ansible:fedora-27 |
fubarhouse | fedora28 | fubarhouse/docker-ansible:fedora-28 |
fubarhouse | ubuntu1204 | fubarhouse/docker-ansible:precise |
fubarhouse | ubuntu1210 | fubarhouse/docker-ansible:quantal |
fubarhouse | ubuntu1304 | fubarhouse/docker-ansible:raring |
fubarhouse | ubuntu1310 | fubarhouse/docker-ansible:saucy |
fubarhouse | ubuntu1404 | fubarhouse/docker-ansible:trusty |
fubarhouse | ubuntu1410 | fubarhouse/docker-ansible:utopic |
fubarhouse | ubuntu1504 | fubarhouse/docker-ansible:vivid |
fubarhouse | ubuntu1510 | fubarhouse/docker-ansible:wily |
fubarhouse | ubuntu1604 | fubarhouse/docker-ansible:xenial |
fubarhouse | ubuntu1610 | fubarhouse/docker-ansible:yakkety |
fubarhouse | ubuntu1704 | fubarhouse/docker-ansible:zesty |
fubarhouse | ubuntu1710 | fubarhouse/docker-ansible:artful |
fubarhouse | ubuntu1804 | fubarhouse/docker-ansible:bionic |
fubarhouse | ubuntu1810 | fubarhouse/docker-ansible:cosmic |
geerlingguy | centos6 | geerlingguy/docker-centos6-ansible:latest |
geerlingguy | centos7 | geerlingguy/docker-centos7-ansible:latest |
geerlingguy | debian8 | geerlingguy/docker-debian8-ansible:latest |
geerlingguy | debian9 | geerlingguy/docker-debian9-ansible:latest |
geerlingguy | fedora24 | geerlingguy/docker-fedora24-ansible:latest |
geerlingguy | fedora27 | geerlingguy/docker-fedora27-ansible:latest |
geerlingguy | ubuntu1204 | geerlingguy/docker-ubuntu1204-ansible:latest |
geerlingguy | ubuntu1404 | geerlingguy/docker-ubuntu1404-ansible:latest |
geerlingguy | ubuntu1604 | geerlingguy/docker-ubuntu1604-ansible:latest |
geerlingguy | ubuntu1804 | geerlingguy/docker-ubuntu1804-ansible:latest |
The following command will execute properly inside a DrupalVM clone, however it won't include the configuration variables, but it's an interesting case which proves how flexible this tool can be.
ansible-role-tester full -p ../provisioning/playbook.yml -u fubarhouse -t centos7 -r provisioning/requirements.yml
MIT
This tool was created in 2018 by Karl Hepworth.
Special thanks to @samdoran and @geerlingguy for the original bash scripts and ideas which were used during creation.