hetzner.hcloud.hcloud inventory – Ansible dynamic inventory plugin for the Hetzner Cloud.
Note
This inventory plugin is part of the hetzner.hcloud collection (version 1.9.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install hetzner.hcloud
.
You need further requirements to be able to use this inventory plugin,
see Requirements for details.
To use it in a playbook, specify: hetzner.hcloud.hcloud
.
Synopsis
Reads inventories from the Hetzner Cloud API.
Uses a YAML configuration file that ends with hcloud.(yml|yaml).
Requirements
The below requirements are needed on the local controller node that executes this inventory.
python >= 2.7
hcloud-python >= 1.0.0
Parameters
Parameter |
Comments |
---|---|
Create vars from jinja2 expressions. Default: |
|
Connect to the server using the value from this field. Choices:
|
|
The group all servers are automatically added to. Default: |
|
Add hosts to group based on Jinja2 conditionals. Default: |
|
Populate inventory with instances with this image name, only available for system images. Default: |
|
Add hosts to group based on the values of a variable. Default: |
|
The default value when the host variable’s value is an empty string. This option is mutually exclusive with |
|
The key from input dictionary used to generate groups |
|
parent group for keyed group |
|
A keyed group name will start with this prefix Default: |
|
separator used to build the keyed group name Default: |
|
Set this option to False to omit the This option is mutually exclusive with Choices:
|
|
Populate inventory with instances with this label. Default: |
|
Use in conjunction with keyed_groups. By default, a keyed group that does not have a prefix or a separator provided will have a name that starts with an underscore. This is because the default prefix is “” and the default separator is “_”. Set this option to False to omit the leading underscore (or other separator) if no prefix is given. If the group name is derived from a mapping the separator is still used to concatenate the items. To not use a separator in the group name at all, set the separator for the keyed group to an empty string instead. Choices:
|
|
Populate inventory with instances in this location. Default: |
|
Populate inventory with instances which are attached to this network name or ID. Default: |
|
marks this as an instance of the “hcloud” plugin Choices:
|
|
Populate inventory with instances with this status. Default: |
|
If Since it is possible to use facts in the expressions they might not always be available and we ignore those errors by default. Choices:
|
|
The Hetzner Cloud API Token. |
|
Environment variable to load the Hetzner Cloud API Token from. Default: |
|
Populate inventory with instances with this type. Default: |
|
Merge extra vars into the available variables for composition (highest precedence). Choices:
Configuration:
|
Examples
# Minimal example. `HCLOUD_TOKEN` is exposed in environment.
plugin: hcloud
# Example with locations, types, status and token
plugin: hcloud
token: foobar
locations:
- nbg1
types:
- cx11
status:
- running
# Group by a location with prefix e.g. "hcloud_location_nbg1"
# and image_os_flavor without prefix and separator e.g. "ubuntu"
# and status with prefix e.g. "server_status_running"
plugin: hcloud
keyed_groups:
- key: location
prefix: hcloud_location
- key: image_os_flavor
separator: ""
- key: status
prefix: server_status