Molecule Hetzner Cloud driver plugin
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
decentral1se 3617624623
Merge pull request #28 from aminvakil/patch-1
3 weeks ago
.github Add missing header 12 months ago
integration Fixup volume creation functionality 3 months ago
molecule_hetznercloud Appease linter 3 months ago
.drone.yml Install Ansible for integration testing 3 months ago
.envrc.sample Fixup envrc.sample with missing env var 1 year ago
.gitignore Testing configuration cleanup 1 year ago
.pre-commit-config.yaml Fix linters 1 year ago
.yamllint.yml Remove Molecule project cruft 1 year ago Typo fix 3 weeks ago
LICENSE Relicense to LGPL 1 year ago
Makefile Remove cruft and shorten dir name 1 year ago Install ansible now 3 months ago
pyproject.toml Shape up package configuration and update deps 1 year ago
pytest.ini Ignore those warnings 1 year ago
setup.cfg Relax molecule bounds 3 weeks ago Testing configuration cleanup 1 year ago
tox.ini Py39, Molecule 3.2.1 and dep tree upgrade 3 months ago

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.


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.


$ pip install molecule-hetznercloud


Please see the for migration guides.

$ pip install --upgrade molecule-hetznercloud


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 create a role using the driver plugin.

$ molecule init role myrolename -d hetznercloud

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

  name: galaxy
  name: hetznercloud
  - name: instance
    server_type: cx11
    image: debian-10
  name: ansible
  name: ansible

Please see 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 (Please note: there is a bug raised against clean-up right now, see #24 for more).

  - name: "molecule-hetznercloud-volume-1-${INSTANCE_UUID}"
    location: /foo/bar
  - name: "molecule-hetznercloud-volume-2-${INSTANCE_UUID}"
    size: 20

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.


Issues will be responded to on both issue trackers.

Change log


Molecule Documentation



The LGPLv3 license.


This is all done on our setup.


$ pip install tox
$ tox -v


Only doable by Autonomic Cooperative members.

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