hetzner_vswitch
Ansible Role: Hetzner vSwitch
An Ansible Role that manages Hetzner Robot vSwitch.
Prerequisites
- Existing Hetzner Online GmbH Account.
- Configured Hetzner Robot Webservice Account.
Requirements
Name | Type | Version | Location |
---|---|---|---|
ansible-filter | Python package | 1.0.1 | Control node |
Role Variables
Available variables are listed below, along with default values (see defaults/main.yml
):
hetzner_vswitch_webservice_base_url: https://robot-ws.your-server.de
Base url that is pointing to the Hetzner Robot API. The variable is mostly utilized for testing purposes, there is no need to change the default.
hetzner_vswitch_webservice_username: robot
Webservice login name. May be set/changed as described in the section Change Access Data (Hetzner Wiki).
hetzner_vswitch_webservice_password: secret
Webservice password. May be set/changed as described in the section Change Access Data (Hetzner Wiki).
hetzner_vswitch_instances:
- name: New vSwitch
vlan: 1234
Multiple vSwitch instances may be managed using hetzner_vswitch_instances
variable. A vSwitch is
identified by the name
attribute. The name must be unique to omit collision/unexpected behavior.
The state
attribute for a vSwitch defaults to present
.
hetzner_vswitch_instances:
- name: New vSwitch
interface: vlan1
Virtual interface name for the vSwitch based network may be specified using interface
keyword. With eth0
as physical interface
and 1234
as VLAN ID it defaults to eth0.1234
if not set.
hetzner_vswitch_instances:
- name: New vSwitch
state: absent
To ensure the vSwitch is removed add state: absent
. The name
attribute remains mandatory to identify origin state.
hetzner_vswitch_host:
- name: New vSwitch
Every host can be bound to one or multiple vSwitches defined within hetzner_vswitch_instances
using the hetzner_vswitch_host
variable. vSwitches
are referenced by the name
attribute.
Hosts with undefined hetzner_vswitch_host
variable are ignored by the role.
hetzner_vswitch_host:
- name: New vSwitch
state: absent
Add state: absent
to detach a host from a vSwitch.
hetzner_vswitch_instances:
- name: New vSwitch
vlan: 4001
ipv4_address: 192.168.100.0
ipv4_netmask: 255.255.255.0
hetzner_vswitch_host:
- name: New vSwitch
ipv4_address: 192.168.100.1
To manage the underlying network configuration ipv4_address
and ipv4_netmask
must be present on the hetzner_vswitch_instances
.
A dedicated host IP address must be specified as ipv4_address
within hetzner_vswitch_host
variable.
hetzner_vswitch_webservice_concurrent_requests: 1
hetzner_vswitch_webservice_concurrent_poll: 1
To speed up the role execution while handling the vSwitch configuration with multiple vSwitches, the number of parallel requests made to the Hetzner Robot API
can be controlled by hetzner_vswitch_webservice_concurrent_requests
variable. The poll interval for asynchronous request
result processing is set using hetzner_vswitch_webservice_concurrent_poll
. Check official documentation on
Asynchronous Actions and Polling for more explanation.
Tags
Tags can be used to limit the role execution to a particular task module. Following tags are available:
hetzner_vswitch
: Covers the full role lifecycle.hetzner_vswitch_install
,install
: Installs required packages.hetzner_vswitch_config
,config
: Configures related packages and resources.hetzner_vswitch_vswitch
,config
: Manages vswitch configuration using Hetzner Robot API.hetzner_vswitch_vswitch_server
,config
: Adds/removes servers to/from a vswitch using Hetzner Robot API.hetzner_vswitch_host
,config
: Configures network settings on the target hosts.hetzner_vswitch_handle
,handle
: Executes handlers when necessary.
Dependencies
None.
Example Playbook
- hosts: all
roles:
- nl2go.hetzner_vswitch
Development
Use docker-molecule following the instructions to run Molecule or install Molecule locally (not recommended, version conflicts might appear).
Use following to run tests:
molecule test --all
Maintainers
License
See the LICENSE.md file for details.
Author Information
This role was created by in 2019 by Newsletter2Go GmbH.
Manage Hetzner Robot vSwitch (https://wiki.hetzner.de/index.php/Vswitch/en) using Ansible.
ansible-galaxy install nl2go/ansible-role-hetzner-vswitch