Hello All, I recently found an excellent feature that I never knew about. I never knew that you could source an array of files and then have puppet figure out which one to use (like a case statement, within the source directive. An example of this would be: file { "/etc/sysctl.conf": source => [ "puppet://server/sysctl/sysctl.conf.$hostname", "puppet://server/sysctl/sysctl.conf.$tuningpolicy", "puppet://server/sysctl/sysctl.conf", ] } Is it possible to do the same thing with templates? An example of what I want to do is: file { "/etc/sysctl.conf": content => [ template("sysctl.conf.$hostname.erb"), template("sysctl.conf.$tuningpolicy.erb"), template("sysctl.conf.erb"), ] } Thank you very much for the help. -Tom --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Jul 23, 2009, at 1:58 PM, TomTom wrote:> Is it possible to do the same thing with templates? > An example of what I want to do is: > > file { "/etc/sysctl.conf": > content => [ > template("sysctl.conf.$hostname.erb"), > template("sysctl.conf.$tuningpolicy.erb"), > template("sysctl.conf.erb"), > ] > }Directly this feature is not available. Here is an example I''ve used for exim that may suit your needs. content => $directadmin_exim ? { ''antispam'' => template(''directadmin/exim/ exim.antispam.conf.erb''), ''local'' => template(''directadmin/exim/ exim.local.conf.erb''), ''custom'' => template("directadmin/exim/hosts/exim.$ {hostname}.conf.erb"), default => template(''directadmin/exim/ exim.default.conf.erb''), }, -L -- Larry Ludwig Reductive Labs --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, On 23.07.2009, at 19:58, TomTom wrote:> Is it possible to do the same thing with templates? > An example of what I want to do is: > > file { "/etc/sysctl.conf": > content => [ > template("sysctl.conf.$hostname.erb"), > template("sysctl.conf.$tuningpolicy.erb"), > template("sysctl.conf.erb"), > ] > }Unfortunately, the behaviour here is different. All templates outputs are concatenated... see: http://reductivelabs.com/trac/puppet/wiki/FunctionReference#template Maybe one would like to have the same behaviour as with file. I was once in the sitauton where I wanted exactly that. Unfortunatly, it does not work that way. udo. -- :: udo waechter - root@zoide.net :: N 52º16''30.5" E 8º3''10.1" :: genuine input for your ears: http://auriculabovinari.de :: your eyes: http://ezag.zoide.net :: your brain: http://zoide.net
hmmm, right after sending the provious mail, I realised something: On 23.07.2009, at 21:27, Udo Waechter wrote:> Hi, > > On 23.07.2009, at 19:58, TomTom wrote: > >> Is it possible to do the same thing with templates? >> An example of what I want to do is: >> >> file { "/etc/sysctl.conf": >> content => [ >> template("sysctl.conf.$hostname.erb"), >> template("sysctl.conf.$tuningpolicy.erb"), >> template("sysctl.conf.erb"), >> ] >> } > > Unfortunately, the behaviour here is different. All templates > outputs are concatenated... > > see: http://reductivelabs.com/trac/puppet/wiki/FunctionReference#template >this is different call: file{"/foo/bar": content => template("template1","template2") } yields concatenated templates. maybe this: file { "/etc/sysctl.conf": content => [ template("sysctl.conf.$hostname.erb"), template("sysctl.conf.$tuningpolicy.erb"), template("sysctl.conf.erb"), ] } works as expected, namely to select the one template that exists (or the first that exists). dunno, udo. -- :: udo waechter - root@zoide.net :: N 52º16''30.5" E 8º3''10.1" :: genuine input for your ears: http://auriculabovinari.de :: your eyes: http://ezag.zoide.net :: your brain: http://zoide.net
It doesn''t seem to work from me, bombing out if the template specified first doesn''t exist. you''d expect it to gracefully ignore and try the next...this a bug? running puppet-0.24.6-1.1 On Jul 23, 12:31 pm, Udo Waechter <udo.waech...@uni-osnabrueck.de> wrote:> hmmm, right after sending the provious mail, I realised something: > > On 23.07.2009, at 21:27, Udo Waechter wrote: > > > > > Hi, > > > On 23.07.2009, at 19:58, TomTom wrote: > > >> Is it possible to do the same thing with templates? > >> An example of what I want to do is: > > >> file { "/etc/sysctl.conf": > >> content => [ > >> template("sysctl.conf.$hostname.erb"), > >> template("sysctl.conf.$tuningpolicy.erb"), > >> template("sysctl.conf.erb"), > >> ] > >> } > > > Unfortunately, the behaviour here is different. All templates > > outputs are concatenated... > > > see:http://reductivelabs.com/trac/puppet/wiki/FunctionReference#template > > this is different call: > > file{"/foo/bar": > content => template("template1","template2") > > } > > yields concatenated templates. > > maybe this: > file { "/etc/sysctl.conf": > content => [ > template("sysctl.conf.$hostname.erb"), > template("sysctl.conf.$tuningpolicy.erb"), > template("sysctl.conf.erb"), > ] > > } > > works as expected, namely to select the one template that exists (or > the first that exists). > > dunno, > udo. > > -- > :: udo waechter - r...@zoide.net :: N 52º16''30.5" E 8º3''10.1" > :: genuine input for your ears:http://auriculabovinari.de > :: your eyes:http://ezag.zoide.net > :: your brain:http://zoide.net > > smime.p7s > 2KViewDownload--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---