Molecule driver for Hetzner Cloud
Project description
Molecule Hetzner Cloud Driver
A Hetzner Cloud driver for Molecule.
This plugin allows you to use on-demand Hetzner Cloud servers for your molecule integration tests.
Install
$ pip install molecule-hetznercloud
Upgrade
This project adheres to Semantic Versioning.
$ pip install --upgrade molecule-hetznercloud
Upgrading to v2
- In your
molecule.ymlfiles, rename the molecule driver name (driver.name) tomolecule_hetznercloud:
driver:
- name: hetznercloud
+ name: molecule_hetznercloud
- In your
molecule.ymlfiles, the volumes name (platforms[].volumes[].name) field is now required. If the field is missing, you MUST add it:
platforms:
- name: instance-1
image: debian-12
volumes:
- - size: 20
+ - name: volume-1
+ size: 20
-
Each resource (servers, volumes, networks) name are prefixed with a hash (32 chars) based on the role and scenario path. This means you MAY reuse the same names (e.g.
instance-1) across your scenarios. Resource names MUST not exceed their max length, for example the server name max length is 63 chars, with the prefix you only have 31 chars left for your name. -
In your
molecule.ymlfiles, the platforms server type (platforms[].server_type) field now defaults tocx22. If you already use the default, you MAY remove the field:
platforms:
- name: instance-1
image: debian-12
- server_type: cx22
Usage
To communicate with the Hetzner Cloud API, you need to expose a HCLOUD_TOKEN environment variable. Find out more about how to get a Hetzner Cloud API token in the authentication documentation.
$ export HCLOUD_TOKEN="set_the_hcloud_token_here"
Then setup a new molecule scenario using the driver plugin.
$ molecule init scenario --driver-name molecule_hetznercloud
[!WARNING] With molecule 6, the
molecule init scenariocommand dropped support for driver provided configuration. If you are using molecule >=6, please copy the example below and paste it in your scenariomolecule.ymlfile. See this commit for details.
Your molecule/default/molecule.yml should then look like the following.
---
driver:
name: molecule_hetznercloud
platforms:
- # Name of the Server to create (must be unique per Project and a valid hostname as per RFC 1123).
# required
name: instance-1
# Name of the Image the Server is created from.
# required
image: debian-12
# Name of the Server type this Server should be created with.
# default: cx23
server_type: cx23
# Name of Location to create Server in.
# default: omit
location: hel1
# Cloud-Init user data to use during Server creation. This field is limited to 32KiB.
# default: omit
user_data: null
# List of volumes to attach to the server.
volumes:
- # Name of the volume.
# required
name: volume-1
# Size of the Volume in GB.
# default: 10
size: 10
# Dictionary of private networks the server should be attached to.
networks:
# Name of the network
network-1:
# IP range of the whole network which must span all included subnets. Must be one of the private IPv4 ranges of RFC1918.
# If multiple hosts using the same network, you may only define it once.
# required
ip_range: 10.0.0.0/16
subnet:
# IP to assign to the server.
# required
ip: 10.0.0.1/24
# Type of subnetwork.
# default: cloud
type: cloud
# Name of network zone.
# default: eu-central
network_zone: eu-central
network-2:
ip_range: 10.1.0.0/16
subnet:
ip: 10.1.0.1/24
[!NOTE] The
networks.ip_rangeis important for creating. If you have multiple hosts, you may only define it once.
[!NOTE] You may list the server types and available images using the
hcloudcommand line tool:# List server types $ hcloud server-type list --sort name # List images for the x86 architecture $ hcloud image list --type system --architecture x86 --sort name
Then test your role.
$ 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
You may also define a custom resource namespace by exposing the following environment variables, for example in CI workflows:
$ export RESOURCE_NAMESPACE=e121dc64ff615ccdfac71bb5c00296b9 # Ensure the value length is <= 32
Development
Testing
Run unit tests:
make test
Run integration tests
export HCLOUD_TOKEN="set_the_hcloud_token_here"
make integration
History
The project was initially maintained by @decentral1se. After a long period looking for new maintainers, the project was archived in early 2023.
In September 2023, the code has been rewritten by @jooola and the project was reactivated to continue development.
License
The LGPLv3 license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file molecule_hetznercloud-2.7.0.tar.gz.
File metadata
- Download URL: molecule_hetznercloud-2.7.0.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abc803d0eab4aeeec6e6a4012d6a22a839146f36671da55201bc85427823f1a8
|
|
| MD5 |
4f02873d77742f1c48ab20bb168e3c91
|
|
| BLAKE2b-256 |
7f6e9decab9b454188e7cd241977bedf40242b4493fe6eece79a733034643f22
|
Provenance
The following attestation bundles were made for molecule_hetznercloud-2.7.0.tar.gz:
Publisher:
release.yml on ansible-community/molecule-hetznercloud
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
molecule_hetznercloud-2.7.0.tar.gz -
Subject digest:
abc803d0eab4aeeec6e6a4012d6a22a839146f36671da55201bc85427823f1a8 - Sigstore transparency entry: 816798504
- Sigstore integration time:
-
Permalink:
ansible-community/molecule-hetznercloud@f05e60799d86910412edf5671335a81ccc5cae39 -
Branch / Tag:
refs/tags/v2.7.0 - Owner: https://github.com/ansible-community
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f05e60799d86910412edf5671335a81ccc5cae39 -
Trigger Event:
release
-
Statement type:
File details
Details for the file molecule_hetznercloud-2.7.0-py3-none-any.whl.
File metadata
- Download URL: molecule_hetznercloud-2.7.0-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48f07c2975fb31d2943c2a569f028da34400a2e35a937241023e409cea3f9b42
|
|
| MD5 |
b95f374cc8ee1b997099fb68a457fd56
|
|
| BLAKE2b-256 |
3bc55cea9e710e4f3bce9b267c961952e8806b1723a644df58e2e8eb92e7fa00
|
Provenance
The following attestation bundles were made for molecule_hetznercloud-2.7.0-py3-none-any.whl:
Publisher:
release.yml on ansible-community/molecule-hetznercloud
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
molecule_hetznercloud-2.7.0-py3-none-any.whl -
Subject digest:
48f07c2975fb31d2943c2a569f028da34400a2e35a937241023e409cea3f9b42 - Sigstore transparency entry: 816798551
- Sigstore integration time:
-
Permalink:
ansible-community/molecule-hetznercloud@f05e60799d86910412edf5671335a81ccc5cae39 -
Branch / Tag:
refs/tags/v2.7.0 - Owner: https://github.com/ansible-community
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f05e60799d86910412edf5671335a81ccc5cae39 -
Trigger Event:
release
-
Statement type: