Hi,
On 06/08/2011 10:40 PM, Toby wrote:> Hello all, sort of a puppet newbie here,
> 
> I have some constructs that are like so:
> 
> class hosts {
>    file {"/etc/hosts":
>       owner  => root,
>       group  => root,
>       mode   => 644,
>       source => ["puppet://puppet/files/etc/hosts.$hostname",
>                 
"puppet://puppet/files/etc/hosts.$operatingsystem",
>                  "puppet://puppet/files/etc/hosts"]
>    }
> }
> 
> And I have lots of them, for various reasons.  It seems like a real
> waste to have to keep on typing out those 3-5 lines for where the
> source of these things are from.  So I thought I could do something
> like the following.  Having all those variables in one place, being
> able
> to add to the search path easily:
> 
> $base = "puppet://puppet.foo.bar/files"
> 
> $search = [
>   "${base}/${host}",
>   "${base}/${operatingsystem}",
>   "${base}/default"
> ]
> 
> class hosts {
>    file {"/etc/hosts":
>       owner  => root,
>       group  => root,
>       mode   => 644,
>       source => "${search}/etc/hosts";
>    }
> }
you typically want to wrap your file resources in a define like
define remote_file($url="puppet://puppet.foo.bar/files",$path) {
  file { "$name": source => [
    "$url/$path.$host",
    "$url/$path.$operatingsystem",
    "$url/$path" ],
  }
}
There are some tricks to dynamically pass other file parameters, but
this is the gist of it.
HTH,
Felix
-- 
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.