Skip to content

linuxfabrik.lfops.exoscale_security_group

Manage an Exoscale security group and its rules

Synopsis

  • Creates or deletes an Exoscale security group, identified by name, and adds or removes the listed rules, using the Exoscale v2 API.
  • Rules that exist on the security group but are not listed in rules are left alone. Remove a rule by listing it with state=absent.
  • Supports --check and --diff.

Available since LFOps 10.0.0.

Mandatory Parameters

api_key

  • Exoscale API key.
  • Type: String.

api_secret

  • Exoscale API secret matching api_key.
  • Type: String.

name

  • Name of the security group. Must be unique in the organization.
  • Type: String.

zone

  • Exoscale zone, for example ch-gva-2. Selects the API endpoint. Security groups themselves are global.
  • Type: String.

Optional Parameters

operation_timeout

  • Seconds to wait for an asynchronous Exoscale operation to finish.
  • Type: Number.
  • Default: 600

rules

  • Rules to add to or remove from the security group. A rule is identified by all of its subkeys except state.
  • Type: List.
  • Default: []
  • Subkeys:

    • cidr:

      • Network the rule applies to, in CIDR notation.
      • Type: String.
      • Default: 0.0.0.0/0
    • end_port:

      • Last port of the range. Only for tcp and udp.
      • Type: Number.
    • icmp_code:

      • ICMP code. Only for icmp and icmpv6. -1 matches any code.
      • Type: Number.
      • Default: -1
    • icmp_type:

      • ICMP type. Only for icmp and icmpv6. -1 matches any type.
      • Type: Number.
      • Default: -1
    • protocol:

      • Network protocol.
      • Type: String. One of ah, all, esp, gre, icmp, icmpv6, ipip, tcp, udp.
    • start_port:

      • First port of the range. Only for tcp and udp.
      • Type: Number.
    • state:

      • Whether the rule should exist.
      • Type: String. One of absent, present.
      • Default: present
    • type:

      • Direction of the traffic.
      • Type: String. One of egress, ingress.
      • Default: ingress

state

  • present creates the security group if it is missing and applies rules. absent deletes the security group. Exoscale refuses this while an instance is still attached to it.
  • Type: String. One of absent, present.
  • Default: present

Examples

- name: 'Allow SSH and ping to the instance'
  linuxfabrik.lfops.exoscale_security_group:
    api_key: '{{ exoscale_api_key }}'
    api_secret: '{{ exoscale_api_secret }}'
    zone: 'ch-gva-2'
    name: 'web01'
    rules:
      - protocol: 'tcp'
        start_port: 22
        end_port: 22
        cidr: '192.0.2.0/24'
      - protocol: 'icmp'
        icmp_type: 8
        icmp_code: 0
      - protocol: 'tcp'
        start_port: 23
        end_port: 23
        state: 'absent'
  delegate_to: 'localhost'

Return Values

security_group

  • The security group as returned by the Exoscale API after all changes, including its rules. Empty when state=absent.
  • Type: Dictionary.
  • Returned: always.

Authors

  • Linuxfabrik GmbH, Zurich, Switzerland (info (at) linuxfabrik (dot) ch)