Depending on how complex the hosts file needs to be, what LenR may be best 
or I have sometimes also approached this kind of issue by using 
parameterized classes can work well too. You can use a define classname 
($variables_to_pass_to_template) { } and then you don't have to work with 
ERB-type conditionals. Its a matter of preference in my opinion. So it 
would do something like this:

define location-based-hosts ($my_specific_hosts) {

file { "etc/hosts":
    ensure => present,
    content => template("puppet:///hosts/hosts_template.erb"),
    }
}

Then call it with:

hosts::location-based-hosts { "us-west":
    my_specific_hosts => "list of the important host entries",
}

And finally, in the hosts_template.erb:

127.0.0.1 localhost
<%= my_specific_hosts %>

The syntax should be good but I may have missed something. Again its all 
matter of preference but I have all my templates set up this way, that way 
my templates look as close to the end file as possible and all the "magic" 
happens in my manifests. 


>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/-ttLBhVQCiUJ.
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.

Reply via email to