У нас Puppet устанавливает определенные правила брандмауэра на рабочих станциях системного администратора. Недавно мы обнаружили, что некоторые системы были подключены к неправильным сетевым портам и смогли получить административный доступ к вещам на основе IP-адреса. Все эти системы используют Puppet, поэтому мы хотели, чтобы Puppet выходил из строя, если система находится в сети администратора и для нее не включены правильные правила брандмауэра.
Это отлично сработало вчера, а сегодня не работает, и я не могу понять, почему.
У нас есть фактор, создающий факты в формате vlan####_interface: eth0
и vlan###_ipaddress: 10.72.1.100
на основе реально существующих IP-адресов.
class profile::firewall_rulesets::vlan2501 {
firewall{"801 add some example firewall rule":
ensure => present,
chain => 'INPUT',
proto => 'tcp',
dport => '22',
source => ['10.72.1.0/24'],
state => ['NEW'],
action => 'accept',
}
}
class profile::base {
... other stuff ...
Firewall {
before => Class['::fw::post'],
require => Class['::fw::pre'],
}
include ::fw::pre
include ::fw::post
}
class fw::pre {
Firewall {
require => undef,
}
#ensure input rules are cleaned out, but ignore fail2ban
firewallchain { 'INPUT:filter:IPv4':
ensure => present,
ignore => '-j f2b-sshd',
purge => true,
}
firewallchain { 'f2b-sshd:filter:IPv4':
ignore => '-A f2b-sshd',
}
# Default firewall rules
firewall { '000 accept all icmp':
proto => 'icmp',
action => 'accept',
}
-> firewall { '001 accept all to lo interface':
proto => 'all',
iniface => 'lo',
action => 'accept',
}
-> firewall { '002 reject local traffic not on loopback interface':
proto => 'all',
iniface => '! lo',
destination => '127.0.0.1/8',
action => 'reject',
}
-> firewall { '003 accept related established rules':
proto => 'all',
state => ['RELATED', 'ESTABLISHED'],
action => 'accept',
}
}
class fw::post {
firewall { '999 drop all':
proto => 'all',
action => 'drop',
before => undef,
}
# This is set to be after all other firewall rules by profile::base
if $facts['vlan2501_ipaddress'] {
if (! defined( Class['profile::firewall_rulesets::vlan2501'] )) {
# We want to fail, not include the missing rules, because we want admins to be forced to verify all the other included manifests and make sure the machine is properly set up
fail( "An interface with an IP address is on VLAN 2501, but does not have the correct firewall rules. ${facts['vlan2501_interface']} => ${facts['vlan2501_ipaddress']}" )
}
}
}
class role::my_example_machine {
include ::profile::base
include ::profile::firewall_rulesets::vlan2501
... other stuff ...
}
Насколько я понимаю, так как fw::post
настроен на требование всех остальных Firewall
действия, проверка на Class['profile::firewall_rulesets::admin_workstation']
должно быть правдой, даже если оно включено после profile::base