[Fedora-livecd-list] Support for custom configuration using python templates
Mark McLoughlin
markmc at redhat.com
Wed May 16 17:28:50 UTC 2007
On Wed, 2007-05-16 at 17:56 +0100, Mark McLoughlin wrote:
> - The main reason, though, is that I wanted the derived iptables
> config to just add some rules rather than completely override the
> entire config. Can we do something similar with templating?
Here's a quick prototype of using templating. Hmm.
Cheers,
Mark.
-------------- next part --------------
class iptables {
$start = "*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
# disable all forwarding
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
# trust loopback device
-A INPUT -i lo -j ACCEPT
# allow ICMP
-A INPUT -p icmp --icmp-type any -j ACCEPT
# allow IPSec
-A INPUT -p 50 -j ACCEPT
-A INPUT -p 51 -j ACCEPT
# allow mDNS
-A INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
# allow CUPS browsing
-A INPUT -p udp -m udp --dport 631 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 631 -j ACCEPT
# allow packets for established connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
"
$end = "
-A INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
"
file { "iptables" :
path => "/tmp/iptables",
content => "$start\n$end\n"
}
}
class myiptables inherits iptables {
$ports = [ "22", "80" ]
$lines = template("/root/puppet/addport.erb")
File["iptables"] { content => "$start\n$lines\n$end\n" }
}
include myiptables
-------------- next part --------------
<% ports.each do |port| -%>-A INPUT -m state --state NEW -m tcp -p tcp --dport <%= port %> -j ACCEPT
<% end -%>
More information about the Fedora-livecd-list
mailing list