On 01/14/2014 05:12 PM, 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?
> 
> I’m running puppet 3.4.0.
> 
> Thanks,
> Justin
> 

It is, but you have to use a define (or at least how I'm doing it uses a
define), here's an example based on something thing I'm doing:

common.pp:
class my_module::common () {
...

my_module::common::my_symlinks { ['file1', 'file2', 'file3']: }

...
}

common/my_symlinks.pp:
define my_module::common::my_symlinks: {
    file { "symlink_${name}":
      ensure  => link,
      path    => "/some/path/${name}",
      target  => "/some/other/path/${name}",
    }
}

I wasn't the first to figure that out, I think I remember who I got it
from, but I'm not sure if it's something they came up with or if they
got it from somewhere else.  Hope that helps.

-- 
Joseph Swick <joseph.sw...@meltwater.com>
Operations Engineer
Meltwater Group

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to