hetzner.hcloud.hcloud_firewall module – Create and manage firewalls on the Hetzner Cloud.
Note
This module is part of the hetzner.hcloud collection (version 1.6.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
.
To use it in a playbook, specify: hetzner.hcloud.hcloud_firewall
.
Requirements
The below requirements are needed on the host that executes this module.
hcloud-python >= 1.0.0
Parameters
Parameter |
Comments |
---|---|
This is the API Token for the Hetzner Cloud. |
|
This is the API Endpoint for the Hetzner Cloud. Default: “https://api.hetzner.cloud/v1” |
|
The ID of the Hetzner Cloud firewall to manage. Only required if no firewall name is given |
|
User-defined labels (key-value pairs) |
|
The Name of the Hetzner Cloud firewall to manage. Only required if no firewall id is given, or a firewall does not exists. |
|
List of rules the firewall should contain. |
|
User defined description of this rule. |
|
List of CIDRs that are allowed within this rule |
|
The direction of the firewall rule. Choices:
|
|
The port of the firewall rule. |
|
The protocol of the firewall rule. Choices:
|
|
List of CIDRs that are allowed within this rule |
|
State of the firewall. Choices:
|
See Also
See also
- Documentation for Hetzner Cloud API
Complete reference for the Hetzner Cloud API.
Examples
- name: Create a basic firewall
hcloud_firewall:
name: my-firewall
state: present
- name: Create a firewall with rules
hcloud_firewall:
name: my-firewall
rules:
- direction: in
protocol: icmp
source_ips:
- 0.0.0.0/0
- ::/0
description: allow icmp in
state: present
- name: Create a firewall with labels
hcloud_firewall:
name: my-firewall
labels:
key: value
mylabel: 123
state: present
- name: Ensure the firewall is absent (remove if needed)
hcloud_firewall:
name: my-firewall
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The firewall instance Returned: Always |
|
Numeric identifier of the firewall Returned: always Sample: 1937415 |
|
User-defined labels (key-value pairs) Returned: always |
|
Name of the firewall Returned: always Sample: “my firewall” |
|
List of Rules within this Firewall Returned: always |
|
User defined description of the Firewall Rule Returned: always |
|
Source IPs of the Firewall Returned: always |
|
Direction of the Firewall Rule Returned: always Sample: “in” |
|
Port of the Firewall Rule, None/Null if protocol is icmp Returned: always Sample: “in” |
|
Protocol of the Firewall Rule Returned: always Sample: “icmp” |
|
Source IPs of the Firewall Returned: always |
Authors
Lukas Kaemmerling (@lkaemmerling)