Projet

Général

Profil

Révision fcb1d356

IDfcb1d356e076b8c8900d08f3b596613cc246261b
Parent f0bd8791
Enfant 294a38ff

Ajouté par Nacho Barrientos il y a plus de 4 ans

Auto fill simple table configuration

Voir les différences:

files/config/puppet-ip-nat.nft
1
  include "ip-nat-chain-*.nft"
files/config/puppet-ip6-nat.nft
1
  include "ip6-nat-chain-*.nft"
manifests/config.pp
38 38
        source => $source,
39 39
    }
40 40
  } else {
41
    if $content {
42
      $_content = $content
43
    } else {
44
      $_content = "  include \"${name}-chain-*.nft\""
45
    }
41 46
    concat::fragment {
42 47
      "${concat_name}-body":
43 48
        target  => $concat_name,
44 49
        order   => '98',
45
        content => $content,
50
        content => $_content,
46 51
    }
47 52
  }
48 53

  
manifests/ip_nat.pp
1 1
# manage basic chains in table ip nat
2 2
class nftables::ip_nat inherits nftables {
3
  nftables::config {
4
    'ip-nat':
5
      source => 'puppet:///modules/nftables/config/puppet-ip-nat.nft';
6
    'ip6-nat':
7
      source => 'puppet:///modules/nftables/config/puppet-ip6-nat.nft';
8
  }
3
  nftables::config { ['ip-nat', 'ip6-nat']: }
9 4

  
10 5
  nftables::chain {
11 6
    [
spec/classes/ip_nat_spec.rb
30 30
      it {
31 31
        is_expected.to contain_concat__fragment('nftables-ip-nat-body').with(
32 32
          target:  'nftables-ip-nat',
33
          content: %r{^\s+include "ip-nat-chain-\*\.nft"$},
33 34
          order:   '98',
34 35
        )
35 36
      }
......
63 64
      it {
64 65
        is_expected.to contain_concat__fragment('nftables-ip6-nat-body').with(
65 66
          target:  'nftables-ip6-nat',
67
          content: %r{^\s+include "ip6-nat-chain-\*\.nft"$},
66 68
          order:   '98',
67 69
        )
68 70
      }
spec/defines/config_spec.rb
11 11
      end
12 12

  
13 13
      context 'with source and content both unset' do
14
        it { is_expected.not_to compile }
14
        it { is_expected.to compile }
15
        it { is_expected.to contain_concat('nftables-FOO-BAR') }
16
        it {
17
          is_expected.to contain_concat('nftables-FOO-BAR').with(
18
            path: '/etc/nftables/puppet-preflight/FOO-BAR.nft',
19
            ensure_newline: true,
20
            mode: '0640',
21
          )
22
        }
23
        it { is_expected.to contain_file('/etc/nftables/puppet/FOO-BAR.nft') }
24
        it {
25
          is_expected.to contain_file('/etc/nftables/puppet/FOO-BAR.nft').with(
26
            ensure: 'file',
27
            source: '/etc/nftables/puppet-preflight/FOO-BAR.nft',
28
            mode: '0640',
29
          )
30
        }
31
        it { is_expected.to contain_concat_fragment('nftables-FOO-BAR-header') }
32
        it {
33
          is_expected.to contain_concat_fragment('nftables-FOO-BAR-header').with(
34
            target: 'nftables-FOO-BAR',
35
            order: '00',
36
            content: 'table FOO BAR {',
37
          )
38
        }
39
        it {
40
          is_expected.to contain_concat_fragment('nftables-FOO-BAR-body').with(
41
            target: 'nftables-FOO-BAR',
42
            order: '98',
43
            content: '  include "FOO-BAR-chain-*.nft"',
44
          )
45
        }
15 46
      end
16 47

  
17 48
      context 'with a non hyphenated title' do

Formats disponibles : Unified diff