- From: "Mark J. Reed" <
>
- To:
- Subject: [chef] Modelling a collection of resources as an LWRP
- Date: Mon, 14 Feb 2011 16:01:03 -0500
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=MALMjWJOHm2OzMLllN3+QouaUVoHR/af5Sc2g7eaHU5Y3Kaz3YI438LbUoX1dipDur AgLrg12yIk4GQ+47HNYGQNoOXODeZz3+rvBsRjK7ig4ueyqZl1BL6eaWA5hi++G5gwRs x+/LD3wyUrEgsRjdgh3wiYEhLGO1vM66x7Uic=
I have a set of resources that I want to invoke as a single unit, that will notify other resources if any of the sub-resources would do so.
One such set could be modeled as its own recipe, I want to be able to include multiple instances in other recipes - and you can only include another given recipe once.
So I was thinking an LWRP. Say I want to create a group, a user who belongs to that group, a file owned by that user, and a service that requires that file to exist, in one swell foop. The provider could look like this:
action :create do
resources = Hash.new []
resources[:create] <<
group "foo" do ... end <<
user "bar" do ... end <<
resources[:enable] = resources[:start] << service "zoo" do ... end
resources.each do |action, res|
res.run_action action
( @new_resource.updated_by_last_action? || res.updated_by_last_action? )
end
end
It seems kind of hacky to force all the resources to run immediately just so I can query their updated_by_last_action status. Is there a better way?
- [chef] Modelling a collection of resources as an LWRP, Mark J. Reed, 02/14/2011
Archive powered by MHonArc 2.6.16.