[Fedora-livecd-list] Support for custom configuration using python templates
Mark McLoughlin
markmc at redhat.com
Wed May 16 16:56:17 UTC 2007
On Thu, 2007-04-26 at 10:29 +0100, Mark McLoughlin wrote:
> On Tue, 2007-04-24 at 14:53 -0400, John (J5) Palmieri wrote:
>
> > One of the things we need to for OLPC from the LiveCD creator is the
> > ability to output configuration files from a template.
>
> One thing I've been meaning to do for a while, based on David
> Lutterkort's suggestion, is to try using puppet[1] from the
> livecd-creator ... i.e. run puppet from %post with a manifest that would
> change whatever configuration files you need. One reason puppet might be
> nice is that it does inheritance, templating etc.
I gave this a shot. What I did was:
- Packaged, in an RPM, a manifest for changing the iptables config
- Demonstrated a form of inheritance - i.e. there's a base iptables
configuration, and the manifest adds to that
- Installed puppet and the manifest RPM via the kickstart package list
- In %post, passed the manifest to puppet and then removed puppet
again
See the attached kickstart file and puppet files.
So, some comments:
- I don't want to have to require setting up a puppet server in order
to build images
- Having to package the manifest in an RPM sucks, we should probably
have support for copying the manifest into the chroot e.g.
$> livecd-creator -t raw -c ./test-image.ks -p iptables.pp --p myiptables.pp
- One reason why I include the iptables config inline in the puppet
manifest is that I don't like having stuff scattered over many
different files
- 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?
- This is all fairly clunky, is there a better way?
Cheers,
Mark.
-------------- next part --------------
lang en_US.UTF-8
keyboard us
timezone US/Eastern
auth --useshadow --enablemd5
selinux --enforcing
firewall --disabled
network --device eth0 --bootproto dhcp
repo --name=fedora --baseurl=file:///redhat/rawhide-latest/x86_64
repo --name=puppet --baseurl=file:///redhat/rawhide-latest/puppet-repo
%packages
bash
kernel-xen
syslinux
passwd
policycoreutils
chkconfig
authconfig
rootfiles
# in order to add a tty on /dev/xvc0
kudzu
# in order to bring eth0 up
dhclient
# let's play around with iptables
iptables
myiptables
# for config changes in %post
puppet
%post
# turn on swap probing
sed -i -e 's/AUTOSWAP=no/AUTOSWAP=yes/' /etc/sysconfig/init
puppet /etc/puppet/myiptables.pp
# get rid of puppet again
rpm -e myiptables puppet facter ruby ruby-libs
-------------- next part --------------
$iptables_base = "*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
"
$iptables_final = "
-A INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
"
class iptables {
file { "iptables" :
path => "/etc/sysconfig/iptables",
content => "$iptables_base$iptables_final"
}
service { "iptables" :
enable => true
}
}
-------------- next part --------------
import "iptables.pp"
class myiptables inherits iptables {
$iptables_config = "
# Allow SSH and HTTP
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
"
File["iptables"] { content => "$iptables_base$iptables_config$iptables_final" }
}
include myiptables
More information about the Fedora-livecd-list
mailing list