Projet

Général

Profil

Révision 11bf7237

ID11bf7237333a685ccc629e0b2536a34c79a4e217
Parent 78f22811
Enfant b09d43bf

Ajouté par Steve Traylen il y a plus de 4 ans

lint_fix results

Voir les différences:

manifests/bridges.pp
1 1
# allow forwarding traffic on bridges
2
class nftables::bridges(
2
class nftables::bridges (
3 3
  Enum['present','absent']
4
    $ensure = 'present',
4
  $ensure = 'present',
5 5
  Regexp
6
    $bridgenames = /^br.+/
6
  $bridgenames = /^br.+/
7 7
) {
8 8
  if $ensure == 'present' {
9 9
    $interfaces = keys($facts['networking']['interfaces'])
manifests/chain.pp
1 1
# manage a chain
2
define nftables::chain(
2
define nftables::chain (
3 3
  Pattern[/^(ip|ip6|inet)-[a-zA-Z0-9_]+$/]
4
    $table = 'inet-filter',
4
  $table = 'inet-filter',
5 5
  Pattern[/^[a-zA-Z0-9_]+$/]
6
    $chain = $title,
6
  $chain = $title,
7 7
  Optional[Pattern[/^\d\d-[a-zA-Z0-9_]+$/]]
8
    $inject = undef,
8
  $inject = undef,
9 9
  Optional[String]
10
    $inject_iif = undef,
10
  $inject_iif = undef,
11 11
  Optional[String]
12
    $inject_oif = undef,
13
){
12
  $inject_oif = undef,
13
) {
14 14
  $concat_name = "nftables-${table}-chain-${chain}"
15 15

  
16
  concat{
16
  concat {
17 17
    $concat_name:
18 18
      path           => "/etc/nftables/puppet-preflight/${table}-chain-${chain}.nft",
19 19
      owner          => root,
......
21 21
      mode           => '0640',
22 22
      ensure_newline => true,
23 23
      require        => Package['nftables'],
24
  } ~> Exec['nft validate'] -> file{
24
  } ~> Exec['nft validate'] -> file {
25 25
    "/etc/nftables/puppet/${table}-chain-${chain}.nft":
26
    ensure => file,
27
    source => "/etc/nftables/puppet-preflight/${table}-chain-${chain}.nft",
28
    owner  => root,
29
    group  => root,
30
    mode   => '0640',
26
      ensure => file,
27
      source => "/etc/nftables/puppet-preflight/${table}-chain-${chain}.nft",
28
      owner  => root,
29
      group  => root,
30
      mode   => '0640',
31 31
  } ~> Service['nftables']
32 32

  
33
  concat::fragment{
33
  concat::fragment {
34 34
    default:
35 35
      target => $concat_name;
36 36
    "${concat_name}-header":
......
51 51
      undef => '',
52 52
      default => "oifname ${inject_oif} ",
53 53
    }
54
    nftables::rule{ "${data[1]}-jump_${chain}":
54
    nftables::rule { "${data[1]}-jump_${chain}":
55 55
      order   => $data[0],
56 56
      content => "${iif}${oif}jump ${chain}",
57 57
    }
manifests/config.pp
1 1
# manage a config snippet
2
define nftables::config(
2
define nftables::config (
3 3
  Optional[String]
4
    $content = undef,
4
  $content = undef,
5 5
  Optional[Variant[String,Array[String,1]]]
6
    $source = undef,
7
){
6
  $source = undef,
7
) {
8 8
  $concat_name = "nftables-${name}"
9 9

  
10
  Package['nftables'] -> concat{
10
  Package['nftables'] -> concat {
11 11
    $concat_name:
12 12
      path           => "/etc/nftables/puppet-preflight/${name}.nft",
13 13
      ensure_newline => true,
14 14
      owner          => root,
15 15
      group          => root,
16 16
      mode           => '0640',
17
  } ~> Exec['nft validate'] -> file{
17
  } ~> Exec['nft validate'] -> file {
18 18
    "/etc/nftables/puppet/${name}.nft":
19
    ensure => file,
20
    source => "/etc/nftables/puppet-preflight/${name}.nft",
21
    owner  => root,
22
    group  => root,
23
    mode   => '0640',
19
      ensure => file,
20
      source => "/etc/nftables/puppet-preflight/${name}.nft",
21
      owner  => root,
22
      group  => root,
23
      mode   => '0640',
24 24
  } ~> Service['nftables']
25 25

  
26 26
  $data = split($name, '-')
manifests/inet_filter.pp
1 1
# manage basic chains in table inet filter
2 2
class nftables::inet_filter inherits nftables {
3

  
4 3
  $_reject_rule = epp('nftables/reject_rule.epp',
5 4
    {
6 5
      'log_prefix' => sprintf($nftables::log_prefix, { 'chain' => '%<chain>s', 'comment' => 'Rejected: ' }),
......
8 7
    }
9 8
  )
10 9

  
11
  nftables::config{
10
  nftables::config {
12 11
    'inet-filter':
13 12
      source => 'puppet:///modules/nftables/config/puppet-inet-filter.nft';
14 13
  }
15 14

  
16
  nftables::chain{
15
  nftables::chain {
17 16
    [
18 17
      'INPUT',
19 18
      'OUTPUT',
......
21 20
    ]:;
22 21
  }
23 22

  
24
  nftables::chain{
23
  nftables::chain {
25 24
    'default_in':
26 25
      inject => '10-INPUT';
27 26
    'default_out':
......
31 30
  }
32 31

  
33 32
  # inet-filter-chain-INPUT
34
  nftables::rule{
33
  nftables::rule {
35 34
    'INPUT-type':
36 35
      order   => '01',
37 36
      content => 'type filter hook input priority 0';
......
49 48
      content => sprintf($_reject_rule, { 'chain' => 'INPUT' }),
50 49
  }
51 50
  if $nftables::reject_with {
52
    nftables::rule{
51
    nftables::rule {
53 52
      'INPUT-reject':
54 53
        order   => '98',
55 54
        content => "reject with ${$nftables::reject_with}";
56 55
    }
57 56
  }
58 57
  if $nftables::in_out_conntrack {
59
    nftables::rule{
58
    nftables::rule {
60 59
      'INPUT-accept_established_related':
61 60
        order   => '05',
62 61
        content => 'ct state established,related accept';
......
67 66
  }
68 67

  
69 68
  # inet-filter-chain-OUTPUT
70
  nftables::rule{
69
  nftables::rule {
71 70
    'OUTPUT-type':
72 71
      order   => '01',
73 72
      content => 'type filter hook output priority 0';
......
85 84
      content => sprintf($_reject_rule, { 'chain' => 'OUTPUT' }),
86 85
  }
87 86
  if $nftables::reject_with {
88
    nftables::rule{
87
    nftables::rule {
89 88
      'OUTPUT-reject':
90 89
        order   => '98',
91 90
        content => "reject with ${$nftables::reject_with}";
92 91
    }
93 92
  }
94 93
  if $nftables::in_out_conntrack {
95
    nftables::rule{
94
    nftables::rule {
96 95
      'OUTPUT-accept_established_related':
97 96
        order   => '05',
98 97
        content => 'ct state established,related accept';
......
103 102
  }
104 103

  
105 104
  # inet-filter-chain-FORWARD
106
  nftables::rule{
105
  nftables::rule {
107 106
    'FORWARD-type':
108 107
      order   => '01',
109 108
      content => 'type filter hook forward priority 0';
......
118 117
      content => sprintf($_reject_rule, { 'chain' => 'FORWARD' });
119 118
  }
120 119
  if $nftables::reject_with {
121
    nftables::rule{
120
    nftables::rule {
122 121
      'FORWARD-reject':
123 122
        order   => '98',
124 123
        content => "reject with ${$nftables::reject_with}";
125 124
    }
126 125
  }
127 126
  if $nftables::fwd_conntrack {
128
    nftables::rule{
127
    nftables::rule {
129 128
      'FORWARD-accept_established_related':
130 129
        order   => '05',
131 130
        content => 'ct state established,related accept';
manifests/init.pp
95 95
  Hash $sets                     = {},
96 96
  String $log_prefix             = '[nftables] %<chain>s %<comment>s',
97 97
  Variant[Boolean[false], String]
98
    $log_limit                   = '3/minute burst 5 packets',
98
  $log_limit                   = '3/minute burst 5 packets',
99 99
  Variant[Boolean[false], Pattern[
100
    /icmp(v6|x)? type .+|tcp reset/]]
101
    $reject_with                 = 'icmpx type port-unreachable',
100
  /icmp(v6|x)? type .+|tcp reset/]]
101
  $reject_with                 = 'icmpx type port-unreachable',
102 102
  Variant[Boolean[false], Enum['mask']]
103
    $firewalld_enable            = 'mask',
103
  $firewalld_enable            = 'mask',
104 104
  Optional[Array[Pattern[/^(ip|ip6|inet)-[-a-zA-Z0-9_]+$/],1]]
105
    $noflush_tables = undef,
105
  $noflush_tables = undef,
106 106
) {
107

  
108
  package{'nftables':
107
  package { 'nftables':
109 108
    ensure => installed,
110
  } -> file_line{
109
  } -> file_line {
111 110
    'enable_nftables':
112 111
      line   => 'include "/etc/nftables/puppet.nft"',
113 112
      path   => '/etc/sysconfig/nftables.conf',
114 113
      notify => Service['nftables'],
115
  } -> file{
114
  } -> file {
116 115
    default:
117 116
      owner => 'root',
118 117
      group => 'root',
......
126 125
    '/etc/nftables/puppet-preflight.nft':
127 126
      ensure  => file,
128 127
      content => epp('nftables/config/puppet.nft.epp', { 'nat' => $nat, 'noflush' => $noflush_tables });
129
  } ~> exec{
128
  } ~> exec {
130 129
    'nft validate':
131 130
      refreshonly => true,
132 131
      command     => '/usr/sbin/nft -I /etc/nftables/puppet-preflight -c -f /etc/nftables/puppet-preflight.nft || ( /usr/bin/echo "#CONFIG BROKEN" >> /etc/nftables/puppet-preflight.nft && /bin/false)';
133
  } -> file{
132
  } -> file {
134 133
    default:
135 134
      owner => 'root',
136 135
      group => 'root',
......
144 143
      purge   => true,
145 144
      force   => true,
146 145
      recurse => true;
147
  } ~> service{'nftables':
146
  } ~> service { 'nftables':
148 147
    ensure     => running,
149 148
    enable     => true,
150 149
    hasrestart => true,
151 150
    restart    => '/usr/bin/systemctl reload nftables',
152 151
  }
153 152

  
154
  systemd::dropin_file{'puppet_nft.conf':
153
  systemd::dropin_file { 'puppet_nft.conf':
155 154
    ensure  => present,
156 155
    unit    => 'nftables.service',
157 156
    content => epp('nftables/systemd/puppet_nft.conf.epp', { 'noflush' => $noflush_tables }),
158 157
    notify  => Service['nftables'],
159 158
  }
160 159

  
161
  service{'firewalld':
160
  service { 'firewalld':
162 161
    ensure => stopped,
163 162
    enable => $firewalld_enable,
164 163
  }
......
170 169

  
171 170
  # inject custom rules e.g. from hiera
172 171
  $rules.each |$n,$v| {
173
    nftables::rule{
172
    nftables::rule {
174 173
      $n:
175
        * => $v
174
        * => $v,
176 175
    }
177 176
  }
178 177

  
179 178
  # inject custom sets e.g. from hiera
180 179
  $sets.each |$n,$v| {
181
    nftables::set{
180
    nftables::set {
182 181
      $n:
183
        * => $v
182
        * => $v,
184 183
    }
185 184
  }
186 185
}
manifests/ip_nat.pp
1 1
# manage basic chains in table ip nat
2 2
class nftables::ip_nat inherits nftables {
3

  
4
  nftables::config{
3
  nftables::config {
5 4
    'ip-nat':
6 5
      source => 'puppet:///modules/nftables/config/puppet-ip-nat.nft';
7 6
    'ip6-nat':
8 7
      source => 'puppet:///modules/nftables/config/puppet-ip6-nat.nft';
9 8
  }
10 9

  
11
  nftables::chain{
10
  nftables::chain {
12 11
    [
13 12
      'PREROUTING',
14 13
      'POSTROUTING',
......
16 15
      table => 'ip-nat';
17 16
  }
18 17

  
19
  nftables::chain{
18
  nftables::chain {
20 19
    [
21 20
      'PREROUTING6',
22 21
      'POSTROUTING6',
......
25 24
  }
26 25

  
27 26
  # ip-nat-chain-PREROUTING
28
  nftables::rule{
27
  nftables::rule {
29 28
    'PREROUTING-type':
30 29
      table   => 'ip-nat',
31 30
      order   => '01',
......
45 44
  }
46 45

  
47 46
  # ip-nat-chain-POSTROUTING
48
  nftables::rule{
47
  nftables::rule {
49 48
    'POSTROUTING-type':
50 49
      table   => 'ip-nat',
51 50
      order   => '01',
manifests/rule.pp
1 1
# manage a chain rule
2 2
# Name should be:
3 3
#   CHAIN_NAME-rulename
4
define nftables::rule(
4
define nftables::rule (
5 5
  Enum['present','absent']
6
    $ensure = 'present',
6
  $ensure = 'present',
7 7
  Pattern[/^[a-zA-Z0-9_]+-[a-zA-Z0-9_]+(-\d+)?$/]
8
    $rulename = $title,
8
  $rulename = $title,
9 9
  Pattern[/^\d\d$/]
10
    $order = '50',
10
  $order = '50',
11 11
  Optional[String]
12
    $table = 'inet-filter',
12
  $table = 'inet-filter',
13 13
  Optional[String]
14
    $content = undef,
14
  $content = undef,
15 15
  Optional[Variant[String,Array[String,1]]]
16
    $source = undef,
17
){
18

  
16
  $source = undef,
17
) {
19 18
  if $ensure == 'present' {
20 19
    $data = split($rulename, '-')
21 20

  
......
25 24
      $fragment = "nftables-${table}-chain-${data[0]}-rule-${data[1]}"
26 25
    }
27 26

  
28
    concat::fragment{"${fragment}_header":
27
    concat::fragment { "${fragment}_header":
29 28
      content => "#   Start of fragment order:${order} rulename:${rulename}",
30 29
      order   => "${order}-${fragment}-a",
31 30
      target  => "nftables-${table}-chain-${data[0]}",
32 31
    }
33 32

  
34
    concat::fragment{
33
    concat::fragment {
35 34
      $fragment:
36 35
        order  => "${order}-${fragment}-b",
37 36
        target => "nftables-${table}-chain-${data[0]}",
38 37
    }
39 38

  
40 39
    if $content {
41
      Concat::Fragment[$fragment]{
40
      Concat::Fragment[$fragment] {
42 41
        content => "  ${content}",
43 42
      }
44 43
    } else {
45
      Concat::Fragment[$fragment]{
44
      Concat::Fragment[$fragment] {
46 45
        source => $source,
47 46
      }
48 47
    }
manifests/rules/afs3_callback.pp
8 8
class nftables::rules::afs3_callback (
9 9
  Array[Stdlib::IP::Address::V4,1] $saddr = ['0.0.0.0/0'],
10 10
) {
11

  
12
  nftables::rule{'default_in-afs3_callback':
13
    content =>  "ip saddr { ${saddr.join(', ')} } udp dport 7001 accept";
11
  nftables::rule { 'default_in-afs3_callback':
12
    content => "ip saddr { ${saddr.join(', ')} } udp dport 7001 accept";
14 13
  }
15

  
16 14
}
manifests/rules/ceph.pp
2 2
# Enable this to support Ceph's Object Storage Daemons (OSD),
3 3
# Metadata Server Daemons (MDS), or Manager Daemons (MGR).
4 4
class nftables::rules::ceph {
5
  nftables::rule{
5
  nftables::rule {
6 6
    'default_in-ceph':
7 7
      content => 'tcp dport 6800-7300 accept comment "Accept Ceph OSD, MDS, MGR"',
8 8
  }
manifests/rules/ceph_mon.pp
1 1
# Ceph is a distributed object store and file system.
2 2
# Enable this option to support Ceph's Monitor Daemon.
3
class nftables::rules::ceph_mon(
3
class nftables::rules::ceph_mon (
4 4
  Array[Integer,1] $ports = [3300, 6789],
5
){
6
  nftables::rule{
5
) {
6
  nftables::rule {
7 7
    'default_in-ceph_mon':
8 8
      content => "tcp dport {${$ports.join(', ')}} accept comment \"Accept Ceph MON\"",
9 9
  }
manifests/rules/dhcpv6_client.pp
1 1
class nftables::rules::dhcpv6_client {
2
  nftables::rule{
2
  nftables::rule {
3 3
    'default_in-dhcpv6_client':
4 4
      content => 'ip6 saddr fe80::/10 ip6 daddr fe80::/10 udp sport 547 udp dport 546 accept',
5 5
  }
manifests/rules/dnat4.pp
1 1
# manage a ipv4 dnat rule
2
define nftables::rules::dnat4(
2
define nftables::rules::dnat4 (
3 3
  Pattern[/^[12]?\d{1,2}\.[12]?\d{1,2}\.[12]?\d{1,2}\.[12]?\d{1,2}$/]
4
    $daddr,
4
  $daddr,
5 5
  Variant[String,Integer[1,65535]]
6
    $port,
6
  $port,
7 7
  Pattern[/^[a-zA-Z0-9_]+$/]
8
    $rulename = $title,
8
  $rulename = $title,
9 9
  Pattern[/^\d\d$/]
10
    $order = '50',
10
  $order = '50',
11 11
  String[1]
12
    $chain = 'default_fwd',
12
  $chain = 'default_fwd',
13 13
  Optional[String[1]]
14
    $iif = undef,
14
  $iif = undef,
15 15
  Enum['tcp','udp']
16
    $proto = 'tcp',
16
  $proto = 'tcp',
17 17
  Optional[Variant[String,Integer[1,65535]]]
18
    $dport = '',
18
  $dport = '',
19 19
  Enum['present','absent']
20
    $ensure = 'present',
20
  $ensure = 'present',
21 21
) {
22

  
23 22
  $iifname = $iif ? {
24 23
    undef   => '',
25 24
    default => "iifname ${iif} ",
......
33 32
    default => ":${dport}",
34 33
  }
35 34

  
36
  nftables::rule{
35
  nftables::rule {
37 36
    default:
38 37
      ensure => $ensure,
39 38
      order  => $order;
manifests/rules/dns.pp
1 1
# manage in dns
2
class nftables::rules::dns(
2
class nftables::rules::dns (
3 3
  Array[Integer,1]
4
    $ports = [53],
4
  $ports = [53],
5 5
) {
6
  nftables::rule{
6
  nftables::rule {
7 7
    'default_in-dns_tcp':
8 8
      content => "tcp dport {${join($ports,', ')}} accept";
9 9
    'default_in-dns_udp':
manifests/rules/http.pp
1 1
# manage in http
2 2
class nftables::rules::http {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_in-http':
5 5
      content => 'tcp dport 80 accept',
6 6
  }
manifests/rules/https.pp
1 1
# manage in https
2 2
class nftables::rules::https {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_in-https':
5 5
      content => 'tcp dport 443 accept',
6 6
  }
manifests/rules/icinga2.pp
1 1
# manage in icinga2
2
class nftables::rules::icinga2(
2
class nftables::rules::icinga2 (
3 3
  Array[Integer,1]
4
    $ports = [5665],
4
  $ports = [5665],
5 5
) {
6
  nftables::rule{
6
  nftables::rule {
7 7
    'default_in-icinga2':
8 8
      content => "tcp dport {${join($ports,', ')}} accept",
9 9
  }
manifests/rules/icmp.pp
5 5
) {
6 6
  if $v4_types {
7 7
    $v4_types.each | String $icmp_type | {
8
      nftables::rule{
8
      nftables::rule {
9 9
        "default_in-accept_icmpv4_${regsubst(split($icmp_type, ' ')[0], '-', '_', 'G')}":
10 10
          content => "ip protocol icmp icmp type ${icmp_type} accept",
11 11
          order   => $order,
12 12
      }
13 13
    }
14 14
  } else {
15
    nftables::rule{
15
    nftables::rule {
16 16
      'default_in-accept_icmpv4':
17 17
        content => 'ip protocol icmp accept',
18 18
        order   => $order,
19
      }
19
    }
20 20
  }
21 21

  
22 22
  if $v6_types {
23 23
    $v6_types.each | String $icmp_type | {
24
      nftables::rule{
24
      nftables::rule {
25 25
        "default_in-accept_icmpv6_${regsubst(split($icmp_type, ' ')[0], '-', '_', 'G')}":
26 26
          content => "ip6 nexthdr ipv6-icmp icmpv6 type ${icmp_type} accept",
27 27
          order   => $order,
28 28
      }
29 29
    }
30 30
  } else {
31
    nftables::rule{
31
    nftables::rule {
32 32
      'default_in-accept_icmpv6':
33 33
        content => 'ip6 nexthdr ipv6-icmp accept',
34 34
        order   => $order,
35
      }
35
    }
36 36
  }
37 37
}
manifests/rules/masquerade.pp
1 1
# masquerade all outgoing traffic
2
define nftables::rules::masquerade(
2
define nftables::rules::masquerade (
3 3
  Pattern[/^[a-zA-Z0-9_]+$/]
4
    $rulename = $title,
4
  $rulename = $title,
5 5
  Pattern[/^\d\d$/]
6
    $order = '70',
6
  $order = '70',
7 7
  String[1]
8
    $chain = 'POSTROUTING',
8
  $chain = 'POSTROUTING',
9 9
  Optional[String[1]]
10
    $oif = undef,
10
  $oif = undef,
11 11
  Optional[String[1]]
12
    $saddr = undef,
12
  $saddr = undef,
13 13
  Optional[String[1]]
14
    $daddr = undef,
14
  $daddr = undef,
15 15
  Optional[Enum['tcp','udp']]
16
    $proto = undef,
16
  $proto = undef,
17 17
  Optional[Variant[String,Integer[1,65535]]]
18
    $dport = undef,
18
  $dport = undef,
19 19
  Enum['present','absent']
20
    $ensure = 'present',
20
  $ensure = 'present',
21 21
) {
22

  
23 22
  $oifname = $oif ? {
24 23
    undef   => '',
25 24
    default => "oifname ${oif} ",
......
47 46
    $port     = ''
48 47
  }
49 48

  
50
  nftables::rule{
49
  nftables::rule {
51 50
    "${chain}-${rulename}":
52 51
      ensure  => $ensure,
53 52
      table   => 'ip-nat',
manifests/rules/nfs.pp
1 1
# manage in nfs4
2 2
class nftables::rules::nfs {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_in-nfs4':
5 5
      content => 'tcp dport nfs accept comment "Accept NFS4"',
6 6
  }
manifests/rules/nfs3.pp
1 1
# manage in nfs3
2 2
class nftables::rules::nfs3 {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_in-nfs3':
5 5
      content => 'meta l4proto { tcp, udp } dport nfs accept comment "Accept NFS3"',
6 6
  }
manifests/rules/node_exporter.pp
1 1
# manage in node exporter
2
class nftables::rules::node_exporter(
2
class nftables::rules::node_exporter (
3 3
  Optional[Variant[String,Array[String,1]]]
4
    $prometheus_server = undef,
4
  $prometheus_server = undef,
5 5
  Integer
6
    $port = 9100,
6
  $port = 9100,
7 7
) {
8 8
  if $prometheus_server {
9 9
    any2array($prometheus_server).each |$index,$prom| {
10

  
11
      nftables::rule{
10
      nftables::rule {
12 11
        "default_in-node_exporter-${index}":
13 12
      }
14 13
      if $prom =~ /:/ {
15
        Nftables::Rule["default_in-node_exporter-${index}"]{
14
        Nftables::Rule["default_in-node_exporter-${index}"] {
16 15
          content => "ip6 saddr ${prom} tcp dport ${port} accept",
17 16
        }
18 17
      } else {
19
        Nftables::Rule["default_in-node_exporter-${index}"]{
18
        Nftables::Rule["default_in-node_exporter-${index}"] {
20 19
          content => "ip saddr ${prom} tcp dport ${port} accept",
21 20
        }
22 21
      }
23 22
    }
24 23
  } else {
25
    nftables::rule{
24
    nftables::rule {
26 25
      'default_in-node_exporter':
27 26
        content => "tcp dport ${port} accept";
28 27
    }
manifests/rules/ospf.pp
1 1
# manage in ospf
2 2
class nftables::rules::ospf {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_in-ospf':
5 5
      content => 'ip daddr { 224.0.0.5, 224.0.0.6 } meta l4proto ospf accept',
6 6
  }
manifests/rules/ospf3.pp
1 1
# manage in ospf3
2 2
class nftables::rules::ospf3 {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_in-ospf3':
5 5
      content => 'ip6 saddr fe80::/64 ip6 daddr { ff02::5, ff02::6 } meta l4proto ospf accept',
6 6
  }
manifests/rules/out/all.pp
1 1
# allow all outbound
2 2
class nftables::rules::out::all {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_out-all':
5 5
      order   => '90',
6 6
      content => 'accept',
7

  
8 7
  }
9 8
}
manifests/rules/out/ceph_client.pp
2 2
# Enable this to be a client of Ceph's Monitor (MON),
3 3
# Object Storage Daemons (OSD), Metadata Server Daemons (MDS),
4 4
# and Manager Daemons (MGR).
5
class nftables::rules::out::ceph_client(
5
class nftables::rules::out::ceph_client (
6 6
  Array[Integer,1] $ports = [3300, 6789],
7
){
8
  nftables::rule{
7
) {
8
  nftables::rule {
9 9
    'default_out-ceph_client':
10 10
      content => "tcp dport { ${$ports.join(', ')}, 6800-7300 } accept comment \"Accept Ceph MON, OSD, MDS, MGR\"",
11 11
  }
manifests/rules/out/chrony.pp
1 1
# manage out chrony
2 2
class nftables::rules::out::chrony {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_out-chrony':
5 5
      content => 'udp dport 123 accept',
6 6
  }
manifests/rules/out/dhcp.pp
1 1
# manage out dhcp
2 2
class nftables::rules::out::dhcp {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_out-dhcpc':
5 5
      content => 'udp sport {67, 68} udp dport {67, 68} accept';
6 6
  }
manifests/rules/out/dhcpv6_client.pp
1 1
class nftables::rules::out::dhcpv6_client {
2
  nftables::rule{
2
  nftables::rule {
3 3
    'default_out-dhcpv6_client':
4 4
      content => 'ip6 saddr fe80::/10 udp sport 546 udp dport 547 accept',
5 5
  }
manifests/rules/out/dns.pp
1 1
# manage out dns
2 2
class nftables::rules::out::dns (
3 3
  Optional[Variant[String,Array[String,1]]]
4
    $dns_server = undef,
4
  $dns_server = undef,
5 5
) {
6 6
  if $dns_server {
7 7
    any2array($dns_server).each |$index,$dns| {
8

  
9
      nftables::rule{
8
      nftables::rule {
10 9
        "default_out-dnsudp-${index}":
11 10
      }
12 11
      if $dns =~ /:/ {
13
        Nftables::Rule["default_out-dnsudp-${index}"]{
12
        Nftables::Rule["default_out-dnsudp-${index}"] {
14 13
          content => "ip6 daddr ${dns} udp dport 53 accept",
15 14
        }
16 15
      } else {
17
        Nftables::Rule["default_out-dnsudp-${index}"]{
16
        Nftables::Rule["default_out-dnsudp-${index}"] {
18 17
          content => "ip daddr ${dns} udp dport 53 accept",
19 18
        }
20 19
      }
21 20

  
22
      nftables::rule{
21
      nftables::rule {
23 22
        "default_out-dnstcp-${index}":
24 23
      }
25 24
      if $dns =~ /:/ {
26
        Nftables::Rule["default_out-dnstcp-${index}"]{
25
        Nftables::Rule["default_out-dnstcp-${index}"] {
27 26
          content => "ip6 daddr ${dns} tcp dport 53 accept",
28 27
        }
29 28
      } else {
30
        Nftables::Rule["default_out-dnstcp-${index}"]{
29
        Nftables::Rule["default_out-dnstcp-${index}"] {
31 30
          content => "ip daddr ${dns} tcp dport 53 accept",
32 31
        }
33 32
      }
34 33
    }
35 34
  } else {
36
    nftables::rule{
35
    nftables::rule {
37 36
      'default_out-dnsudp':
38 37
        content => 'udp dport 53 accept';
39 38
      'default_out-dnstcp':
manifests/rules/out/http.pp
1 1
# manage out http
2 2
class nftables::rules::out::http {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_out-http':
5 5
      content => 'tcp dport 80 accept';
6 6
  }
manifests/rules/out/https.pp
1 1
# manage out https
2 2
class nftables::rules::out::https {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_out-https':
5 5
      content => 'tcp dport 443 accept';
6 6
  }
manifests/rules/out/icmp.pp
5 5
) {
6 6
  if $v4_types {
7 7
    $v4_types.each | String $icmp_type | {
8
      nftables::rule{
8
      nftables::rule {
9 9
        'default_out-accept_icmpv4':
10 10
          content => "ip protocol icmp icmp type ${icmp_type} accept",
11 11
          order   => $order,
12 12
      }
13 13
    }
14 14
  } else {
15
    nftables::rule{
15
    nftables::rule {
16 16
      'default_out-accept_icmpv4':
17 17
        content => 'ip protocol icmp accept',
18 18
        order   => $order,
19
      }
19
    }
20 20
  }
21 21

  
22 22
  if $v6_types {
23 23
    $v6_types.each | String $icmp_type | {
24
      nftables::rule{
24
      nftables::rule {
25 25
        'default_out-accept_icmpv6':
26 26
          content => "ip6 nexthdr ipv6-icmp icmpv6 type ${icmp_type} accept",
27 27
          order   => $order,
28 28
      }
29 29
    }
30 30
  } else {
31
    nftables::rule{
31
    nftables::rule {
32 32
      'default_out-accept_icmpv6':
33 33
        content => 'ip6 nexthdr ipv6-icmp accept',
34 34
        order   => $order,
35
      }
35
    }
36 36
  }
37 37
}
manifests/rules/out/kerberos.pp
1 1
# @summary allows outbound access for kerberos
2 2
class nftables::rules::out::kerberos {
3

  
4
  nftables::rule{
3
  nftables::rule {
5 4
    'default_out-kerberos_udp':
6
      content =>  'udp dport 88 accept';
5
      content => 'udp dport 88 accept';
7 6
    'default_out-kerberos_tcp':
8
      content =>  'tcp dport 88 accept';
7
      content => 'tcp dport 88 accept';
9 8
  }
10

  
11 9
}
manifests/rules/out/mysql.pp
1 1
# manage out mysql
2 2
class nftables::rules::out::mysql {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_out-mysql':
5 5
      content => 'tcp dport 3306 accept';
6 6
  }
manifests/rules/out/nfs.pp
1 1
# manage out nfs
2 2
class nftables::rules::out::nfs {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_out-nfs4':
5 5
      content => 'tcp dport nfs accept comment "Accept NFS4"',
6 6
  }
manifests/rules/out/nfs3.pp
1 1
# manage out nfs3
2 2
class nftables::rules::out::nfs3 {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_out-nfs3':
5 5
      content => 'meta l4proto { tcp, udp } dport nfs accept comment "Accept NFS3"',
6 6
  }
manifests/rules/out/openafs_client.pp
5 5
#
6 6
# @see https://wiki.openafs.org/devel/AFSServicePorts/ AFS Service Ports
7 7
#
8
class nftables::rules::out::openafs_client(
8
class nftables::rules::out::openafs_client (
9 9
  Array[Integer,1] $ports = [7000, 7002, 7003],
10
){
11

  
10
) {
12 11
  include nftables::rules::out::kerberos
13 12

  
14
  nftables::rule{'default_out-openafs_client':
13
  nftables::rule { 'default_out-openafs_client':
15 14
    content => "udp dport {${$ports.join(', ')}} accept";
16 15
  }
17

  
18 16
}
manifests/rules/out/ospf.pp
1 1
# manage out ospf
2 2
class nftables::rules::out::ospf {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_out-ospf':
5 5
      content => 'ip daddr { 224.0.0.5, 224.0.0.6 } meta l4proto ospf accept',
6 6
  }
manifests/rules/out/ospf3.pp
1 1
# manage out ospf3
2 2
class nftables::rules::out::ospf3 {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_out-ospf3':
5 5
      content => 'ip6 saddr fe80::/64 ip6 daddr { ff02::5, ff02::6 } meta l4proto ospf accept',
6 6
  }
manifests/rules/out/postgres.pp
1 1
# manage out postgres
2 2
class nftables::rules::out::postgres {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_out-postgres':
5 5
      content => 'tcp dport 5432 accept';
6 6
  }
manifests/rules/out/puppet.pp
1 1
# manage outgoing puppet
2
class nftables::rules::out::puppet(
2
class nftables::rules::out::puppet (
3 3
  Variant[String,Array[String,1]]
4
    $puppetmaster,
4
  $puppetmaster,
5 5
  Integer
6
    $puppetserver_port = 8140,
6
  $puppetserver_port = 8140,
7 7
) {
8 8
  any2array($puppetmaster).each |$index,$pm| {
9
    nftables::rule{
9
    nftables::rule {
10 10
      "default_out-puppet-${index}":
11 11
    }
12 12
    if $pm =~ /:/ {
13
      Nftables::Rule["default_out-puppet-${index}"]{
13
      Nftables::Rule["default_out-puppet-${index}"] {
14 14
        content => "ip6 daddr ${pm} tcp dport ${puppetserver_port} accept",
15 15
      }
16 16
    } else {
17
      Nftables::Rule["default_out-puppet-${index}"]{
17
      Nftables::Rule["default_out-puppet-${index}"] {
18 18
        content => "ip daddr ${pm} tcp dport ${puppetserver_port} accept",
19 19
      }
20 20
    }
manifests/rules/out/smtp.pp
1 1
# manage out smtp
2 2
class nftables::rules::out::smtp {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_out-smtp':
5 5
      content => 'tcp dport 25 accept',
6 6
  }
manifests/rules/out/ssh.pp
1 1
# manage out ssh
2 2
class nftables::rules::out::ssh {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_out-ssh':
5 5
      content => 'tcp dport 22 accept',
6 6
  }
manifests/rules/out/ssh/remove.pp
1 1
# disable outgoing ssh
2 2
class nftables::rules::out::ssh::remove inherits nftables::rules::out::ssh {
3
  Nftables::Rule['default_out-ssh']{
3
  Nftables::Rule['default_out-ssh'] {
4 4
    ensure => absent,
5 5
  }
6 6
}
manifests/rules/out/tor.pp
1 1
# manage out tor
2 2
class nftables::rules::out::tor {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_out-tor':
5 5
      content => 'tcp dport 9001 accept',
6 6
  }
manifests/rules/out/wireguard.pp
1 1
# manage out wireguard
2 2
class nftables::rules::out::wireguard (
3 3
  Array[Integer,1]
4
    $ports = [51820],
4
  $ports = [51820],
5 5
) {
6
  nftables::rule{
6
  nftables::rule {
7 7
    'default_out-wireguard':
8 8
      content => "udp dport {${join($ports,', ')}} accept",
9 9
  }
manifests/rules/puppet.pp
1 1
# manage in puppet
2
class nftables::rules::puppet(
2
class nftables::rules::puppet (
3 3
  Array[Integer,1]
4
    $ports = [8140],
4
  $ports = [8140],
5 5
) {
6
  nftables::rule{
6
  nftables::rule {
7 7
    'default_in-puppet':
8 8
      content => "tcp dport {${join($ports,', ')}} accept",
9 9
  }
manifests/rules/smtp.pp
1 1
# manage in smtp
2 2
class nftables::rules::smtp {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_in-smtp':
5 5
      content => 'tcp dport 25 accept',
6 6
  }
manifests/rules/smtp_submission.pp
1 1
# manage in smtp submission
2 2
class nftables::rules::smtp_submission {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_in-smtp_submission':
5 5
      content => 'tcp dport 587 accept',
6 6
  }
manifests/rules/smtps.pp
1 1
# manage in smtps
2 2
class nftables::rules::smtps {
3
  nftables::rule{
3
  nftables::rule {
4 4
    'default_in-smtps':
5 5
      content => 'tcp dport 465 accept',
6 6
  }
manifests/rules/snat4.pp
1 1
# manage a ipv4 snat rule
2
define nftables::rules::snat4(
2
define nftables::rules::snat4 (
3 3
  String[1]
4
    $snat,
4
  $snat,
5 5
  Pattern[/^[a-zA-Z0-9_]+$/]
6
    $rulename = $title,
6
  $rulename = $title,
7 7
  Pattern[/^\d\d$/]
8
    $order = '70',
8
  $order = '70',
9 9
  String[1]
10
    $chain = 'POSTROUTING',
10
  $chain = 'POSTROUTING',
11 11
  Optional[String[1]]
12
    $oif = undef,
12
  $oif = undef,
13 13
  Optional[String[1]]
14
    $saddr = undef,
14
  $saddr = undef,
15 15
  Optional[Enum['tcp','udp']]
16
    $proto = undef,
16
  $proto = undef,
17 17
  Optional[Variant[String,Integer[1,65535]]]
18
    $dport = undef,
18
  $dport = undef,
19 19
  Enum['present','absent']
20
    $ensure = 'present',
20
  $ensure = 'present',
21 21
) {
22

  
23 22
  $oifname = $oif ? {
24 23
    undef   => '',
25 24
    default => "oifname ${oif} ",
......
43 42
    $port     = ''
44 43
  }
45 44

  
46
  nftables::rule{
45
  nftables::rule {
47 46
    "${chain}-${rulename}":
48 47
      ensure  => $ensure,
49 48
      table   => 'ip-nat',
manifests/rules/ssh.pp
1 1
# manage in ssh
2
class nftables::rules::ssh(
2
class nftables::rules::ssh (
3 3
  Array[Integer,1]
4
    $ports = [22],
4
  $ports = [22],
5 5
) {
6
  nftables::rule{
6
  nftables::rule {
7 7
    'default_in-ssh':
8 8
      content => "tcp dport {${join($ports,', ')}} accept",
9 9
  }
manifests/rules/tor.pp
1 1
# manage in tor
2
class nftables::rules::tor(
2
class nftables::rules::tor (
3 3
  Array[Integer,1]
4
    $ports = [9001],
4
  $ports = [9001],
5 5
) {
6
  nftables::rule{
6
  nftables::rule {
7 7
    'default_in-tor':
8 8
      content => "tcp dport {${join($ports,', ')}} accept",
9 9
  }
manifests/rules/wireguard.pp
1 1
# manage in wireguard
2
class nftables::rules::wireguard(
2
class nftables::rules::wireguard (
3 3
  Array[Integer,1]
4
    $ports = [51820],
4
  $ports = [51820],
5 5
) {
6
  nftables::rule{
6
  nftables::rule {
7 7
    'default_in-wireguard':
8 8
      content => "udp dport {${join($ports,', ')}} accept",
9 9
  }
manifests/set.pp
1 1
# manage a named set
2
define nftables::set(
2
define nftables::set (
3 3
  Enum['present','absent']
4
    $ensure = 'present',
4
  $ensure = 'present',
5 5
  Pattern[/^[-a-zA-Z0-9_]+$/]
6
    $setname = $title,
6
  $setname = $title,
7 7
  Pattern[/^\d\d$/]
8
    $order = '10',
8
  $order = '10',
9 9
  Optional[Enum['ipv4_addr', 'ipv6_addr', 'ether_addr', 'inet_proto', 'inet_service', 'mark']]
10
    $type = undef,
10
  $type = undef,
11 11
  String
12
    $table = 'inet-filter',
12
  $table = 'inet-filter',
13 13
  Array[Enum['constant', 'dynamic', 'interval', 'timeout'], 0, 4]
14
    $flags = [],
14
  $flags = [],
15 15
  Optional[Integer]
16
    $timeout = undef,
16
  $timeout = undef,
17 17
  Optional[Integer]
18
    $gc_interval = undef,
18
  $gc_interval = undef,
19 19
  Optional[Array[String]]
20
    $elements = undef,
20
  $elements = undef,
21 21
  Optional[Integer]
22
    $size = undef,
22
  $size = undef,
23 23
  Optional[Enum['performance', 'memory']]
24
    $policy = undef,
24
  $policy = undef,
25 25
  Boolean
26
    $auto_merge = false,
26
  $auto_merge = false,
27 27
  Optional[String]
28
    $content = undef,
28
  $content = undef,
29 29
  Optional[Variant[String,Array[String,1]]]
30
    $source = undef,
31
){
32

  
30
  $source = undef,
31
) {
33 32
  if $size and $elements {
34 33
    if length($elements) > $size {
35 34
      fail("Max size of set ${setname} of ${size} is not being respected")
......
37 36
  }
38 37

  
39 38
  if $ensure == 'present' {
40
    concat::fragment{
39
    concat::fragment {
41 40
      "nftables-${table}-set-${setname}":
42 41
        order  => $order,
43 42
        target => "nftables-${table}",
44 43
    }
45 44

  
46 45
    if $content {
47
      Concat::Fragment["nftables-${table}-set-${setname}"]{
46
      Concat::Fragment["nftables-${table}-set-${setname}"] {
48 47
        content => "  ${content}",
49 48
      }
50 49
    } elsif $source {
51
      Concat::Fragment["nftables-${table}-set-${setname}"]{
50
      Concat::Fragment["nftables-${table}-set-${setname}"] {
52 51
        source => $source,
53 52
      }
54 53
    } else {
55 54
      if $type == undef {
56 55
        fail('The way the resource is configured must have a type set')
57 56
      }
58
      Concat::Fragment["nftables-${table}-set-${setname}"]{
57
      Concat::Fragment["nftables-${table}-set-${setname}"] {
59 58
        content => epp('nftables/set.epp',
60 59
          {
61 60
            'name'        => $setname,

Formats disponibles : Unified diff