Home

Search Posts:

Archives

Login

September 2010

S M T W H F S
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30

Listing comments

Post Author Email Url Body
Systems administration with puppet j tad@vmdaemon.org Hi, Thanks for the interesting post. I've been experimenting with puppet and saw your mention of an optional additional template which gets appended if the $snmpextra variable is defined. Does this still work with current versions of puppet? I find if I include a second template based on an undefined variable, the client complains with "Could not find template /etc/puppet/modules/foo/templates/.erb ..." It'd certainly be handy to be able to have a standard configuration, with optional additional conf for specific hosts. Something like foo/$hostname/$extra.erb Thanks. Show Edit Destroy
Systems administration with puppet Jeremy jeremy.thornhill@gmail.com j - indeed it does still work, but you have to be careful to avoid trying to load an ERB that includes an undefined variable. The trick is to use a conditional to verify that the variable exists, and if it does then to load the extra template. I do this like so: if $snmpextra { file {"/etc/snmp/snmpd.conf": content => template("snmp/snmpd.conf.erb","snmp/$snmpextra.erb"), mode => 0640, alias => snmpconf, } } else { file {"/etc/snmp/snmpd.conf": content => template("snmp/snmpd.conf.erb"), mode => 0640, alias => snmpconf, } } There are limitations to this approach that do bother me a bit - you can only add one additional snippet, for example. Puppet's conditionals and variable capabilities have undergone substantial improvement since I first configured this, though, and there may well be a better way to do this now! Show Edit Destroy

New comment