Listing comments
| Post | Author | 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