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.16.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 module,
see Requirements for details.
To use it in a playbook, specify: hetzner.hcloud.hcloud_firewall
.
Synopsis
Create, update and manage firewalls on the Hetzner Cloud.
Requirements
The below requirements are needed on the host that executes this module.
python-dateutil >= 2.7.5
requests >=2.20
Parameters
Parameter |
Comments |
---|---|
This is the API Token for the Hetzner Cloud. You can also set this option by using the environment variable HCLOUD_TOKEN |
|
This is the API Endpoint for the Hetzner Cloud. Default: |
|
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 exist. |
|
List of rules the firewall should contain. |
|
User defined description of this rule. |
|
List of CIDRs that are allowed within this rule Default: |
|
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 Default: |
|
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: |
|
User-defined labels (key-value pairs) Returned: always |
|
Name of the firewall Returned: always Sample: |
|
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: |
|
Port of the Firewall Rule, None/Null if protocol is icmp Returned: always Sample: |
|
Protocol of the Firewall Rule Returned: always Sample: |
|
Source IPs of the Firewall Returned: always |