russell.fulton
2010-Nov-19 03:19 UTC
[Puppet Users] using an array to generate several files to down load via erb
Hi I have a requirement to generate several very similar config files which are just a couple of tokens different and with different names. These are barnyard conf files if anyone is interested and differ only in the interface name which is also part of the file name. I can include [eth1, eth2] in the manifest and I want to get files: barnyard.conf.eth1 ..... interface eth1 ........... barnyard.conf.eth2 ..... interface eth2 ........... I could generate these outside puppet but I am trying to get as much of the setp into puppet as I can. Russell -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Daniel Pittman
2010-Nov-19 04:13 UTC
Re: [Puppet Users] using an array to generate several files to down load via erb
"russell.fulton" <russell.fulton@gmail.com> writes: I am going to mostly use this as a soapbox to expound on how I do this sort of thing, but will answer your questions along the way. I hope you don''t mind. :)> I have a requirement to generate several very similar config files > which are just a couple of tokens different and with different names....so, at this point I am thinking that this is a pretty clear case for modelling each individual configuration file as a puppet ''define'', because you can have more than one of them, and they are almost-but-not-quite identical.> These are barnyard conf files if anyone is interested and differ only in the > interface name which is also part of the file name. I can include [eth1, > eth2] in the manifest and I want to get files:So, I would look to something like this: modules/barnyard/manifests/config.pp define barnyard::config () { file { "/path/to/config.${name}": # ... content => template(''barnyard/config.erb'') } modules/barnyard/templates/config.erb [<%= name %>] # ... manifests/nodes.pp node "example.com" { barnyard::config { ["eth0", "eth1"]: } # ...or do I want this: barnyard::config { split($interfaces, '',''): } } Anyway, the essential point is that when you identify a collection of things that are similar but not identical, and are all related to a single "product" you generally want to use a ''define'' to model them. Look to where your software management treats things like objects and instances in traditional programming, and leverage that to model the data. Regards, Daniel -- ✣ Daniel Pittman ✉ daniel@rimspace.net ☎ +61 401 155 707 ♽ made with 100 percent post-consumer electrons -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Seemingly Similar Threads
- Best practices for building a file from distributed data.
- variables created with generate() function have a newline when used in a template
- Passing node hostname to the Puppet managed node
- Idletimeout patch, third attempt
- [LLVMdev] llvm_fcmp_ord and llvm_fcmp_uno and assembly code generation