Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fubarhouse/ansible-role-tester
A small program which will run isolated tests for Ansible roles on a local file system in a Docker container
https://github.com/fubarhouse/ansible-role-tester
ansible docker golang testing-tools
Last synced: 3 months ago
JSON representation
A small program which will run isolated tests for Ansible roles on a local file system in a Docker container
- Host: GitHub
- URL: https://github.com/fubarhouse/ansible-role-tester
- Owner: fubarhouse
- License: mit
- Created: 2018-06-07T12:00:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-07-02T19:15:02.000Z (over 3 years ago)
- Last Synced: 2024-09-30T01:42:47.435Z (3 months ago)
- Topics: ansible, docker, golang, testing-tools
- Language: Go
- Homepage:
- Size: 1.99 MB
- Stars: 18
- Watchers: 3
- Forks: 4
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ansible Role Tester
[![Build Status](https://img.shields.io/travis/fubarhouse/ansible-role-tester/master.svg?style=for-the-badge)](https://travis-ci.org/fubarhouse/ansible-role-tester)
![stability-experimental](https://img.shields.io/badge/stability-experimental-orange.svg?style=for-the-badge)
[![Go Report Card](https://img.shields.io/badge/go%20report-A%2B-brightgreen.svg?style=for-the-badge)](https://goreportcard.com/report/github.com/fubarhouse/ansible-role-tester)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge)](https://raw.githubusercontent.com/fubarhouse/ansible-role-tester/master/LICENSE)This program will allow users to mount [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) 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](https://gist.github.com/samdoran/c3d392ee697881fa33a1d1a65814a07b) by [@samdoran](https://github.com/samdoran) originally inspired by [@geerlingguy](https://github.com/geerlingguy)'s ansible role tester [script](https://gist.github.com/geerlingguy/73ef1e5ee45d8694570f334be385e181).
## Requirements
* [Docker](https://www.docker.com/)
* [Go](https://golang.org/) 1.11 or later may be required if building from source, see installation instructions.## Dependencies
None.
## Installation
### Releases
* Releases will accompany compiled binaries excluding windows executables.### Building from source
```sh
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
```
## UsageAnsible-Role-Tester is based upon the [Cobra command line framework](https://github.com/spf13/cobra).
You can use it by typing `ansible-role-tester`, and by adding `-h` or `--help` you can see additional help.
## Selecting containers for testing
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
````### Custom containers
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:
````sh
# 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
````### Running Ansible role remotely
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.
### Available distributions
| 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 |## Interesting uses.
The following command will execute properly inside a [DrupalVM](https://github.com/geerlingguy/drupal-vm) 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
````## Screenshots
## License
MIT
## Author Information
This tool was created in 2018 by [Karl Hepworth](https://twitter.com/fubarhouse).
**Special thanks** to [@samdoran](https://github.com/samdoran) and [@geerlingguy](https://github.com/geerlingguy) for the original bash scripts and ideas which were used during creation.