Tests your ansible roles in multiple operating systems.
Please see the file called INSTALL.md.
- Test ansible roles in operating systems defined in config/default.md
$ ./test.sh
- Test juliendufresne.influxdb role on bento/ubuntu-16.04 vagrant box with debug if something fails
$ ./test.sh --verbose --ansible-role juliendufresne.influxdb --vagrant-box bento/ubuntu-16.04
- Test ansible roles defined in a custom config file defined in config/debian.md
$ ./test.sh --config-file debian
- Test using the config file config/default.md filtering by ansible role
$ ./test.sh --ansible-role juliendufresne.influxdb
- Test using the config file config/default.md filtering by vagrant box
$ ./test.sh --vagrant-box bento/centos7
Tips: First, run your test with a config file then run failed tests manually with the
--verbose
option.
TL;DR RTFM: ./test.sh --help
**`--ansible-role ANSIBLE_ROLE`**
> **Note:** You need to do few things to be able to test any ansible role (see [Adding a role section](#adding-a-role))This option allows to specify which ansible role to test.
You can specify more than one ansible role.
Examples:
$ ./test.sh --ansible-role juliendufresne.influxdb
$ ./test.sh --ansible-role juliendufresne.influxdb --ansible-role juliendufresne.grafana
Note: If you don't specify a vagrant box, the script will search in your configuration file
**`--config-file CONFIG_FILE`** (Recommended)
A configuration file ease repetitive tests by providing a set of (ansible role, vagrant box) to test.The script will run one test for each line in the config file (except the headers).
Basically, a line contains an ansible role, a vagrant box and some options that you would define manually otherwise.
Examples:
$ ./test.sh # will load config/default.md
$ ./test.sh --config-file default # will load config/default.md
$ ./test.sh --config-file /home/julien/debian.md # will load /home/julien/debian.md
Note: The configuration file may be anywhere accessible in your computer. If you specify a relative path, the script will search in:
- your current directory
- the repository root directory
- the repository config directory
Note: You can omit the ".md" extension. This simplify the command line:
./test.sh --config-file default
Note: If you don't specify a configuration file, the script will try to load the config/default.md file
**`--enable-vbguest`**
Some vagrant box needs virtual box guest additions to be installed in order to create a synced folder between your host and the virtual machine.Since it installs some additional packages and hence, slows the tests, it is not installed by default.
Tips: If your test doesn't work the first time, try to enable vbguest and see if it solves the problem.
**`--pre-script PRE_SCRIPT`**
Executes a script in the virtual machine after it is up but before running ansible playbook. For instance, vagrant is not able to install the latest version of ansible in some operating systems (like centos 6). In this case of situation, you can install it manually using this option.Example:
$ ./test.sh --pre-script provision/install_ansible.sh --ansible-role juliendufresne.influxdb --vagrant-box bento/centos6
Note: You can only execute one script.
**`-v`**, **`--verbose`**
Activates the debugging for failed task.Example:
$ ./test.sh -v
$ ./test.sh --verbose --ansible-role juliendufresne.influxdb --vagrant-box bento/centos7
**`--vagrant-box VAGRANT_BOX`**
This option allows to specify a vagrant box to test.
You can specify more than one vagrant box.
Examples:
$ ./test.sh --vagrant-box bento/centos6
$ ./test.sh --vagrant-box bento/centos6 --vagrant-box bento/centos7
Note: If you don't specify an ansible role, the script will search in your configuration file
When you want to test a new role, you need to:
- [ansible galaxy only] add a line in the requirements.yml file.
- create a playbook in the playbooks directory.
The file name must be
<your_role_name>.yml
. For example, for a role name juliendufresne.influxdb, you will need a file playbooks/juliendufresne.influxdb.yml - [local (non galaxy) role] define your role in the playbooks/roles directory
Every tests are reported in a file located in the reports directory.
Reports are grouped by ansible roles.
If you run a test on the same operating system, it will override the previous report.
You can see an example of report in reports/juliendufresne.influxdb.md