Puppet Class: nftables::rules::out::choria

Defined in:
manifests/rules/out/choria.pp

Summary

manage outgoing connections to choria brokers

Overview

Parameters:

  • brokers (Array[Stdlib::IP::Address]) (defaults to: [])

    list of brokers where you want to connect to

  • choria_port (Stdlib::Port) (defaults to: 4222)

    where the broker listens for incoming server connections

  • websocket_port (Stdlib::Port) (defaults to: 4333)

    where the broker listens for incoming websocket connections from servers

  • enable_websockets (Boolean) (defaults to: true)

    websockets are optional and use a different port

See Also:

Author:

  • Tim Meusel <tim@bastelfreak.de>



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'manifests/rules/out/choria.pp', line 13

class nftables::rules::out::choria (
  Array[Stdlib::IP::Address] $brokers = [],
  Stdlib::Port $choria_port = 4222,
  Stdlib::Port $websocket_port = 4333,
  Boolean $enable_websockets = true,
) {
  if empty($brokers) {
    nftables::rule { 'default_out-choria-0':
      content => "tcp dport ${choria_port} accept",
    }
    if $enable_websockets {
      nftables::rule { 'default_out-choriawebsocket-0':
        content => "tcp dport ${choria_port} accept",
      }
    }
  }
  else {
    $brokers.each |$index,$ip| {
      if $ip =~ Stdlib::IP::Address::V6 {
        nftables::rule { "default_out-choria-${index}":
          content => "ip6 daddr ${ip} tcp dport ${choria_port} accept",
        }
      } else {
        nftables::rule { "default_out-choria-${index}":
          content => "ip daddr ${ip} tcp dport ${choria_port} accept",
        }
      }
      if $enable_websockets {
        if $ip =~ Stdlib::IP::Address::V6 {
          nftables::rule { "default_out-choriawebsocket-${index}":
            content => "ip6 daddr ${ip} tcp dport ${websocket_port} accept",
          }
        } else {
          nftables::rule { "default_out-choriawebsocket-${index}":
            content => "ip daddr ${ip} tcp dport ${websocket_port} accept",
          }
        }
      }
    }
  }
}