Hi all,
I would Like to use TT to generate config files for a bunch of servers.
The sticky bit is that I need to allow exceptions, and not sure what the
best way to do this is.
Say I have 3 clusters with 3 types of servers:
All clusters contain Blue Servers, Red Servers, and Green Servers.
If I wanted to generate resolv.conf - that's simple enough, but I need to
allow exceptions based on what kind of server it is, and/or what cluster
it is in.
For example, the default nameserver should be 172.0.0.1, except for all
the blue servers in cluster 2 - they should use 172.0.0.2, and every
server in cluster 3 should use 172.0.0.3
One way I could do it, is to turn every variable into a rather large if
statement:
($cluster and $servertype are set in perl)
[% DEFAULT nameserver = 172.0.0.1 %]
[% "2" = { blue = { nameserver = 172.0.0.1 } } %]
[% "3" = { nameserver = 172.0.0.1 } %]
[% IF $cluster.$servertype.nameserver.defined %]
nameserver [% $cluster.$servertype.nameserver %]
[% ELSIF $servertype.nameserver.defined %]
nameserver [% $servertype.nameserver %]
[% ELSIF $cluster.nameserver.defined %]
nameserver [% $cluster.nameserver %]
[% ELSE %]
nameserver [% nameserver %]
[% END %]
If course, I would need to do this for *every* variable, which makes the
template files rather ugly, and a pain to maintain.
I'm wondering if there's a way to wrap that if statement into every
variable.
Is there an easier way? Am I missing something
Thanks.
--
John Ross
[email protected]
There's plenty of room for all God's creatures.
Right next to the mashed potatoes.
- Billboard ad for Saskatoon Restaurant
Greenville, SC
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates