I have an LWRP that fundamentally just creates a bunch of other
resources dynamically. I had some issues getting notifies to work, so
I have some questions.
-
Is an LWRP the best way to create a resource that is really a
collection of other resources?
-
If not, what is? A define? A straight-up non-lightweight resource
definition? It’s definitely not a recipe, as I need to be able to
call/include it multiple times with different parameters.
-
If it’s at least a reasonable way to do it, where in the provider
does that logic belong? Creating more resources once you’re already
running the action seems a bit late; I wind up having to call
run_action on them as I create them in order to get the behavior I
want.
-
As far as notifies go, is there a way from the provider to access
the set of notifications requested?
Any thoughts and recommendations appreciated. Thanks!
–
Mark J. Reed markjreed@gmail.com
On Tue, Apr 19, 2011 at 8:13 AM, Mark J. Reed markjreed@gmail.com wrote:
I have an LWRP that fundamentally just creates a bunch of other
resources dynamically. I had some issues getting notifies to work, so
I have some questions.
-
Is an LWRP the best way to create a resource that is really a
collection of other resources?
-
If not, what is? A define? A straight-up non-lightweight resource
definition? It's definitely not a recipe, as I need to be able to
call/include it multiple times with different parameters.
-
If it's at least a reasonable way to do it, where in the provider
does that logic belong? Creating more resources once you're already
running the action seems a bit late; I wind up having to call
run_action on them as I create them in order to get the behavior I
want.
-
As far as notifies go, is there a way from the provider to access
the set of notifications requested?
Any thoughts and recommendations appreciated. Thanks!
Can you give us some example code, and tell us what's happening with
the notifications?
Adam
--
Opscode, Inc.
Adam Jacob, Chief Product Officer
T: (206) 619-7151 E: adam@opscode.com
Thanks, Adam. I got it working with kallistec's help on IRC. What
I'm doing now is just duplicating the notifies from the LWRP onto each
sub resource.
Ex code (abbreviated due to typing on phone):
action :create do
nr = new_resource
@delay = nr.delayed_notifications
@imm = nr.immediate_notifications
def fw(res)
if @delay then
@delay.each do |r|
res.notifies_delayed r.action, r.resource
end
end
if @imm then ... #similar
end
end
fw( remote_file "foo" do ... end )
fw( bash "bar" do ... end )
...
end
Direct setters for the notifications attributes would be helpful here...
On Tuesday, April 19, 2011, Adam Jacob adam@opscode.com wrote:
On Tue, Apr 19, 2011 at 8:13 AM, Mark J. Reed markjreed@gmail.com wrote:
I have an LWRP that fundamentally just creates a bunch of other
resources dynamically. I had some issues getting notifies to work, so
I have some questions.
-
Is an LWRP the best way to create a resource that is really a
collection of other resources?
-
If not, what is? A define? A straight-up non-lightweight resource
definition? It's definitely not a recipe, as I need to be able to
call/include it multiple times with different parameters.
-
If it's at least a reasonable way to do it, where in the provider
does that logic belong? Creating more resources once you're already
running the action seems a bit late; I wind up having to call
run_action on them as I create them in order to get the behavior I
want.
-
As far as notifies go, is there a way from the provider to access
the set of notifications requested?
Any thoughts and recommendations appreciated. Thanks!
Can you give us some example code, and tell us what's happening with
the notifications?
Adam
--
Opscode, Inc.
Adam Jacob, Chief Product Officer
T: (206) 619-7151 E: adam@opscode.com
--
Mark J. Reed markjreed@gmail.com