Thats overkill for what it looks like you're trying to do. Here
is a
snippet that
does what it looks like you're trying to do:
================ put this in /var/lib/cobbler/snippets/relay_host ===
#if $getVar("system_name","") != ""
#set hostname = $getVar('system_name').split('.')
#import re
## If system_name is server1.foo: hostname[0] == server1 and
hostname[1] = foo
#set location = re.match('^([a-z]|[0-9])+', $hostname[1].lower()).group()
#set relayhost = "mail." + $location
#if $location == "foo"
#set relayhost = "mail2.foo"
#elif $location == "bar"
#set relayhost = "evil.admin.workstation"
#end if
echo 'relayhost = $relayhost" >> /etc/postfix/main.cf
#end if
=====================================================
I made a profile named test with a kickstart only including the line
below. Put that snippet line under your %post in the kickstart
template.
$SNIPPET('relay_host')
So this allows you to set explicit relay hosts for locations named foo
or bar and sets mail.$location for everything else.
root@cobbler1: snippets # cobbler system getks --name server1.foo
echo 'relayhost = mail2.foo" >> /etc/postfix/main.cf
root@cobbler1: snippets # cobbler system getks --name server1.bar
echo 'relayhost = evil.admin.workstation" >> /etc/postfix/main.cf
root@cobbler1: snippets # cobbler system getks --name server1.office
echo 'relayhost = mail.office" >> /etc/postfix/main.cf
Like I said earlier, by learning a bit of cheetah/python you can make
this much more concise. If you have a different hostname you'll need
to change the regex on the line that sets "location". Read the docs
and then ask more questions =)
thanks for this - for me hostname is good to use as thats actually the
FQDN and from that i can work out the DC the box is in. At the moment i
have to worry about 6 DC's but this is likely to increase and i just
want common ks's and snippets between them. I take the first parameter
of the hostname to work out the box role and from that can work out what
packages to install, again all by using a common kickstart and snippet set.
i am getting to grips with this slowly but alas its not coming super
quick but getting there one bit at a time.
thanks