On Thu, Apr 12, 2012 at 11:39 AM, Marek Dohojda <chro...@gmail.com> wrote:
> Hello > > Thank you > Unfortunately this won't help me at the moment because the files are > different completely and not just few parameters. I need different > templates based on hostname. > I am fully aware that I can use "if" but well..ahm.. its ugly :) > > Right, If you used something like Hiera you could do a lookup on a variable (like $foo_content for example) and hiera would pass a different value for the content attribute based on the hostname of the machine. So if it were one hostname you could get something like "template('module/first_template.erb')" and another hostname would return a value of "template('module/second_template.erb')". Then, in the declaration, you could do: file { '/path/to/file': ensure => present, content => $foo_content, } Your Puppet code would be generic (only using a variable) and all your data would be determined in Hiera. If you're interested in this method, there's also a blog post for using Hiera here --> http://puppetlabs.com/blog/first-look-installing-and-using-hiera/ > > > > On Thu, Apr 12, 2012 at 10:53 AM, Gary Larizza <g...@puppetlabs.com>wrote: > >> Hey Marek, >> >> Templates do have different functionality here - they will concatenate >> arrays of templates (i.e. if you pass more than one template, it >> concatenates them all together into one file). You might want to check out >> the blog on separating data from code ( >> http://puppetlabs.com/blog/the-problem-with-separating-data-from-puppet-code/) >> to see ways that you can specify that piece of data entirely separate from >> your puppet code. >> >> >> >> On Thu, Apr 12, 2012 at 9:42 AM, Marek Dohojda <chro...@gmail.com> wrote: >> >>> Sorry if this has been asked, but Google has failed me and I haven't >>> been able to find an answer. >>> >>> With a source one can declare array so that if file exist puppet will >>> pull it out first, if not move to the next file in this fashion: >>> >>> source => ["puppet:///conf/httpd_$hostname.conf", >>> "puppet:///conf/httpd.conf", >>> ], >>> >>> To the best of my knowledge one can't do that with a Template (at least as >>> of 0.24, I am hoping this has changed). >>> >>> What is the recommended way of dealing with this? >>> >>> I do know that I can have an "if" statement within a class/module to go >>> like this: >>> >>> >>> >>> if $hostname { >>> content =... >>> >>> However that isn't as clean as being able to do this from within the same >>> array as "source". That way instead of keep having to add "if/else" I can >>> simply add a file as needed. >>> >>> >>> >>> Thank you! >>> >>> >>> -- >>> 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+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/puppet-users?hl=en. >>> >> >> >> >> -- >> >> Gary Larizza >> Professional Services Engineer >> Puppet 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+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/puppet-users?hl=en. >> > > -- > 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+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > -- Gary Larizza Professional Services Engineer Puppet 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.