Parent Post: Systems administration with puppet
Author: Jeremy
Email: jeremy.thornhill@gmail.com
Url:
Body: 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!
Edit | Back