On Fri, Mar 27, 2009 at 9:26 AM, Tom Brown <[email protected]> wrote:
>
> how can i cascade this more so that i have perhaps 5 or even 10 if
> statements ? ie if myhost does not match one of the 10 given then dont do
> anything ?
>
> #set myloc = $getVar("hostname","")split('.')[2]
> #if $myloc == "foo"
> echo 'relayhost         = mail.foo' >> /etc/postfix/main.cf;
> #elif $myloc == "bar"
> echo 'relayhost         = mail.bar' >> /etc/postfix/main.cf;
> #elif $myloc == "baz"
> echo 'relayhost         = mail.baz' >> /etc/postfix/main.cf;
> #else $myloc == "more"
> echo 'relayhost         = mail.more' >> /etc/postfix/main.cf;
> #end if
>
> etc etc ??

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.

r...@cobbler1: snippets # cobbler system getks --name server1.foo
echo 'relayhost = mail2.foo" >> /etc/postfix/main.cf

r...@cobbler1: snippets # cobbler system getks --name server1.bar
echo 'relayhost = evil.admin.workstation" >> /etc/postfix/main.cf

r...@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 =)

-- 
Jeff Schroeder

Don't drink and derive, alcohol and analysis don't mix.
http://www.digitalprognosis.com
_______________________________________________
cobbler mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/cobbler

Reply via email to