On Apr 5, 4:47 am, Pablo Fernandez <pablo.fernan...@cscs.ch> wrote:
> Dear all,
>
> I have a class where I declare one file and many execs with
> create_resources:
>
> class module::yeah {
>    file {"myfile"}
>    $hash = parseyaml(inline_template('hereigeneratemynicehash.to_yaml'))
>    create_resources ('exec', $hash)
>
> }
>
> And I need to create a dependency of the kind inside that class:
> File["myfile"] -> Exec[*]
>
> I have tried setting "require" => File['myfile'] inside my template, but
> File is not recognized inside the template. And if I quote it, Puppet
> does not recognize it as a File resource.
>
> Do you guys see a way how I can create the dependency?


I see at least two possibilities:

1) Use resource chaining and tag-selected collections:
1a) either automatic tags: File["myfile"] -> Exec<| tag =
'module::yeah' |>
1b) or manual tags: File["myfile"] -> Exec<| tag = 'tag-I-explicitly-
declared-via-my-hash' |>

2) Use resource defaults:
class module::yeah {
   file { 'myfile': }

   # I think this is scoped to the class:
   Exec { require => File['myfile'] }

   $hash =
parseyaml(inline_template('hereigeneratemynicehash.to_yaml'))
   create_resources ('exec', $hash)
}


Test these, of course.  I am uncertain whether create_resources() has
different semantics in these cases than would ordinary resource
declarations.


John

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