GithubHelp home page GithubHelp logo

issmirnov / ansible-role-tester Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fubarhouse/ansible-role-tester

0.0 3.0 0.0 1.99 MB

A small program which will run isolated tests for Ansible roles on a local file system in a Docker container

License: MIT License

Go 100.00%

ansible-role-tester's Introduction

Ansible Role Tester

Build Status stability-experimental Go Report Card MIT licensed

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.

Requirements

  • Docker
  • Go 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

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

Usage

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.

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:

# 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 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.

Special thanks to @samdoran and @geerlingguy for the original bash scripts and ideas which were used during creation.

ansible-role-tester's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar fubarhouse avatar issmirnov avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.