Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch the server naming #42

Merged
merged 1 commit into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions manifests/rules/out/puppet.pp
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# manage outgoing puppet
class nftables::rules::out::puppet (
duritong marked this conversation as resolved.
Show resolved Hide resolved
Variant[String,Array[String,1]] $puppetmaster,
Variant[Stdlib::IP::Address,Array[Stdlib::IP::Address,1]] $puppetserver,
Integer $puppetserver_port = 8140,
) {
any2array($puppetmaster).each |$index,$pm| {
Array($puppetserver, true).each |$index,$ps| {
nftables::rule {
"default_out-puppet-${index}":
}
if $pm =~ /:/ {
if $ps =~ Stdlib::IP::Address::V6 {
Nftables::Rule["default_out-puppet-${index}"] {
content => "ip6 daddr ${pm} tcp dport ${puppetserver_port} accept",
content => "ip6 daddr ${ps} tcp dport ${puppetserver_port} accept",
}
} else {
Nftables::Rule["default_out-puppet-${index}"] {
content => "ip daddr ${pm} tcp dport ${puppetserver_port} accept",
content => "ip daddr ${ps} tcp dport ${puppetserver_port} accept",
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/all_rules_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class { 'nftables':
include nftables::rules::out::http
include nftables::rules::out::ssh::remove
class{'nftables::rules::out::puppet':
puppetmaster => '127.0.0.1',
puppetserver => '127.0.0.1',
}
include nftables::rules::out::all
include nftables::rules::out::tor
Expand Down
42 changes: 42 additions & 0 deletions spec/classes/rules/out/puppet_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require 'spec_helper'

describe 'nftables::rules::out::puppet' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
let(:params) do
{ puppetserver: '1.2.3.4' }
end

context 'default options' do
it { is_expected.to compile }
it { is_expected.to contain_nftables__rule('default_out-puppet-0').with_content('ip daddr 1.2.3.4 tcp dport 8140 accept') }
end
context 'with different port' do
let(:params) do
super().merge({ puppetserver_port: 8141 })
end

it { is_expected.to compile }
it { is_expected.to contain_nftables__rule('default_out-puppet-0').with_content('ip daddr 1.2.3.4 tcp dport 8141 accept') }
end
context 'with ipv6 address' do
let(:params) do
{ puppetserver: 'fe80::1' }
end

it { is_expected.to compile }
it { is_expected.to contain_nftables__rule('default_out-puppet-0').with_content('ip6 daddr fe80::1 tcp dport 8140 accept') }
end
context 'with ipv6 & ipv4 address' do
let(:params) do
{ puppetserver: ['fe80::1', '1.2.3.4'] }
end

it { is_expected.to compile }
it { is_expected.to contain_nftables__rule('default_out-puppet-0').with_content('ip6 daddr fe80::1 tcp dport 8140 accept') }
it { is_expected.to contain_nftables__rule('default_out-puppet-1').with_content('ip daddr 1.2.3.4 tcp dport 8140 accept') }
end
end
end
end