Skip to content

Commit

Permalink
Made ctdb rule parameterized
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed Jan 18, 2021
1 parent 1ee2f66 commit e743f82
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
12 changes: 8 additions & 4 deletions manifests/rules/samba.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# manage in samba/ctdb
class nftables::rules::samba {
class nftables::rules::samba (
Boolean $ctdb = false,
) {
nftables::rule {
'default_in-netbios_tcp':
content => 'tcp dport {139,445} accept',
Expand All @@ -10,8 +12,10 @@
content => 'udp dport {137,138} accept',
}

nftables::rule {
'default_in-ctdb':
content => 'tcp dport 4379 accept',
if ($ctdb) {
nftables::rule {
'default_in-ctdb':
content => 'tcp dport 4379 accept',
}
}
}
14 changes: 14 additions & 0 deletions spec/classes/rules/samba_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@
it { is_expected.to compile }
it { is_expected.to contain_nftables__rule('default_in-netbios_tcp').with_content('tcp dport {139,445} accept') }
it { is_expected.to contain_nftables__rule('default_in-netbios_udp').with_content('udp dport {137,138} accept') }
it { is_expected.not_to contain_nftables__rule('default_in-ctdb').with_content('tcp dport 4379 accept') }
end

context 'with ctdb set' do
let(:params) do
{
ctdb: true,
}
end

it { is_expected.to compile }
it { is_expected.to contain_nftables__rule('default_in-netbios_tcp').with_content('tcp dport {139,445} accept') }
it { is_expected.to contain_nftables__rule('default_in-netbios_udp').with_content('udp dport {137,138} accept') }
it { is_expected.to contain_nftables__rule('default_in-ctdb').with_content('tcp dport 4379 accept') }
end
end
end
Expand Down

0 comments on commit e743f82

Please sign in to comment.