安装puppetlabs-firewall模块

有没有人有经验在Ubuntu 12.04上设置puppetlabs-firewall模块?

https://github.com/puppetlabs/puppetlabs-firewall上的文档声明:

目前,您需要提供一些设置,使其不在我们提供的模块中,以支持正确的sorting,清除和防火墙的持久性。

所以build议您在某处(如site.pp)提供以下顶级范围:

# Always persist firewall rules exec { 'persist-firewall': command => $operatingsystem ? { 'debian' => '/sbin/iptables-save > /etc/iptables/rules.v4', /(RedHat|CentOS)/ => '/sbin/iptables-save > /etc/sysconfig/iptables', }, refreshonly => true, } 
 # These defaults ensure that the persistence command is executed after # every change to the firewall, and that pre & post classes are run in the # right order to avoid potentially locking you out of your box during the # first puppet run. Firewall { notify => Exec['persist-firewall'], before => Class['my_fw::post'], require => Class['my_fw::pre'], } Firewallchain { notify => Exec['persist-firewall'], } # Purge unmanaged firewall resources # # This will clear any existing rules, and make sure that only rules # defined in puppet exist on the machine resources { "firewall": purge => true } 

我很难理解它是如何工作的。 当我把它放在最高的范围内时,它将locking我所有的傀儡主人。 我不想将这个模块的防火墙规则应用到我所有的木偶主机上,而只是一个testing目的的子集。 由于我使用shorewall为我的大多数主机,只是试图控制由puppet防火墙,而不是通过分发shorewallconfiguration文件。 有没有人有一个在Ubuntu的工作设置,我可以分配一个防火墙到特定主机configuration最小的重复? 一个例子会真正帮助我。

为了充分理解模块工作在$module_path/firewall/lib/puppet/{type|proider}/*的作用,它们全部用Ruby编写。 即使你不懂这门语言,也很容易理解。

正如注释中所提到的,你的清单中的附加代码是一个解决scheme,所以模块能正常工作。 我想他们有一些问题,直接在types/提供者通过ruby实现所有的代码。 使用默认的iptables-savefunction是有意义的,因为重启后重新加载防火墙设置要容易得多,而且它适用于大多数stream行的linux发行版。

即使复制/粘贴该代码,也不会影响当前的configuration,只要不在节点默认或节点configuration中使用资源types即可。 为了testing目的,直接在testing节点中包含这个代码。 应该产生相同的结果。 上面是一个例子:

  Firewall { notify => Exec["persist-firewall"], before => Class['my_fw::post'], require => Class['my_fw::pre'], } Firewallchain { notify => Exec['persist-firewall'], } resources { "firewall": purge => true } firewall { '100 ssh 22': port => '22', proto => 'tcp', action => 'accept', } firewall { '100 www 80': port => '80', proto => 'tcp', action => 'accept', } firewall { '100 sql 5436': port => '5436', proto => 'tcp', action => 'accept', } firewall { '100 sql 5438': port => '5438', proto => 'tcp', action => 'accept', } firewall { '100 sql 5440': port => '5440', proto => 'tcp', action => 'accept', } exec { "persist-firewall": command => $operatingsystem ? { "debian" => "/sbin/iptables-save > /etc/iptables/rules.v4", /(RedHat|CentOS)/ => "/sbin/iptables-save > /etc/sysconfig/iptables", }, refreshonly => 'true', } 

在这个例子中,我允许22,80,5436,5438 INCOMING TCP连接。