Révision 9e42547b
split conntrack management into dedicated classes so they get consumeable
manifests/inet_filter.pp | ||
---|---|---|
57 | 57 |
} |
58 | 58 |
} |
59 | 59 |
if $nftables::in_out_conntrack { |
60 |
nftables::rule { |
|
61 |
'INPUT-accept_established_related': |
|
62 |
order => '05', |
|
63 |
content => 'ct state established,related accept'; |
|
64 |
'INPUT-drop_invalid': |
|
65 |
order => '06', |
|
66 |
content => 'ct state invalid drop'; |
|
67 |
} |
|
60 |
include nftables::inet_filter::in_out_conntrack |
|
68 | 61 |
} |
69 | 62 |
|
70 | 63 |
# inet-filter-chain-OUTPUT |
... | ... | |
93 | 86 |
} |
94 | 87 |
} |
95 | 88 |
if $nftables::in_out_conntrack { |
96 |
nftables::rule { |
|
97 |
'OUTPUT-accept_established_related': |
|
98 |
order => '05', |
|
99 |
content => 'ct state established,related accept'; |
|
100 |
'OUTPUT-drop_invalid': |
|
101 |
order => '06', |
|
102 |
content => 'ct state invalid drop'; |
|
103 |
} |
|
89 |
include nftables::inet_filter::in_out_conntrack |
|
104 | 90 |
} |
105 | 91 |
|
106 | 92 |
# inet-filter-chain-FORWARD |
... | ... | |
126 | 112 |
} |
127 | 113 |
} |
128 | 114 |
if $nftables::fwd_conntrack { |
129 |
nftables::rule { |
|
130 |
'FORWARD-accept_established_related': |
|
131 |
order => '05', |
|
132 |
content => 'ct state established,related accept'; |
|
133 |
'FORWARD-drop_invalid': |
|
134 |
order => '06', |
|
135 |
content => 'ct state invalid drop'; |
|
136 |
} |
|
115 |
include nftables::inet_filter::fwd_conntrack |
|
137 | 116 |
} |
138 | 117 |
|
139 | 118 |
# basic outgoing rules |
manifests/inet_filter/fwd_conntrack.pp | ||
---|---|---|
1 |
# @summary enable conntrack for fwd |
|
2 |
class nftables::inet_filter::fwd_conntrack { |
|
3 |
nftables::rule { |
|
4 |
'FORWARD-accept_established_related': |
|
5 |
order => '05', |
|
6 |
content => 'ct state established,related accept'; |
|
7 |
'FORWARD-drop_invalid': |
|
8 |
order => '06', |
|
9 |
content => 'ct state invalid drop'; |
|
10 |
} |
|
11 |
} |
manifests/inet_filter/in_out_conntrack.pp | ||
---|---|---|
1 |
# @summary manage input & output conntrack |
|
2 |
class nftables::inet_filter::in_out_conntrack { |
|
3 |
nftables::rule { |
|
4 |
'INPUT-accept_established_related': |
|
5 |
order => '05', |
|
6 |
content => 'ct state established,related accept'; |
|
7 |
'INPUT-drop_invalid': |
|
8 |
order => '06', |
|
9 |
content => 'ct state invalid drop'; |
|
10 |
'OUTPUT-accept_established_related': |
|
11 |
order => '05', |
|
12 |
content => 'ct state established,related accept'; |
|
13 |
'OUTPUT-drop_invalid': |
|
14 |
order => '06', |
|
15 |
content => 'ct state invalid drop'; |
|
16 |
} |
|
17 |
} |
spec/classes/inet_filter/fwd_conntrack_spec.rb | ||
---|---|---|
1 |
# frozen_string_literal: true |
|
2 |
|
|
3 |
require 'spec_helper' |
|
4 |
|
|
5 |
describe 'nftables::inet_filter::fwd_conntrack' do |
|
6 |
on_supported_os.each do |os, _os_facts| |
|
7 |
context "on #{os}" do |
|
8 |
it { |
|
9 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-accept_established_related').with( |
|
10 |
target: 'nftables-inet-filter-chain-FORWARD', |
|
11 |
content: %r{^ ct state established,related accept$}, |
|
12 |
order: '05-nftables-inet-filter-chain-FORWARD-rule-accept_established_related-b' |
|
13 |
) |
|
14 |
} |
|
15 |
|
|
16 |
it { |
|
17 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-drop_invalid').with( |
|
18 |
target: 'nftables-inet-filter-chain-FORWARD', |
|
19 |
content: %r{^ ct state invalid drop$}, |
|
20 |
order: '06-nftables-inet-filter-chain-FORWARD-rule-drop_invalid-b' |
|
21 |
) |
|
22 |
} |
|
23 |
end |
|
24 |
end |
|
25 |
end |
spec/classes/inet_filter/in_out_conntrack_spec.rb | ||
---|---|---|
1 |
# frozen_string_literal: true |
|
2 |
|
|
3 |
require 'spec_helper' |
|
4 |
|
|
5 |
describe 'nftables::inet_filter::in_out_conntrack' do |
|
6 |
let(:pre_condition) { 'Exec{path => "/bin"}' } |
|
7 |
|
|
8 |
on_supported_os.each do |os, _os_facts| |
|
9 |
context "on #{os}" do |
|
10 |
it { |
|
11 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-accept_established_related').with( |
|
12 |
target: 'nftables-inet-filter-chain-INPUT', |
|
13 |
content: %r{^ ct state established,related accept$}, |
|
14 |
order: '05-nftables-inet-filter-chain-INPUT-rule-accept_established_related-b' |
|
15 |
) |
|
16 |
} |
|
17 |
|
|
18 |
it { |
|
19 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-drop_invalid').with( |
|
20 |
target: 'nftables-inet-filter-chain-INPUT', |
|
21 |
content: %r{^ ct state invalid drop$}, |
|
22 |
order: '06-nftables-inet-filter-chain-INPUT-rule-drop_invalid-b' |
|
23 |
) |
|
24 |
} |
|
25 |
|
|
26 |
it { |
|
27 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-accept_established_related').with( |
|
28 |
target: 'nftables-inet-filter-chain-OUTPUT', |
|
29 |
content: %r{^ ct state established,related accept$}, |
|
30 |
order: '05-nftables-inet-filter-chain-OUTPUT-rule-accept_established_related-b' |
|
31 |
) |
|
32 |
} |
|
33 |
|
|
34 |
it { |
|
35 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-drop_invalid').with( |
|
36 |
target: 'nftables-inet-filter-chain-OUTPUT', |
|
37 |
content: %r{^ ct state invalid drop$}, |
|
38 |
order: '06-nftables-inet-filter-chain-OUTPUT-rule-drop_invalid-b' |
|
39 |
) |
|
40 |
} |
|
41 |
end |
|
42 |
end |
|
43 |
end |
spec/classes/inet_filter_spec.rb | ||
---|---|---|
96 | 96 |
} |
97 | 97 |
|
98 | 98 |
it { |
99 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-accept_established_related').with( |
|
100 |
target: 'nftables-inet-filter-chain-INPUT', |
|
101 |
content: %r{^ ct state established,related accept$}, |
|
102 |
order: '05-nftables-inet-filter-chain-INPUT-rule-accept_established_related-b' |
|
103 |
) |
|
104 |
} |
|
105 |
|
|
106 |
it { |
|
107 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-drop_invalid').with( |
|
108 |
target: 'nftables-inet-filter-chain-INPUT', |
|
109 |
content: %r{^ ct state invalid drop$}, |
|
110 |
order: '06-nftables-inet-filter-chain-INPUT-rule-drop_invalid-b' |
|
111 |
) |
|
112 |
} |
|
113 |
|
|
114 |
it { |
|
115 | 99 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-jump_default_in').with( |
116 | 100 |
target: 'nftables-inet-filter-chain-INPUT', |
117 | 101 |
content: %r{^ jump default_in$}, |
... | ... | |
234 | 218 |
} |
235 | 219 |
|
236 | 220 |
it { |
237 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-accept_established_related').with( |
|
238 |
target: 'nftables-inet-filter-chain-OUTPUT', |
|
239 |
content: %r{^ ct state established,related accept$}, |
|
240 |
order: '05-nftables-inet-filter-chain-OUTPUT-rule-accept_established_related-b' |
|
241 |
) |
|
242 |
} |
|
243 |
|
|
244 |
it { |
|
245 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-drop_invalid').with( |
|
246 |
target: 'nftables-inet-filter-chain-OUTPUT', |
|
247 |
content: %r{^ ct state invalid drop$}, |
|
248 |
order: '06-nftables-inet-filter-chain-OUTPUT-rule-drop_invalid-b' |
|
249 |
) |
|
250 |
} |
|
251 |
|
|
252 |
it { |
|
253 | 221 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-jump_default_out').with( |
254 | 222 |
target: 'nftables-inet-filter-chain-OUTPUT', |
255 | 223 |
content: %r{^ jump default_out$}, |
... | ... | |
396 | 364 |
} |
397 | 365 |
|
398 | 366 |
it { |
399 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-accept_established_related') |
|
400 |
} |
|
401 |
|
|
402 |
it { |
|
403 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-drop_invalid') |
|
367 |
expect(subject).not_to contain_class('nftables::inet_filter::fwd_conntrack') |
|
404 | 368 |
} |
405 | 369 |
|
406 | 370 |
it { |
... | ... | |
685 | 649 |
end |
686 | 650 |
|
687 | 651 |
it { |
688 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-accept_established_related') |
|
689 |
} |
|
690 |
|
|
691 |
it { |
|
692 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-drop_invalid') |
|
693 |
} |
|
694 |
|
|
695 |
it { |
|
696 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-accept_established_related') |
|
652 |
expect(subject).not_to contain_class('nftables::inet_filter::in_out_conntrack') |
|
697 | 653 |
} |
698 | 654 |
|
699 | 655 |
it { |
700 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-OUTPUT-rule-drop_invalid')
|
|
656 |
expect(subject).not_to contain_class('nftables::inet_filter::fwd_conntrack')
|
|
701 | 657 |
} |
658 |
end |
|
702 | 659 |
|
703 |
it { |
|
704 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-accept_established_related') |
|
705 |
} |
|
660 |
context 'with fwd conntrack rules' do |
|
661 |
let(:params) do |
|
662 |
{ |
|
663 |
'fwd_conntrack' => true, |
|
664 |
} |
|
665 |
end |
|
706 | 666 |
|
707 | 667 |
it { |
708 |
expect(subject).not_to contain_concat__fragment('nftables-inet-filter-chain-FORWARD-rule-drop_invalid')
|
|
668 |
expect(subject).to contain_class('nftables::inet_filter::fwd_conntrack')
|
|
709 | 669 |
} |
710 | 670 |
end |
711 | 671 |
|
Formats disponibles : Unified diff