community.hrobot.firewall_info (1.9.1) — module

Manage Hetzner's dedicated server firewall

Authors: Felix Fontein (@felixfontein)

Install collection

Install with ansible-galaxy collection install community.hrobot:==1.9.1


Add to requirements.yml

  collections:
    - name: community.hrobot
      version: 1.9.1

Description

Manage Hetzner's dedicated server firewall.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Get firewall configuration for server with main IP 1.2.3.4
  community.hrobot.firewall_info:
    hetzner_user: foo
    hetzner_password: bar
    server_ip: 1.2.3.4
  register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- ansible.builtin.debug:
    msg: "{{ result.firewall }}"

Inputs

    
timeout:
    default: 180
    description:
    - Timeout (in seconds) for waiting for firewall to be configured.
    type: int

server_ip:
    description:
    - The server's main IP address.
    - Exactly one of O(server_ip) and O(server_number) must be specified.
    - Note that Hetzner deprecated identifying the server's firewall by the server's main
      IP. Using this option can thus stop working at any time in the future. Use O(server_number)
      instead.
    type: str

wait_delay:
    default: 10
    description:
    - Delay to wait (in seconds) before checking again whether the firewall has been configured.
    type: int

hetzner_user:
    description: The username for the Robot webservice user.
    required: true
    type: str

server_number:
    description:
    - The server's number.
    - Exactly one of O(server_ip) and O(server_number) must be specified.
    type: int
    version_added: 1.8.0
    version_added_collection: community.hrobot

hetzner_password:
    description: The password for the Robot webservice user.
    required: true
    type: str

wait_for_configured:
    default: true
    description:
    - Whether to wait until the firewall has been successfully configured before returning
      from the module.
    - The API returns status C(in progress) when the firewall is currently being configured.
      If this happens, the module will try again until the status changes to C(active)
      or C(disabled).
    - Please note that there is a request limit. If you have to do multiple updates, it
      can be better to disable waiting, and regularly use M(community.hrobot.firewall_info)
      to query status.
    type: bool

Outputs

firewall:
  contains:
    allowlist_hos:
      description:
      - Whether Hetzner services have access.
      sample: true
      type: bool
      version_added: 1.2.0
      version_added_collection: community.hrobot
    filter_ipv6:
      description:
      - Whether the firewall rules apply to IPv6 as well or not.
      sample: false
      type: bool
    port:
      description:
      - Switch port of firewall.
      - V(main) or V(kvm).
      sample: main
      type: str
    rules:
      contains:
        input:
          contains:
            action:
              choices:
              - accept
              - discard
              description:
              - Action if rule matches.
              - V(accept) or V(discard).
              sample: accept
              type: str
            dst_ip:
              description:
              - Destination IP address or subnet address.
              - CIDR notation.
              sample: 1.2.3.4/32
              type: str
            dst_port:
              description:
              - Destination port or port range.
              sample: '443'
              type: str
            ip_version:
              description:
              - Internet protocol version.
              - No value means the rule applies both to IPv4 and IPv6.
              sample: ipv4
              type: str
            name:
              description:
              - Name of the firewall rule.
              sample: Allow HTTP access to server
              type: str
            protocol:
              description:
              - Protocol above IP layer.
              sample: tcp
              type: str
            src_ip:
              description:
              - Source IP address or subnet address.
              - CIDR notation.
              sample: null
              type: str
            src_port:
              description:
              - Source port or port range.
              sample: null
              type: str
            tcp_flags:
              description:
              - TCP flags or logical combination of flags.
              sample: null
              type: str
          description:
          - Input firewall rules.
          elements: dict
          type: list
        output:
          contains:
            action:
              choices:
              - accept
              - discard
              description:
              - Action if rule matches.
              - V(accept) or V(discard).
              sample: accept
              type: str
            dst_ip:
              description:
              - Destination IP address or subnet address.
              - CIDR notation.
              sample: 1.2.3.4/32
              type: str
            dst_port:
              description:
              - Destination port or port range.
              sample: '443'
              type: str
            ip_version:
              description:
              - Internet protocol version.
              - No value means the rule applies both to IPv4 and IPv6.
              sample: null
              type: str
            name:
              description:
              - Name of the firewall rule.
              sample: Allow HTTP access to server
              type: str
            protocol:
              description:
              - Protocol above IP layer.
              sample: tcp
              type: str
            src_ip:
              description:
              - Source IP address or subnet address.
              - CIDR notation.
              sample: null
              type: str
            src_port:
              description:
              - Source port or port range.
              sample: null
              type: str
            tcp_flags:
              description:
              - TCP flags or logical combination of flags.
              sample: null
              type: str
          description:
          - Output firewall rules.
          elements: dict
          type: list
      description:
      - Firewall rules.
      type: dict
    server_ip:
      description:
      - Server's main IP address.
      sample: 1.2.3.4
      type: str
    server_number:
      description:
      - Hetzner's internal server number.
      sample: 12345
      type: int
    status:
      description:
      - Status of the firewall.
      - V(active) or V(disabled).
      - Will be V(in process) if the firewall is currently updated, and O(wait_for_configured)
        is set to V(false) or O(timeout) to a too small value.
      sample: active
      type: str
    whitelist_hos:
      description:
      - Whether Hetzner services have access.
      - Old name of return value V(allowlist_hos), will be removed eventually.
      sample: true
      type: bool
  description:
  - The firewall configuration.
  returned: success
  type: dict

See also