diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2022-01-08 15:50:26 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2022-01-08 15:50:26 -0300 |
commit | 3d1cf84f39fece3f2a9f8b7247a792212eb81177 (patch) | |
tree | f1fa5ca591908d363d13d30256f7af3b242d2d6b /manifests/virtual | |
parent | 55fa862bae8e2582e5ac0c008a0bb0ec53d9bfff (diff) | |
download | puppet-firewall-3d1cf84f39fece3f2a9f8b7247a792212eb81177.tar.gz puppet-firewall-3d1cf84f39fece3f2a9f8b7247a792212eb81177.tar.bz2 |
Feat: major refactor
Diffstat (limited to 'manifests/virtual')
-rw-r--r-- | manifests/virtual/dns.pp | 58 | ||||
-rw-r--r-- | manifests/virtual/gitd.pp | 27 | ||||
-rw-r--r-- | manifests/virtual/gobby.pp | 27 | ||||
-rw-r--r-- | manifests/virtual/http.pp | 27 | ||||
-rw-r--r-- | manifests/virtual/https.pp | 27 | ||||
-rw-r--r-- | manifests/virtual/icecast.pp | 27 | ||||
-rw-r--r-- | manifests/virtual/jabber.pp | 59 | ||||
-rw-r--r-- | manifests/virtual/mail.pp | 71 | ||||
-rw-r--r-- | manifests/virtual/mdns.pp | 16 | ||||
-rw-r--r-- | manifests/virtual/mumble.pp | 27 | ||||
-rw-r--r-- | manifests/virtual/munin.pp | 40 | ||||
-rw-r--r-- | manifests/virtual/rsync.pp | 16 | ||||
-rw-r--r-- | manifests/virtual/ssh.pp | 38 | ||||
-rw-r--r-- | manifests/virtual/tor.pp | 90 | ||||
-rw-r--r-- | manifests/virtual/web.pp | 12 | ||||
-rw-r--r-- | manifests/virtual/yacy.pp | 16 |
16 files changed, 115 insertions, 463 deletions
diff --git a/manifests/virtual/dns.pp b/manifests/virtual/dns.pp index 1bf3872..8ae02ae 100644 --- a/manifests/virtual/dns.pp +++ b/manifests/virtual/dns.pp @@ -1,53 +1,9 @@ -class firewall::virtual::dns($destination, $zone = 'vm') { - shorewall::rule { 'dns-route-0': - action => 'DNS/ACCEPT', - source => 'net', - destination => '$FW', - proto => '-', - destinationport => '-', - ratelimit => '-', - order => 2000, - } - - shorewall::rule { 'dns-route-1': - action => 'DNAT', - source => 'net', - destination => "$zone:$destination:53", - proto => 'tcp', - destinationport => '53', - ratelimit => '-', - order => 2001, - } - - shorewall::rule { 'dns-route-2': - action => 'DNAT', - source => '$FW', - destination => "fw:$destination:53", - proto => 'tcp', - destinationport => '53', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 2002, - } - - shorewall::rule { 'dns-route-3': - action => 'DNAT', - source => 'net', - destination => "$zone:$destination:53", - proto => 'udp', - destinationport => '53', - ratelimit => '-', - order => 2003, - } - - shorewall::rule { 'dns-route-4': - action => 'DNAT', - source => '$FW', - destination => "fw:$destination:53", - proto => 'udp', - destinationport => '53', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 2004, +class firewall::virtual::dns( + $implementation = lookup('firewall::implementation', undef, undef, 'shorewall'), + $destination, $zone = 'vm' +) { + class { "firewall::implementations::${implementation}::virtual::dns": + destination => $destination, + zone => $zone, } } diff --git a/manifests/virtual/gitd.pp b/manifests/virtual/gitd.pp index b760f03..aedca34 100644 --- a/manifests/virtual/gitd.pp +++ b/manifests/virtual/gitd.pp @@ -1,23 +1,8 @@ -class firewall::virtual::gitd($destination) { - shorewall::rule { 'git-daemon-1': - action => 'DNAT', - source => 'net', - destination => "vm:$destination:9418", - proto => 'tcp', - destinationport => '9418', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 800, - } - - shorewall::rule { 'git-daemon-2': - action => 'DNAT', - source => 'vm', - destination => "fw:$destination:9418", - proto => 'tcp', - destinationport => '9418', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 801, +class firewall::virtual::gitd( + $implementation = lookup('firewall::implementation', undef, undef, 'shorewall'), + $destination +) { + class { "firewall::implementations::${implementation}::virtual::gitd": + destination => $destination, } } diff --git a/manifests/virtual/gobby.pp b/manifests/virtual/gobby.pp index cc2c9fe..a05f154 100644 --- a/manifests/virtual/gobby.pp +++ b/manifests/virtual/gobby.pp @@ -1,23 +1,8 @@ -class firewall::virtual::gobby($destination) { - shorewall::rule { 'gobby-0': - action => 'DNAT', - source => 'vm', - destination => "fw:$destination:6523", - proto => 'tcp', - destinationport => '6523', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 2400, - } - - shorewall::rule { 'gobby-1': - action => 'DNAT', - source => 'net', - destination => "vm:$destination:6523", - proto => 'tcp', - destinationport => '6523', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 2400, +class firewall::virtual::gobby( + $implementation = lookup('firewall::implementation', undef, undef, 'shorewall'), + $destination +) { + class { "firewall::implementations::${implementation}::virtual::gobby": + destination => $destination, } } diff --git a/manifests/virtual/http.pp b/manifests/virtual/http.pp index bb8e232..3050eb3 100644 --- a/manifests/virtual/http.pp +++ b/manifests/virtual/http.pp @@ -1,23 +1,8 @@ -class firewall::virtual::http($destination) { - shorewall::rule { 'http-route-1': - action => 'DNAT', - source => 'vm', - destination => "fw:$destination:80", - proto => 'tcp', - destinationport => '80', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 600, - } - - shorewall::rule { 'http-route-2': - action => 'DNAT', - source => 'net', - destination => "vm:$destination:80", - proto => 'tcp', - destinationport => '80', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 601, +class firewall::virtual::http( + $implementation = lookup('firewall::implementation', undef, undef, 'shorewall'), + $destination +) { + class { "firewall::implementations::${implementation}::virtual::http": + destination => $destination, } } diff --git a/manifests/virtual/https.pp b/manifests/virtual/https.pp index 70a10a4..c93dc01 100644 --- a/manifests/virtual/https.pp +++ b/manifests/virtual/https.pp @@ -1,23 +1,8 @@ -class firewall::virtual::https($destination) { - shorewall::rule { 'https-route-1': - action => 'DNAT', - source => 'vm', - destination => "fw:$destination:443", - proto => 'tcp', - destinationport => '443', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => lookup("firewall::ssl_ratelimit", undef, undef, '-'), - order => 602, - } - - shorewall::rule { 'https-route-2': - action => 'DNAT', - source => 'net', - destination => "vm:$destination:443", - proto => 'tcp', - destinationport => '443', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => lookup("firewall::ssl_ratelimit", undef, undef, '-'), - order => 602, +class firewall::virtual::https( + $implementation = lookup('firewall::implementation', undef, undef, 'shorewall'), + $destination +) { + class { "firewall::implementations::${implementation}::virtual::https": + destination => $destination, } } diff --git a/manifests/virtual/icecast.pp b/manifests/virtual/icecast.pp index 3c392b6..684ce42 100644 --- a/manifests/virtual/icecast.pp +++ b/manifests/virtual/icecast.pp @@ -1,22 +1,9 @@ -class firewall::virtual::icecast($destination, $zone = 'fw') { - shorewall::rule { 'icecast-1': - action => 'DNAT', - source => 'net', - destination => "$zone:$destination:8000", - proto => 'tcp', - destinationport => '8000', - ratelimit => '-', - order => 900, - } - - shorewall::rule { 'icecast-2': - action => 'DNAT', - source => '$FW', - destination => "$zone:$destination:8000", - proto => 'tcp', - destinationport => '8000', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 901, +class firewall::virtual::icecast( + $implementation = lookup('firewall::implementation', undef, undef, 'shorewall'), + $destination, $zone = 'fw' +) { + class { "firewall::implementations::${implementation}::virtual::icecast": + destination => $destination, + zone => $zone, } } diff --git a/manifests/virtual/jabber.pp b/manifests/virtual/jabber.pp index 703b9a9..7666f22 100644 --- a/manifests/virtual/jabber.pp +++ b/manifests/virtual/jabber.pp @@ -1,54 +1,9 @@ -class firewall::virtual::jabber($destination, $zone = 'fw') { - shorewall::rule { 'jabber-0': - action => 'DNAT', - source => 'net', - destination => "$zone:$destination:5222", - proto => 'tcp', - destinationport => '5222', - ratelimit => '-', - order => 2200, - } - - shorewall::rule { 'jabber-1': - action => 'DNAT', - source => '$FW', - destination => "$zone:$destination:5223", - proto => 'tcp', - destinationport => '5223', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 2201, - } - - shorewall::rule { 'jabber-2': - action => 'DNAT', - source => 'net', - destination => "$zone:$destination:5269", - proto => 'tcp', - destinationport => '5269', - ratelimit => '-', - order => 2202, - } - - shorewall::rule { 'jabber-3': - action => 'DNAT', - source => '$FW', - destination => "$zone:$destination:4369", - proto => 'tcp', - destinationport => '4369', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 2203, - } - - shorewall::rule { 'jabber-4': - action => 'DNAT', - source => '$FW', - destination => "$zone:$destination:4370", - proto => 'tcp', - destinationport => '4370:4375', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 2204, +class firewall::virtual::jabber( + $implementation = lookup('firewall::implementation', undef, undef, 'shorewall'), + $destination, $zone = 'fw' +) { + class { "firewall::implementations::${implementation}::virtual::jabber": + destination => $destination, + zone => $zone, } } diff --git a/manifests/virtual/mail.pp b/manifests/virtual/mail.pp index c16f898..2bf9635 100644 --- a/manifests/virtual/mail.pp +++ b/manifests/virtual/mail.pp @@ -1,67 +1,8 @@ -class firewall::virtual::mail($destination) { - shorewall::rule { 'mail-1': - action => 'DNAT', - source => 'vm', - destination => "fw:$destination:25", - proto => 'tcp', - destinationport => '25', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 1000, - } - - shorewall::rule { 'mail-2': - action => 'DNAT', - source => 'net', - destination => "vm:$destination:25", - proto => 'tcp', - destinationport => '25', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 1001, - } - - shorewall::rule { 'mail-3': - action => 'DNAT', - source => 'vm', - destination => "fw:$destination:993", - proto => 'tcp', - destinationport => '993', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => lookup("firewall::ssl_ratelimit", undef, undef, '-'), - order => 1002, - } - - shorewall::rule { 'mail-4': - action => 'DNAT', - source => 'net', - destination => "vm:$destination:993", - proto => 'tcp', - destinationport => '993', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => lookup("firewall::ssl_ratelimit", undef, undef, '-'), - order => 1003, - } - - shorewall::rule { 'mail-5': - action => 'DNAT', - source => 'vm', - destination => "fw:$destination:587", - proto => 'tcp', - destinationport => '587', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => lookup("firewall::ssl_ratelimit", undef, undef, '-'), - order => 1004, - } - - shorewall::rule { 'mail-6': - action => 'DNAT', - source => 'net', - destination => "vm:$destination:587", - proto => 'tcp', - destinationport => '587', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => lookup("firewall::ssl_ratelimit", undef, undef, '-'), - order => 1005, +class firewall::virtual::mail( + $implementation = lookup('firewall::implementation', undef, undef, 'shorewall'), + $destination +) { + class { "firewall::implementations::${implementation}::virtual::mail": + destination => $destination, } } diff --git a/manifests/virtual/mdns.pp b/manifests/virtual/mdns.pp index db8ec25..559a00b 100644 --- a/manifests/virtual/mdns.pp +++ b/manifests/virtual/mdns.pp @@ -1,11 +1,9 @@ -class firewall::virtual::mdns($destination, $zone = 'fw') { - shorewall::rule { 'mdns-0': - action => 'DNAT', - source => 'net', - destination => "$zone:$destination:5353", - proto => 'tcp', - destinationport => '5353', - ratelimit => '-', - order => 2700, +class firewall::virtual::mdns( + $implementation = lookup('firewall::implementation', undef, undef, 'shorewall'), + $destination, $zone = 'fw' +) { + class { "firewall::implementations::${implementation}::virtual::mdns": + destination => $destination, + zone => $zone, } } diff --git a/manifests/virtual/mumble.pp b/manifests/virtual/mumble.pp index b523dca..a091363 100644 --- a/manifests/virtual/mumble.pp +++ b/manifests/virtual/mumble.pp @@ -1,22 +1,9 @@ -class firewall::virtual::mumble($destination, $zone = 'fw') { - shorewall::rule { 'mumble-0': - action => 'DNAT', - source => 'net', - destination => "$zone:$destination:64738", - proto => 'tcp', - destinationport => '64738', - ratelimit => '-', - order => 2300, - } - - shorewall::rule { 'mumble-1': - action => 'DNAT', - source => '$FW', - destination => "$zone:$destination:64738", - proto => 'udp', - destinationport => '64738', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 2301, +class firewall::virtual::mumble( + $implementation = lookup('firewall::implementation', undef, undef, 'shorewall'), + $destination, $zone = 'fw' +) { + class { "firewall::implementations::${implementation}::virtual::mumble": + destination => $destination, + zone => $zone, } } diff --git a/manifests/virtual/munin.pp b/manifests/virtual/munin.pp index 79514c6..531acd9 100644 --- a/manifests/virtual/munin.pp +++ b/manifests/virtual/munin.pp @@ -1,28 +1,16 @@ -define firewall::virtual::munin($destination, $port_orig, $port_dest = '', $order = '400', $zone = 'fw') { - shorewall::rule { "munin-$name-1": - action => 'DNAT', - source => 'net', - destination => $port_dest ? { - '' => "$zone:$destination", - default => "$zone:$destination:$port_dest", - }, - proto => 'tcp', - destinationport => "$port_orig", - ratelimit => '-', - order => $order, - } - - shorewall::rule { "munin-$name-2": - action => 'DNAT', - source => '$FW', - destination => $port_dest ? { - '' => "$zone:$destination", - default => "$zone:$destination:$port_dest", - }, - proto => 'tcp', - destinationport => "$port_orig", - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => $order, +define firewall::virtual::munin( + $destination, + $port_orig, + $port_dest = '', + $order = '400', + $zone = 'fw' + $implementation = lookup('firewall::implementation', undef, undef, 'shorewall'), +) { + class { "firewall::implementations::${implementation}::virtual::munin": + destination => $destination, + port_orig => $port_orig, + port_dest => $port_dest, + order => $order, + zone => $zone, } } diff --git a/manifests/virtual/rsync.pp b/manifests/virtual/rsync.pp index 50df46c..79a8d83 100644 --- a/manifests/virtual/rsync.pp +++ b/manifests/virtual/rsync.pp @@ -1,11 +1,9 @@ -class firewall::virtual::rsync($destination, $zone = 'fw') { - shorewall::rule { 'rsync-0': - action => 'DNAT', - source => 'net', - destination => "$zone:$destination:873", - proto => 'tcp', - destinationport => '873', - ratelimit => '-', - order => 2600, +class firewall::virtual::rsync( + $implementation = lookup('firewall::implementation', undef, undef, 'shorewall'), + $destination, $zone = 'fw' +) { + class { "firewall::implementations::${implementation}::virtual::rsync": + destination => $destination, + zone => $zone, } } diff --git a/manifests/virtual/ssh.pp b/manifests/virtual/ssh.pp index 7ad93fc..0a11fa2 100644 --- a/manifests/virtual/ssh.pp +++ b/manifests/virtual/ssh.pp @@ -1,28 +1,14 @@ -define firewall::virtual::ssh($destination, $port_orig = '22', $port_dest = '', $zone = 'vm') { - shorewall::rule { "ssh-$name-1": - action => 'DNAT', - source => 'net', - destination => $port_dest ? { - '' => "$zone:$destination", - default => "$zone:$destination:$port_dest", - }, - proto => 'tcp', - destinationport => "$port_orig", - ratelimit => '-', - order => "2$port_orig", - } - - shorewall::rule { "ssh-$name-2": - action => 'DNAT', - source => '$FW', - destination => $port_dest ? { - '' => "fw:$destination", - default => "fw:$destination:$port_dest", - }, - proto => 'tcp', - destinationport => "$port_orig", - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => "2$port_orig", +define firewall::virtual::ssh( + $destination, + $port_orig = '22', + $port_dest = '', + $zone = 'vm' + $implementation = lookup('firewall::implementation', undef, undef, 'shorewall'), +) { + class { "firewall::implementations::${implementation}::virtual::ssh": + destination => $destination, + port_orig => $port_orig, + port_dest => $port_dest, + zone => $zone, } } diff --git a/manifests/virtual/tor.pp b/manifests/virtual/tor.pp index 7cca6d6..2b83151 100644 --- a/manifests/virtual/tor.pp +++ b/manifests/virtual/tor.pp @@ -1,85 +1,9 @@ -class firewall::virtual::tor($destination, $zone = 'vm') { - shorewall::rule { 'tor-0': - action => 'DNAT', - source => 'net', - destination => "$zone:$destination:9000", - proto => 'tcp', - destinationport => '9000', - ratelimit => '-', - order => 2100, - } - - shorewall::rule { 'tor-1': - action => 'DNAT', - source => '$FW', - destination => "fw:$destination:9000", - proto => 'tcp', - destinationport => '9000', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 2101, - } - - shorewall::rule { 'tor-2': - action => 'DNAT', - source => 'net', - destination => "$zone:$destination:9001", - proto => 'tcp', - destinationport => '9001', - ratelimit => '-', - order => 2102, - } - - shorewall::rule { 'tor-3': - action => 'DNAT', - source => '$FW', - destination => "fw:$destination:9001", - proto => 'tcp', - destinationport => '9001', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 2103, - } - - shorewall::rule { 'tor-4': - action => 'DNAT', - source => 'net', - destination => "$zone:$destination:9100", - proto => 'tcp', - destinationport => '9100', - ratelimit => '-', - order => 2104, - } - - shorewall::rule { 'tor-5': - action => 'DNAT', - source => '$FW', - destination => "fw:$destination:9100", - proto => 'tcp', - destinationport => '9100', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 2105, - } - - shorewall::rule { 'tor-6': - action => 'DNAT', - source => 'net', - destination => "$zone:$destination:9101", - proto => 'tcp', - destinationport => '9101', - ratelimit => '-', - order => 2106, - } - - shorewall::rule { 'tor-7': - action => 'DNAT', - source => '$FW', - destination => "fw:$destination:9101", - proto => 'tcp', - destinationport => '9101', - originaldest => lookup('firewall::external_ip', undef, undef, $::ipaddress), - ratelimit => '-', - order => 2107, +class firewall::virtual::tor( + $implementation = lookup('firewall::implementation', undef, undef, 'shorewall'), + $destination, $zone = 'vm' +) { + class { "firewall::implementations::${implementation}::virtual::tor": + destination => $destination, + zone => $zone, } } diff --git a/manifests/virtual/web.pp b/manifests/virtual/web.pp index 06bf993..c54a95b 100644 --- a/manifests/virtual/web.pp +++ b/manifests/virtual/web.pp @@ -1,14 +1,8 @@ define firewall::virtual::web( + $implementation = lookup('firewall::implementation', undef, undef, 'shorewall'), $destination ) { - shorewall::rule { "web-route-${name}-1": - action => 'DNAT', - source => 'vm', - destination => "fw:${destination}:80", - proto => 'tcp', - destinationport => '80', - originaldest => $destination, - ratelimit => '-', - order => 600, + class { "firewall::implementations::${implementation}::virtual::web": + destination => $destination, } } diff --git a/manifests/virtual/yacy.pp b/manifests/virtual/yacy.pp index 173ba13..fcc6b1d 100644 --- a/manifests/virtual/yacy.pp +++ b/manifests/virtual/yacy.pp @@ -1,11 +1,9 @@ -class firewall::virtual::yacy($destination, $zone = 'fw') { - shorewall::rule { 'yacy-0': - action => 'DNAT', - source => 'net', - destination => "$zone:$destination:8090", - proto => 'tcp', - destinationport => '8090', - ratelimit => '-', - order => 2500, +class firewall::virtual::yacy( + $implementation = lookup('firewall::implementation', undef, undef, 'shorewall'), + $destination, $zone = 'fw' +) { + class { "firewall::implementations::${implementation}::virtual::yacy": + destination => $destination, + zone => $zone, } } |