Projet

Général

Profil

Révision 03d9e7da

ID03d9e7daab529101204acd9b22d888103860b545
Parent 9fe75e32
Enfant c3be15e0

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

New parameter noflush_tables to selectivly skip flush

Introduces a new structured fact nftables

```yaml
nftables:
tables:
- inet-filter
- ip-nat
- ip6-nat
- inet-f2b-table
```

By default the nft script will continue to contain `nft flush ruleset`

If noflush_tables is specified e.g.

```puppet
class{nftables:
noflush_tables => ['inet-f2b-table'],
}
```
the results script will explicity flush the other tables only.
i.e.

```
flush table inet filter
flush table ip nat
flush table ip6 nat
```

Motivation here is to allow a maintence of chain to managed by something else.
This example for fail2ban but could be docker, ...

Voir les différences:

templates/config/puppet.nft.epp
1
<%- |
2
  Boolean $nat,
3
  Optional[Array[String[1],1]] $noflush = undef,
4
|-%>
5
<%-
6
if $noflush and $facts['nftables'] and $facts['nftables']['tables'] {
7
 $_flush_command = $facts['nftables']['tables'].filter |$_tab| { ! ($_tab in $noflush) }.map |$_table| {
8
   "flush table ${regsubst($_table,'-',' ')}"
9
 }
10
} else {
11
 $_flush_command = ['flush ruleset']
12
}
13
-%>
1 14
# puppet-preflight.nft is only used by puppet for validating new configs
2 15
# puppet.nft is real configuration that the nftables services uses.
3 16
# To process either the -I flag must be specified.
......
5 18
# nft -c -I /etc/nftables/puppet-preflight -f /etc/nftables/puppet-preflight.nft
6 19

  
7 20
# drop any existing nftables ruleset
8
flush ruleset
21
<%= $_flush_command.join('; ') %>
9 22

  
10 23
include "custom-*.nft"
11 24
include "inet-filter.nft"

Formats disponibles : Unified diff