Potentially easier, you could use prefix($scripts, '/path/'), which comes 
from puppetlabs-stdlib to put the path on all members of the array. Then 
just pass the now prefixed array to the defined type described above. This 
avoids storing the script names externally, which may or may not be 
desirable. If the scripts you want in cron might change now and then, then 
the external lookup is the better way.

On Wednesday, April 2, 2014 4:07:04 PM UTC-7, Christopher Wood wrote:
>
> Check out defined types. For a faked together example: 
>
> define make_it_so::make_one_thing_so { 
>   cron { $title: 
>     command => "/path/$title", 
>     user    => 'deploy', 
>     hour    => '*/4', 
>     minute  => '0', 
>   } 
> } 
>
> http://docs.puppetlabs.com/learning/definedtypes.html 
>
>
> Then add a data structure which you will presumably retrieve from hiera: 
>
> $scripts = { 
>   'a.rb' => {}, 
>   'b.rb' => {}, 
> } 
>
> http://docs.puppetlabs.com/hiera/1/ 
>
>
> Then use create_resources to make as many of these as you need, without 
> putting arrays or hashes in your puppet code ($scripts here will be 
> automatically looked up via hiera): 
>
> class make_it_so ( 
>   $scripts = {} 
> ) { 
>   create_resources('make_it_so::make_one_thing_so', $scripts) 
> } 
>
> http://docs.puppetlabs.com/references/latest/function.html#createresources 
>
>
>
>
> On Wed, Apr 02, 2014 at 03:03:42PM -0700, Joaquin Menchaca wrote: 
> >    Is there a way to do something like this: 
> > 
> >    class make_it_so { 
> >      $scripts = ["a.rb", "b.rb"] 
> > 
> >      cron { $scripts: 
> >        command     => "/path/$scripts", 
> >        user        => 'deploy', 
> >        hour        => '*/4', 
> >        minute      => '0', 
> >      } 
> > 
> >    } 
> > 
> >    The attribute usage of the array will just take the entire array 
> >    concatenated together. :'( 
> > 
> >    I would like to have each resource declaration have a correspond to a 
> >    matching element of the array 
> > 
> >    I would like the attribute with $scripts to match to the iteration of 
> the 
> >    resource declaration $scripts. 
> > 
> >    -- 
> >    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 [1]puppet-users...@googlegroups.com <javascript:>. 
> >    To view this discussion on the web visit 
> >    [2]
> https://groups.google.com/d/msgid/puppet-users/6db6cb93-e9c4-4a42-91e7-36aa7583b5e1%40googlegroups.com.
>  
>
> >    For more options, visit [3]https://groups.google.com/d/optout. 
> > 
> > References 
> > 
> >    Visible links 
> >    1. mailto:puppet-users+unsubscr...@googlegroups.com <javascript:> 
> >    2. 
> https://groups.google.com/d/msgid/puppet-users/6db6cb93-e9c4-4a42-91e7-36aa7583b5e1%40googlegroups.com?utm_medium=email&utm_source=footer
>  
> >    3. https://groups.google.com/d/optout 
>

-- 
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/d3cc21c1-05d9-4c58-8e5f-65e60254c391%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to