如何打开使用Puppetpipe理的盒子上的端口80

我有一个pipe理近20个节点的木偶主虚拟机。 我在这些节点之一安装了Nagios,为了让Nagios GUI工作,我需要停止在那个nagios盒子上的iptables。 问题是,无论何时Puppet运行它将重新启动iptables服务。 我已经尝试在nagios模块server.pp文件中添加这样的服务没有工作。 它说,iptables服务已经定义,不能有重复:

service { iptables: ensure => stopped, } 

另外,我试过使用exec命令

 exec { "open-port-80": command => "sudo iptables -I INPUT 14 -m state --state NEW -p tcp --dport 80 -j ACCEPT", path => "${os_path}", unless => "sudo iptables-save | grep 80 | grep INPUT | grep ACCEPT | grep NEW | wc -l | xargs test 1 -eq", notify => Exec["ip-tables-save"] } exec { "ip-tables-save": command => "sudo service iptables save", # refreshonly => true, # path => "${os_path}", } 

还尝试了下面的代码,但没有运气:

 if defined("iptables") and defined(Class['iptables']) { iptables::add_tcp_stateful_listen { 'nagios-core': client_nets => '[nagios node IP address here]/32', dports => '80', } } 

有人可以帮我吗?

提前致谢

我不推荐完全closuresiptables,而是build议使用Puppetlabs防火墙模块来pipe理防火墙/ iptables:

$ puppet模块安装puppetlabs-firewall

那么你可以写一些这样的木偶:

 firewall { '100 Allow http and https access': port => [80, 443], proto => tcp, action => accept, }