It's been a while since you asked this, but I didn't see a followup;
forgive the noise if you've already got an answer.

Wolf Noble <wno...@datapipe.com> posted a solution to this problem
in September that I've been holding onto because I think it's
elegant:

  * Wolf Noble <wnoble at datapipe.com> [2011/09/01 18:45]:
  > Here's what I've been doing, fwiw:
  > 
  > file { 'nsswitch.conf':
  >   path => '/etc/nsswitch.conf',
  >   content => inline_template(
  >     file(
  >       
"/etc/puppet/modules/dist/ldapclient/templates/etc/nsswitch.conf.$hostname.erb",
  >       
"/etc/puppet/modules/dist/ldapclient/templates/etc/nsswitch.conf.$deviceid.erb",
  >       
"/etc/puppet/modules/dist/ldapclient/templates/etc/nsswitch.conf.$clientid.erb",
  >       
"/etc/puppet/modules/dist/ldapclient/templates/etc/nsswitch.conf.erb")),
  >   ensure => file,
  >   owner => root, group => 0, mode => 0644;
  > }
  > 
  > 
  > not sure about the elegance or lack thereof, contained within,
  > but it seems to work until there's a "better way" to do it

The file() function returns the contents of the first of its
arguments that exists, and ignores the rest of the argument list, so
this effectively does what you're asking for.  The one downside to
this is that it doesn't honor puppet:// parameters, but you could
get around that by using a separate file { } resource.


* Chris Hirsch <chris at base2technology.com> [2011/11/30 13:29]:
> Hi all,
> 
> I'm trying to figure out if I can serve a certain template that
> matches a hostname or serve the default like I could if this was
> just a file.
> 
> Works:
> file { '/etc/yum.conf':
>     ensure  => file,
>     source => ["puppet://puppet/yum/yum.conf.$hostname",
>                       "puppet://puppet/yum/yum.conf"],
>   }
> 
> Trying to figure out:
> file {'/etc/yum.conf':
>     ensure  => file,
>     content => ["template("yum/yum.conf.$hostname.erb"),
>                 " template("yum/yum.conf.erb")],
>   }
> 
> There is this issue http://projects.puppetlabs.com/issues/5158 that
> seems related but I can't figure out if this is possible.

-- 
If you want to change the world then start by changing the world
around you.
    -- Andy Wardley

-- 
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.

Reply via email to