This is a followup question from Configure providers from variables, in a generic way
I wrapped some providers into definitions and I was wondering how to handle the notifies. I succeeded in writing a cheap implementation where I can pass an array of arrays, similar to this:
provider_definition name do
component $some_component
notifies [[:redeploy, "docker_container[some_container]", :immediately],
[:redeploy, "docker_container[some_other_cntr]", :delayed]]
end
And then in my definition I have something like this:
params[:notifies].each do |notify_action, resource_name, notify_time|
notifies notify_action, resource_name, notify_time
end
Surely there is a better way of doing this? I was hoping that I could keep the same kind of format in the recipe:
provider_definition name do
component $some_component
notifies :redeploy, "docker_container[some_container]", :immediately
notifies :redeploy, "docker_container[some_other_cntr]", :delayed
end
But when I do this, only the last notifies makes it to my definition.
Sticking with definitions you already have the better way I think.
An option to achieve what you wish would be to turn your definition into a LWRP, this will create a custom resource which can takes notify attributes as any other chef resource.
docker_library/resources/my_deploy.rb
docker_library/provider/my_deploy.rb
I may be wrong on the type for the component, I let you adapt to your specific case. Written from memory, I may have forget something, there's more documentation here on LWRP.
And same as before in recipe, just that the LWRP name will be derived from cookbook name and file name, so in this case: