adroit - Ansible Docker Role Testing
Heavily opinionated tool for testing Ansible roles using Docker containers.
Assumptions and limitations
These are the current assumptions about your Ansible codebase which might prevent you from using Adroit. They are subject to change or improve.
- You only deploy (or only want to test) on modern systems with systemd as their init system.
- You have a
baserole which other roles can build upon. (If you don't need this, you can just have an emptyroles/basedirectory). - With the exception of depending on the base role, your Ansible roles are atomic, indepentent, and can be applied individually.
include_roleand dependencies defined inmetashould still work, though.
Feel free to open a Github issue about any limitations that prevent you from using Adroit.
How it works
- Adroit builds a core image based on your distro of choice.
- A container based on the core image is created. The
baserole will be applied to the container, and it is saved as the base image. - For each role you want to test, a container based on the base image is started, and the role under test will be applied.
Adroit will check if the role playbook fails, and will also run the playbook a second time to test for idempotency - if there are any changes on the second run, we consider it a failure.
Precautions
To properly test Ansible using Docker containers, systemd needs to be running inside the containers. This requires the containers to run in privileged mode. There is a security risk involved here, check your base images and playbooks accordingly.
Usage
In a virtualenv or whatever you prefer: pip install adroit
In the root directory of your Ansible tree structure, which should at least contain a roles directory, run this command:
adroit -d debian:stretch myrole
Where debian:stretch is the image you want to base your tests on. Currently supported are Debian, Ubuntu and CentOS.
Customizing your roles for testing
Certain tasks simply cannot be ran inside a Docker container - for example, mounting /proc with hidepid=2. You should add a when clause to these tasks. Example:
- when: ansible_virtualization_type != 'docker'
import_tasks: configure_network.yml
If you need certain variables to be set which aren't in defaults or vars but should be set during testing, you can create a file like roles/myrole/testing/test_vars.yml and it will be applied when testing that particular role.
License
The contents of this repository is released under the MIT license. See the LICENSE file included for details.
Metadata
Release files for adroit 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| adroit-0.3.tar.gz | 6.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| adroit-0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.4 kB
Release files / adroit-0.3.tar.gz
| Download URL | adroit-0.3.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a4b7b4ef294f00760dbdd60fe435a9bb8cbf40b8f1ea41253272b085ecea5987
|
|
BLAKE2b-256 checksum How to use checksums |
1bea9d48850821a02571462d354f58ef537153537197b95b95a57e32e0599c7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/0.11.5 CPython/3.7.0 Linux/4.17.0-0.bpo.1-amd64
|
Release files / adroit-0.3-py3-none-any.whl
| Download URL | adroit-0.3-py3-none-any.whl |
|---|---|
| Size | 16.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6501a50c841e82a1b0a41819bb3cf485a7e074de6afb3b2a983b10be1f5cc624
|
|
BLAKE2b-256 checksum How to use checksums |
ef436249a40312b08a516ca5effa66222265c42d0e76bc9f466de05e005d6102
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/0.11.5 CPython/3.7.0 Linux/4.17.0-0.bpo.1-amd64
|
Security for adroit 0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.