On Sep 15, 2010, at 7:35 PM, タイ シー wrote: > Greetings > > I'm searching for an elegant way to contribute lines to an SNMP configuration > file from resources scattered throughout a given system's catalog, such that > from anywhere, the SNMP configuration file can be arbitrarily extended like > this: > > $snmp::lines += "proxy -m ${mib_file} -v 2c -c ${snmp_community} > localhost:1161 .1.3.6.1.4.1.42.2.145" > > Forgive me if this is a solved and documented problem. Querying Dr. Google > and the Puppet mailing list didn't reveal answers to me. I'm not sure if > virtual resources and stored configs appropriate, even though usage is > confined to one given system. The += operator appears ineffective, due to > scoping (?), even if I declare the following in the snmp class responsible > for generating snmpd.conf: > > class snmp { > $lines = [] > define line { > $lines += $name > } > ... > } > > Imagine in the theatre of the mind, if you will, snmp::jvm, postgres::server > et. al. each contribute one or more lines of text to snmpd.conf. > Concretely, perhaps a feasible implementation is where all of the contributed > lines in the aggregate are made available to the template engine via a > variable (an array of strings) when writing out the SNMP configuration file > ala > > file { "/etc/snmp/snmpd.conf": > content => template("..."), > ... > } > > Can this be achieved? Is it a naive approach, is there a better way? > I'm using Puppet 0.25.5 as acquired from EPEL.
Sounds like a job for Augeas or puppet-concat. I think puppet_concat would be a better fit. Augeas: http://docs.puppetlabs.com/references/stable/type.html#augeas puppet_concat: http://github.com/ripienaar/puppet-concat -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-us...@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.