On Tuesday, January 14, 2014 4:12:56 PM UTC-6, Justin Lambert wrote:
>
> I’m attempting to create a bunch of symlinks based on an array of 
> filenames but I can’t figure out how to use the title of the resource 
> within the resource itself.
>
> class app::config {  file { [ 'a.conf', 'b.conf' ]:    ensure => 'link',
>     path   => "/etc/app/${name}",
>     target => "/usr/app/${name}  }}
>
> $name and $title both equal app::config in this example.  Is what I’m 
> trying to do possible?
>
>

Resource declarations do not establish new scopes, so variable references 
inside mean the same thing they do outside.  Type *definitions* do 
establish scopes, however, so if you have enough of these to make it 
worthwhile then you can do it like so:

define app::link () {
  file { $title:
    ensure => 'link',
    path => "/etc/app/${title}",
    target => "/usr/app/${title}"

    # $name would work in place of $title, too
  }
}


class app::config {
  app::link { [ 'a.conf', 'b.conf' ]: }}



John

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/4aead5ad-322f-46eb-bd55-b7f81de091f4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to