Skip to main content

Ansible Developers Box

Project description

andebox

Ansible Developer's (tool)Box, andebox, is a script to assist Ansible developers by encapsulating some boilerplate tasks. One of the core features is the ability to run ansible-test on a local copy of a collection repository without having to worry about setting environment variables nor having the expected directory structure above the collection directory.

It also allows some basic stats gathering from the tests/sanity/ignore-X.Y.txt files.

Installation

Install it as usual:

pip install andebox

Requirements

  • ansible-core for actions test and tox-test
  • pyyaml for reading galaxy.yml
  • distutils for comparing LooseVersion objects for action ignore
  • vagrant for action vagrant
    • andebox and any other dependency must be installed inside the VM, but that setup is the user responsibility

Setup-less ansible-test

No need to clone in specific locations or keep track of env variables. Simply clone whichever collection you want and run the ansible-test command as:

# Run sanity test(s)
$ andebox test -- sanity --docker default --test validate-modules plugins/modules/mymodule.py

# Run sanity test(s) excluding the modules listed in the CLI from the sanity 'ignore-X.Y.txt' files
$ andebox test -ei -- sanity --docker default --test validate-modules plugins/modules/mymodule.py

# Run unit test(s)
$ andebox test -- unit --docker default test/units/plugins/modules/mymodule.py

# Run integration test
$ andebox test -- integration --docker default mymodule

# Run tests in multiple Ansible versions using tox
$ andebox tox-test -- sanity --docker default --test validate-modules plugins/modules/mymodule.py
$ andebox tox-test -- unit --docker default test/units/plugins/modules/mymodule.py
$ andebox tox-test -- integration --docker default mymodule

# Run tests in multiple specific Ansible versions using tox
$ andebox tox-test -e ac211,ac212 -- unit --docker default test/units/plugins/modules/mymodule.py     # ansible-core 2.11 & 2.12 only
$ andebox tox-test -e a4,dev -- integration --docker default mymodule                                 # ansible 4 & development branch

By default, andebox will discover the full name of the collection by parsing the galaxy.yml file found in the local directory. If the file is not present or if it fails for any reason, use the option --collection to specify it, as in:

$ andebox test --collection community.general -- sanity --docker default -v --test validate-modules

Please notice that andebox uses whichever ansible-test is available in PATH for execution

Stats on ignore files

Gathering stats from the ignore files can be quite annoying, especially if they are long. One can run:

$ andebox ignores -v2.10 -d4 -fc '.*:parameter-list-no-elements'
    24  plugins/modules/ovirt validate-modules:parameter-list-no-elements
     8  plugins/modules/centurylink validate-modules:parameter-list-no-elements
     6  plugins/modules/redfish validate-modules:parameter-list-no-elements
     5  plugins/modules/oneandone validate-modules:parameter-list-no-elements
     4  plugins/modules/rackspace validate-modules:parameter-list-no-elements
     4  plugins/modules/oneview validate-modules:parameter-list-no-elements
     3  plugins/modules/opennebula validate-modules:parameter-list-no-elements
     3  plugins/modules/univention validate-modules:parameter-list-no-elements
     3  plugins/modules/consul validate-modules:parameter-list-no-elements
     3  plugins/modules/sensu validate-modules:parameter-list-no-elements

Runtime config

Quickly peek what is the runtime.yml status for a specific module:

$ andebox runtime scaleway_ip_facts
D modules scaleway_ip_facts: deprecation in 3.0.0 (current=2.4.0): Use community.general.scaleway_ip_info instead.

Or using a regular expression:

$ andebox runtime -r 'gc[pe]'
R lookup gcp_storage_file: redirected to community.google.gcp_storage_file
T modules gce: terminated in 2.0.0: Use google.cloud.gcp_compute_instance instead.
R modules gce_eip: redirected to community.google.gce_eip
R modules gce_img: redirected to community.google.gce_img
R modules gce_instance_template: redirected to community.google.gce_instance_template
R modules gce_labels: redirected to community.google.gce_labels
R modules gce_lb: redirected to community.google.gce_lb
R modules gce_mig: redirected to community.google.gce_mig
R modules gce_net: redirected to community.google.gce_net
R modules gce_pd: redirected to community.google.gce_pd
R modules gce_snapshot: redirected to community.google.gce_snapshot
R modules gce_tag: redirected to community.google.gce_tag
T modules gcp_backend_service: terminated in 2.0.0: Use google.cloud.gcp_compute_backend_service instead.
T modules gcp_forwarding_rule: terminated in 2.0.0: Use google.cloud.gcp_compute_forwarding_rule or google.cloud.gcp_compute_global_forwarding_rule instead.
T modules gcp_healthcheck: terminated in 2.0.0: Use google.cloud.gcp_compute_health_check, google.cloud.gcp_compute_http_health_check or google.cloud.gcp_compute_https_health_check instead.
T modules gcp_target_proxy: terminated in 2.0.0: Use google.cloud.gcp_compute_target_http_proxy instead.
T modules gcp_url_map: terminated in 2.0.0: Use google.cloud.gcp_compute_url_map instead.
R modules gcpubsub: redirected to community.google.gcpubsub
R modules gcpubsub_info: redirected to community.google.gcpubsub_info
R modules gcpubsub_facts: redirected to community.google.gcpubsub_info
R doc_fragments _gcp: redirected to community.google._gcp
R module_utils gce: redirected to community.google.gce
R module_utils gcp: redirected to community.google.gcp

where D=Deprecated, T=Tombstone, R=Redirect.

Run Integration Tests in Vagrant VMs

To run the test inside a VM managed by vagrant:

# Run test in VM named "fedora37" using sudo
$ andebox vagrant -n fedora37 -s -- --python 3.9 xfs_quota --color yes

Also beware that andebox does not create nor manage Vagrantfile. The user is responsible for creating and setting up the VM definition. It must have andebox and ansible-core (or ansible-base or ansible) installed on a virtual environment. By default, the venv is expected to be at /venv but the localtion can be specified using the --venv parameter.

Project details


Release history Release notifications | RSS feed

This version

0.49

Download files

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

Source Distribution

andebox-0.49.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

andebox-0.49-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file andebox-0.49.tar.gz.

File metadata

  • Download URL: andebox-0.49.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/6.2.0-1012-lowlatency

File hashes

Hashes for andebox-0.49.tar.gz
Algorithm Hash digest
SHA256 a78b058337d3db99b29b61b755224ae4b3de13e7d67ee7c82dc4f684460d6d46
MD5 9ea7585d70900976e341d7692a6afb56
BLAKE2b-256 28cde216108f0a5b88b052fab7199a51344fd81518f402d9ba8c3399ac728f49

See more details on using hashes here.

File details

Details for the file andebox-0.49-py3-none-any.whl.

File metadata

  • Download URL: andebox-0.49-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/6.2.0-1012-lowlatency

File hashes

Hashes for andebox-0.49-py3-none-any.whl
Algorithm Hash digest
SHA256 047562f85a53ad34b80e4a01737ac570f13125788c13c84ef2ed7a8458779ea9
MD5 536174eed0af9f9b509ac10df1da93c4
BLAKE2b-256 ab05a1cf5ffa31c21e4ae2d5911297a027e25a38c5d49340b5c7fa0402172e12

See more details on using hashes here.

Supported by

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