Defined Type: firewall::client

Defined in:
modules/firewall/manifests/client.pp

Summary

a shim define to support a common interface between ferm::client and nft::client

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • proto (Any)

    the protocol to use

  • port (Any)

    the port to configure

  • ensure (Any) (defaults to: present)

    the ensurable parameter

  • desc (Any) (defaults to: '')

    a description to add as a comment

  • prio (Any) (defaults to: 10)

    the priority

  • drange (Any) (defaults to: undef)

    the destination range to configure

  • notrack (Any) (defaults to: false)

    set the rule with no state tracking

  • skip_output_chain (Any) (defaults to: false)

    can be used to avoid adding uneeded rule if we only want to set qos

  • qos (Any) (defaults to: '')

    traffic class (mgmt/high/low) to control DSCP marking



12
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
# File 'modules/firewall/manifests/client.pp', line 12

define firewall::client(
    $proto,
    $port,
    $ensure            = present,
    $desc              = '',
    $prio              = 10,
    $drange            = undef,
    $notrack           = false,
    $skip_output_chain = false,
    $qos               = '',
) {
    include firewall
    case $firewall::provider {
        'none': {}
        'ferm': {
            ferm::client { $title:
                * => wmflib::resource::dump_params(),
            }
        }
        'nftables': {
            if $drange =~ String {
                fail('The drange needs to be passed as an array of hosts or IPs')
            }

            if $port =~ Pattern[/\d{1,5}:\d{1,5}/] {
                fail('The port needs to be converted to use a port_range')
            }

            if $port =~ String {
                fail('The port needs to be converted to an array; use a port or port_range')
            }

            nftables::client { $title:
                *       => wmflib::resource::filter_params('drange', 'srange'),
                dst_ips => $drange.then |$range| { wmflib::hosts2ips($range) },
            }
        }
        default: { fail('invalid provider') }
    }
}