Skip to content

pgrange/role_unit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build status : Build Status

role_unit

The goal of this project is to test your ansible system automation. Its goal is basically to test ansible roles, but role_unit’s own tests are an example of an other usage that can be made.

prerequisites

usage

To create a new role tested with role_unit, place yourself in the directory where you want the role and run role_unit:

cd /my/ansible/dir/roles
/path/to/role_unit my_role

This will create an empty role with the testing tools in the tests directory. A default tests file is created that run on the default container (debian9). To adapt the used distribution set the RU_ENV_IMAGE variable (see below).

You have a list of functions you can call in your test file, described below.

ru_init

Initiates testing environment, i.e. creates containers or virtual machines depending on configuration.

ru_ansible_init

Initiates ansible inventory and playbook necessary to test your ansible role.

ru_run_ansible

Actually run ansible-playbook on your testing environment.

ru_run [ -n N ] cmd …​

Runs the specified command on all of the servers or just on the one specified. N is the number of the server you want to run the command on.

ru_ansible_fact [ -n N ] fact_name…​

Returns the specified ansible fact for all of the servers or just on the one specified. N is the number of the server you want to get the fact from.

parameters

Plumb_unit behaviour can be changed using environment variables: * RU_ENV_NAME defines the testing environment name. It is the name of the role you will test. * RU_ENV_IMAGE defines the system image used to create test environment. * RU_COUNT sets the number of containers or virtual machines

tests

prerequisites

Role_unit is tested with role_unit, so preprequisites are the same.

run

to run the tests, you will have to launch:

tests/bash_unit tests/tests*

About

Test your ansible doc

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages