Reputation: 2080
Is it possible to control execution of create_resources function ? Say I have a class and a definition:
define do::something($a, $b) {
exec { .. }
exec { .. }
}
class do::foo {
$params = {
'a' => { .. },
'b' => { .. }
}
exec {'I need to run first': ... }
create_resources('do::something', $params)
}
In my case I use do::something
to add keys to a key/value store. But I need to first wait for exec
to refresh this store. If exec
after create_resources
than those keys will not be in the the key/value store as the refresh will remove them.
I have tried using the ->
approach and notify => Exec[]
but I'm unsure how to pass params in this case. create_resource
has it's own condition weather it will execute but it needs to be called every time just after the exec
.
Upvotes: 1
Views: 286
Reputation: 180103
Like all Puppet functions, create_resources()
runs during catalog building. Each catalog is completely built before any resource declared in it is applied, and often on a different machine than the one for which it is intended. What you appear to be after is not modulating the behavior of create_resources()
, but rather managing the relative order of application of the resources it adds to the catalog.
And that you can readily do with a chain operator and a resource collector. For example, add
Exec['I need to run first'] -> Do::Something<||>
to the body of class do::foo
. There are a lot of possible variations on that, and also a few alternative approaches, but I would need details of the specific use case to make stronger or more specific recommendations.
Upvotes: 1