-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #974 from lsst-it/IT-4777/default-firewall
(common) setup default firewall rules
- Loading branch information
Showing
10 changed files
with
260 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ lookup_options: | |
ccs_software::udp_properties: | ||
merge: | ||
strategy: "unique" | ||
profile::core::ipset::set: | ||
ipset::sets: | ||
merge: | ||
strategy: "deep" | ||
rsyslog::config::actions: | ||
|
@@ -63,6 +63,9 @@ lookup_options: | |
profile::core::ipa::default: | ||
merge: | ||
strategy: "deep" | ||
profile::core::firewall::firewall: | ||
merge: | ||
strategy: "deep" | ||
profile::core::systemd::tmpfile: | ||
merge: | ||
strategy: "deep" | ||
|
@@ -321,16 +324,34 @@ yum::manage_os_default_repos: true | |
|
||
letsencrypt::email: "[email protected]" | ||
|
||
profile::core::ipset::set: | ||
# lsst/aura "internal" prefixes | ||
lsst: | ||
ipset::sets: | ||
# rubin/aura "internal" prefixes | ||
aura: | ||
ensure: "present" | ||
type: "hash:net" | ||
set: | ||
- "140.252.0.0/16" | ||
- "139.229.0.0/16" | ||
- "198.19.0.0/16" | ||
- "10.0.0.0/8" | ||
# rubin "internal" prefixes | ||
rubin: | ||
ensure: "present" | ||
type: "hash:net" | ||
set: | ||
- "139.229.134.0/23" | ||
- "139.229.136.0/21" | ||
- "139.229.144.0/20" | ||
- "139.229.160.0/19" | ||
- "139.229.192.0/18" | ||
- "140.252.146.0/23" | ||
- "198.19.0.0/16" | ||
- "10.0.0.0/8" | ||
ayekan: # ayekan cluster | ||
ensure: "present" | ||
type: "hash:net" | ||
set: | ||
- "139.229.144.0/26" | ||
|
||
# sssd ipa client setup -- do not use on ipa servers | ||
sssd::main_config: | ||
|
@@ -465,3 +486,47 @@ nm::conf: | |
dns: "none" | ||
|
||
prometheus::node_exporter::version: "1.6.1" | ||
|
||
# profile::core::firewall is not included by default; including it in a role is | ||
# used to opt-in to configuring filtering instead of the default of disabling | ||
# it. Eventually, filtering should be enabled by default and roles would have | ||
# to opt-out. | ||
profile::core::firewall::purge_firewall: true | ||
profile::core::firewall::firewall: | ||
# 000-099 reserved for common rules | ||
# 100-199 reserved for site rules | ||
# 200-299 reserved for role rules | ||
# 400-599 reserved for host specific rules | ||
# 700-899 reserved for role rules | ||
# 800-899 reserved for site rules | ||
# 900-999 reserved for common rules | ||
"000 accept established": | ||
proto: "all" | ||
state: ["RELATED", "ESTABLISHED"] | ||
action: "accept" | ||
"001 accept all icmp": | ||
proto: "icmp" | ||
action: "accept" | ||
"002 accept all loopback": | ||
proto: "all" | ||
iniface: "lo" | ||
action: "accept" | ||
"010 accept ssh": | ||
proto: "tcp" | ||
state: "NEW" | ||
ipset: "rubin src" | ||
dport: "22" | ||
action: "accept" | ||
require: "Ipset::Set[rubin]" | ||
"020 accept dhcp": | ||
proto: "udp" | ||
sport: ["67", "68"] | ||
dport: ["67", "68"] | ||
action: "accept" | ||
"990 reject all": | ||
proto: "all" | ||
action: "reject" | ||
"991 reject forward all": | ||
chain: "FORWARD" | ||
proto: "all" | ||
action: "reject" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,12 @@ accounts::user_list: | |
- "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDsF9VQ7wjm0Rm/1HA6Zc94IAkhqol5cwT44MwwR6uzDyo+/tqa8awUnmVF+RyiJaR6NEKO6YhjkIPga7rDQJerCMLg/xfFzpRcKSi+Xw5YCQ3Z+4P8XZrICM2vzDV6rBELl4n8Bzk6ncXOcKwbUitw3aj6bJNduv6hGrhkJKlWob+cXGH+KZwDiLX82hxsWmktRWcwDEaXTFWq6dahg3/0niAojkfo2ZlJtRblSEgUBf7JITeXBGYAunAeUYE93xUC9tB1OIzisQLQKCFM2OgSjnO4NSx2r4nIPYhEOEhBnNBqF9mPqalRjoyimvF+lu/vsZ43r7nZyV4RwYbyfmVL [email protected]" | ||
|
||
profile::core::common::disable_ipv6: true | ||
|
||
profile::core::firewall::firewall: | ||
"100 accept node_exporter": | ||
proto: "tcp" | ||
state: "NEW" | ||
ipset: "ayekan src" | ||
dport: "9100" | ||
action: "accept" | ||
require: "Ipset::Set[ayekan]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'profile::core::firewall' do | ||
on_supported_os.each do |os, facts| | ||
context "on #{os}" do | ||
let(:facts) { facts } | ||
|
||
it { is_expected.to compile.with_all_deps } | ||
it { is_expected.to contain_class('firewall') } | ||
it { is_expected.to contain_class('ipset') } | ||
it { is_expected.to have_resources_resource_count(0) } | ||
it { is_expected.to have_firewall_resource_count(0) } | ||
|
||
context 'with purge_firewall param' do | ||
let(:params) { { purge_firewall: true } } | ||
|
||
it { is_expected.to contain_resources('firewall').with_purge(true) } | ||
end | ||
|
||
context 'with firewall param' do | ||
let(:params) do | ||
{ | ||
firewall: { | ||
'001 accept all icmp' => { | ||
'proto' => 'icmp', | ||
'action' => 'accept', | ||
}, | ||
}, | ||
} | ||
end | ||
|
||
it do | ||
is_expected.to contain_firewall('001 accept all icmp').with( | ||
'proto' => 'icmp', | ||
'action' => 'accept', | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# frozen_string_literal: true | ||
|
||
shared_examples 'firewall default' do |facts:| | ||
if (facts[:os]['family'] == 'RedHat') && (facts[:os]['release']['major'] == '9') | ||
it { is_expected.to contain_service('nftables').with_enable(true) } | ||
end | ||
|
||
it { is_expected.to contain_service('iptables').with_enable(true) } | ||
it { is_expected.to contain_resources('firewall').with_purge(true) } | ||
|
||
it do | ||
is_expected.to contain_firewall('000 accept established').with( | ||
proto: 'all', | ||
state: %w[RELATED ESTABLISHED], | ||
action: 'accept', | ||
) | ||
end | ||
|
||
it do | ||
is_expected.to contain_firewall('001 accept all icmp').with( | ||
proto: 'icmp', | ||
action: 'accept', | ||
) | ||
end | ||
|
||
it do | ||
is_expected.to contain_firewall('002 accept all loopback').with( | ||
proto: 'all', | ||
iniface: 'lo', | ||
action: 'accept', | ||
) | ||
end | ||
|
||
it do | ||
is_expected.to contain_firewall('020 accept dhcp').with( | ||
proto: 'udp', | ||
sport: %w[67 68], | ||
dport: %w[67 68], | ||
action: 'accept', | ||
) | ||
end | ||
|
||
it do | ||
is_expected.to contain_firewall('990 reject all').with( | ||
proto: 'all', | ||
action: 'reject', | ||
) | ||
end | ||
|
||
it do | ||
is_expected.to contain_firewall('991 reject forward all').with( | ||
chain: 'FORWARD', | ||
proto: 'all', | ||
action: 'reject', | ||
) | ||
end | ||
end | ||
|
||
shared_examples 'firewall node_exporter scraping' do |site:| | ||
case site | ||
when 'dev', 'ls' | ||
it do | ||
is_expected.to contain_firewall('100 accept node_exporter').with( | ||
proto: 'tcp', | ||
state: 'NEW', | ||
ipset: 'ayekan src', | ||
dport: '9100', | ||
action: 'accept', | ||
require: 'Ipset::Set[ayekan]', | ||
) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# frozen_string_literal: true | ||
|
||
shared_examples 'ipset' do | ||
it { is_expected.to contain_class('ipset') } | ||
|
||
it do | ||
is_expected.to contain_ipset__set('aura').with_set( | ||
%w[ | ||
140.252.0.0/16 | ||
139.229.0.0/16 | ||
198.19.0.0/16 | ||
10.0.0.0/8 | ||
], | ||
) | ||
end | ||
|
||
it do | ||
is_expected.to contain_ipset__set('rubin').with_set( | ||
%w[ | ||
139.229.134.0/23 | ||
139.229.136.0/21 | ||
139.229.144.0/20 | ||
139.229.160.0/19 | ||
139.229.192.0/18 | ||
140.252.146.0/23 | ||
198.19.0.0/16 | ||
10.0.0.0/8 | ||
], | ||
) | ||
end | ||
|
||
it do | ||
is_expected.to contain_ipset__set('ayekan').with_set( | ||
%w[ | ||
139.229.144.0/26 | ||
], | ||
) | ||
end | ||
end |