hetzner.hcloud.firewall_resource module – Manage Resources a Hetzner Cloud Firewall is applied to.

Note

This module is part of the hetzner.hcloud collection (version 4.2.2).

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.firewall_resource.

New in hetzner.hcloud 2.5.0

Synopsis

  • Add and Remove Resources a Hetzner Cloud Firewall is applied to.

Aliases: hcloud_firewall_resource

Requirements

The below requirements are needed on the host that executes this module.

  • python-dateutil >= 2.7.5

  • requests >=2.20

Parameters

Parameter

Comments

api_endpoint

aliases: endpoint

string

The API Endpoint for the Hetzner Cloud.

You can also set this option by using the HCLOUD_ENDPOINT environment variable.

Default: "https://api.hetzner.cloud/v1"

api_token

string / required

The API Token for the Hetzner Cloud.

You can also set this option by using the HCLOUD_TOKEN environment variable.

firewall

string / required

Name or ID of the Hetzner Cloud Firewall.

label_selectors

list / elements=string

List of Label Selector.

servers

list / elements=string

List of Server Name or ID.

state

string

State of the firewall resources.

Choices:

  • "absent"

  • "present" ← (default)

See Also

See also

Documentation for Hetzner Cloud API

Complete reference for the Hetzner Cloud API.

Examples

- name: Apply a firewall to a list of servers
  hetzner.hcloud.firewall_resource:
    firewall: my-firewall
    servers:
      - my-server
      - 3456789
    state: present

- name: Remove a firewall from a list of servers
  hetzner.hcloud.firewall_resource:
    firewall: my-firewall
    servers:
      - my-server
      - 3456789
    state: absent

- name: Apply a firewall to resources using label selectors
  hetzner.hcloud.firewall_resource:
    firewall: my-firewall
    label_selectors:
      - env=prod
    state: present

- name: Remove a firewall from resources using label selectors
  hetzner.hcloud.firewall_resource:
    firewall: my-firewall
    label_selectors:
      - env=prod
    state: absent

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

hcloud_firewall_resource

dictionary

The Resources a Hetzner Cloud Firewall is applied to.

Returned: always

firewall

string

Name of the Hetzner Cloud Firewall.

Returned: success

Sample: "my-firewall"

label_selectors

list / elements=string

List of Label Selector.

Returned: success

Sample: ["env=prod"]

servers

list / elements=string

List of Server Name.

Returned: success

Sample: ["my-server1", "my-server2"]

Authors

  • Jonas Lammler (@jooola)