Let’s say I have:
$files = ["file1", "file2"]
exec { "exec1" :
command => "mycommand";
}
file { $files :
ensure => present;
}
And I want to use the -> and ~> constructs to control the notify/require order of execution, like so:
Exec["exec1"] -> File[$files]
How do I do it?
If I do the above, I get Could not find resource 'File[file1]File[file2]' (for real file paths, of course). I’ve played with wrapping the $files variable in quotes and {}s, but to no avail.
What’s the syntax for putting an array variable of resource names into an ordering chain?
You can use the ‘What is in an array’ hint from this great list of hints from R.I.Pienaar:
First define a function that handles the chaining, then pass in your array to the function.
The function will get called once for each item in the array.
Code sample time:
The output of ‘puppet apply test.pp’ on puppet 2.7.11 on Ubuntu 12.04 gives: