Skip to main content

Auto-generate environments for molecule role testing

Project description

# tox-ansible-collection This plugin for tox auto-generates tox environments for running Molecule against roles within an Ansible Collection. Optionally, you can then elect to filter the environments down to only a subset of them. The tool is rather well integrated for the official [Molecule](https://github.com/ansible/molecule) testing tool that integrates with [Ansible](https://github.com/ansible/ansible).

## More details This plugin is designed to support auto-discovery of roles and their scenarios in an Ansible collection repository. When it has done so, the plugin will then create a tox environment, if one does not already exist, that contains two factors matching against the role and scenario names. For example, if you have two roles named “user” and “group” and the “user” role has a scenario named “default” while the “group” role has scenaiors named “default” and “fedora”, then this will auto-configure tox environments named [‘user-default’, ‘group-default’, ‘group-fedora’].

Additional configuration options exsit to expand this matrix automatically. For instance, you can have it auto-generate version with tox factors for different versions of python (e.g. [‘py27-user-default’, ‘py38-user-default’]). Additional options can also be added for different versions of Ansible (e.g. [‘ansible27-user-default’, ‘ansible28-user-default’])

There are also options to filter the list of environment variables executed, after all the generation matrix has been realized. The execution can be filtered to limit itself to only a particular role, only a particular scenario, only scenarios that operate on a particular driver, or any combination of those.

If an environment already exists that matches both the rolename and scenario factors, then this plugin will not modify their configuration. Thus, if you need to customize a particular run, then you can do so, but still take advantage of the filtering options and auto-generation of the environments for other scenarios.

## Under the hood The plugin will first look for a “galaxy.yml” file in the root of the execution. If it doesn’t find this, then it won’t affect your run.

Next, the plugin looks inside of the “roles” directory and finds any subdirectories that contain a file in the “tasks/main.yml” location. This is, technically, the only file required for an Ansible role.

Inside of every role folder, the plugin then looks for molecule/*/molecule.yml files and globs those together.

It then generates new environments for any discovered (role, scenario) pairs that do not already exist in the tox environment list (based on a name that includes “{role}-{scenario}”) and adds these to the default execution envlist with a dependency on Molecule. This list will be expanded by any configured matrix axes with appropriate dependencies and configurations made. Each one will execute the command “molecule test -s {scenario}” if it passes the filter step.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tox-ansible-0.2.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

tox_ansible-0.2-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file tox-ansible-0.2.tar.gz.

File metadata

  • Download URL: tox-ansible-0.2.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.5

File hashes

Hashes for tox-ansible-0.2.tar.gz
Algorithm Hash digest
SHA256 1ef0843fbbb01f807442af26eae6bd0e45d6c91804b5e38614df0a7be90454bd
MD5 bd6b64f90be22c0021df95425b83bf92
BLAKE2b-256 b88619dce024f3aae3e4edfade1019b3437b0cbd9b7dced2257c378c858e98db

See more details on using hashes here.

File details

Details for the file tox_ansible-0.2-py3-none-any.whl.

File metadata

  • Download URL: tox_ansible-0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.5

File hashes

Hashes for tox_ansible-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f772957a581edd50063672a62b1f4f45046bd26de2ebf2175a5f2d28c3764ac6
MD5 df10622800794024d2f13383cbe5e6bc
BLAKE2b-256 663ed8b62ac01c42c43aff852f0dc890297e37d46791d743f1d0744c9af68d54

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page