Skip to main content

Molecule Hetzner Cloud Plugin :: run molecule tests with hetzner cloud

Project description

Molecule Hetzner Cloud Plugin

Drone CI-CD PyPI Package Repository License

A Hetzner Cloud plugin for Molecule.

This plugin allows you to do molecule init role myrolename -d hetznercloud and have Molecule provision on-demand Hetzner Cloud VPSes of your choice for your integration testing. New VPSes will be automagically created and provisioned on each molecule test run, SSH keys are generated and managed internally and all resources are cleaned up regardless of whether the role under test succeeds or fails.

Support

If you use this plugin in a commercial setting or you find it personally useful, please support my maintenance work financially through my Liberapay profile or through my Github Sponsor profile. I do not receive any financial support from RedHat or Hetzner Cloud for this work.

Usage

You need to expose a HCLOUD_TOKEN environment variable in your environment.

Find out more about how to get one of those over here.

$ export HCLOUD_TOKEN=mycoolapitoken

Then install the required Python package.

$ pip install molecule-hetznercloud
$ molecule init role myrolename -d hetznercloud

Your myrolename/molecule/default/molecule.yml should then look like the following.

---
dependency:
  name: galaxy
driver:
  name: hetznercloud
platforms:
  - name: instance
    server_type: cx11
    image: debian-10
provisioner:
  name: ansible
verifier:
  name: ansible

Please see docs.hetzner.cloud for information regarding images and server types.

Then just run the role.

$ cd myrolename && molecule test

To ease initial debugging for getting things started, also expose the following environment variables.

$ export MOLECULE_NO_LOG=False  # not so verbose, helpful
$ export MOLECULE_DEBUG=True  # very verbose, last ditch effort

Volume Handling

It is possible to have the driver manage volumes during the test run.

You can add the following stanza to your Molecule configuration to have Molecule create this volume for the managed VPS. This volume will be cleaned up after use.

volumes:
  - name: "molecule-hetznercloud-volume-1-${INSTANCE_UUID}"
  - name: "molecule-hetznercloud-volume-2-${INSTANCE_UUID}"

Supported keys are:

  • name (required): name of volume
  • size (optional, default: 10GB): size of volume
  • location (optional, default: omitted): path for volume

Only use molecule.yml for configuration

It is being worked on that it is possible to remove all the files except the molecule.yml scenario file in your scenario directory. This is useful when you only require this plugin to do the default behaviour each time. It is also useful to reduce maintenance effort for migration of configurations. This plugin currently embeds the create.yml and destroy.yml playbooks. All other playbooks (e.g. prepare, cleanup) can be created as needed and Molecule will pick them up and run them. Embedding the converge.yml awaits this feature request.

Mirroring

Issues will be responded to on both issue trackers.

Change log

See CHANGELOG.md.

Molecule Documentation

https://molecule.readthedocs.io

Contact

  • Ping @decentral1se on the #ansible-molecule channel on Freenode.

License

The LGPLv3 license.

Testing

This is all done on our drone.autonomic.zone setup.

Unit

$ pip install tox
$ tox -v

Integration

Only doable by Autonomic Cooperative members.

$ sudo apt install -y direnv
$ cp .envrc.sample .envrc
$ direnv allow
$ pip install -e .
$ cd integration && molecule test

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

molecule-hetznercloud-1.0.0.tar.gz (26.3 kB view details)

Uploaded Source

Built Distribution

molecule_hetznercloud-1.0.0-py2.py3-none-any.whl (31.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file molecule-hetznercloud-1.0.0.tar.gz.

File metadata

  • Download URL: molecule-hetznercloud-1.0.0.tar.gz
  • Upload date:
  • Size: 26.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.0

File hashes

Hashes for molecule-hetznercloud-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d288dd7310fa802bb016e9717f94065b401a7904f9df2736695d545ed2c3610f
MD5 f914150147fc45793cb78a134d22c5a1
BLAKE2b-256 501e5fd63bc5f49bb02e601026138bd2e5d6cf3a97ef94e60af11521db304467

See more details on using hashes here.

File details

Details for the file molecule_hetznercloud-1.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: molecule_hetznercloud-1.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 31.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.0

File hashes

Hashes for molecule_hetznercloud-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 cd40ed35fb7d98fe790229f5f692258b49717dec13cb90cbb213ade7b273a018
MD5 a304c9a0f97cbb7f50fd12587fa885b4
BLAKE2b-256 30f25b2201c1c708fed95d7ae603b9f166204e11b33c67f71cdaa65dcbc42f11

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