Hello, We have close to 10 nodes running puppet agent, and currently all of them download same file from puppet master. Current definition: file { /etc/test.conf: mode => 440, owner => root, group => root, content => template(''vem/test.conf.erb'') } New definition: We want this file to be download host specific. so that unique file is downloaded for each host based on the host name. Is this doable. Appreciate any guidance with this problem. Thanks, Mani -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
Peter Bukowinski
2013-Jul-10 14:04 UTC
Re: [Puppet Users] How to download host specific file
On Jul 9, 2013, at 8:36 PM, Mani Devarajan <manidevarajan@gmail.com> wrote:> Hello, > We have close to 10 nodes running puppet agent, and currently all of them download same file from puppet master. > > Current definition: > file { /etc/test.conf: > mode => 440, > owner => root, > group => root, > content => template(''vem/test.conf.erb'') > } > > New definition: > We want this file to be download host specific. so that unique file is downloaded for each host based on the host name. > Is this doable. Appreciate any guidance with this problem. > > Thanks, > ManiMani, this is where facts come into play. If your requirements per hostname are fairly unique, you can have a different template for each hostname, using something like this: $test_template = "vem/test.conf-${hostname}.erb" file { ''/etc/test.conf'': ensure => file, owner => ''root'', group => ''root'', mode => ''0440'', content => template($test_template) } This would populate the /etc/test.conf file on a node named node1 with the contents of, for example, the vem/test.conf-node1.erb template. If the differences between each hostname''s conf file are small, you should put your logic within the existing test.conf.erb template: # exact match example <% if @hostname == ("node1") then -%> option1 = <%= some_facter_fact %> <% end -%> # inverse match example <% if @hostname != ("node1") then -%> option1 = <%= another_facter_fact %> <% end -%> # this or that match <% if @hostname == ("node3" or "node4") then -%> option2 = <%= a_different_facter_fact %> <% end -%> You can get a list of all the facts puppet knows about by running ''facter --puppet'' on your nodes. -- Peter Bukowinski -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.