[chef] Re: Re: How to execute a command block only if previous block succeed?


Chronological Thread 
  • From: howard chen < >
  • To:
  • Subject: [chef] Re: Re: How to execute a command block only if previous block succeed?
  • Date: Tue, 21 May 2013 23:40:03 +0800

Unfortunately, there are more steps in between the two blocks (foo LWRP and execute) , so I can't notify immediately, e.g.

foo "bar" do
  action : helloworld
end

..
..(these steps need to be run first)
..

execute "bye" do
  command "xxx"
  action :run
end



On Tue, May 21, 2013 at 1:26 AM, Cassiano Leal < " target="_blank"> > wrote:
You're asking two different questions here, and the solution will depend on which is actually the case.

If you really just need for one resource to be dependent on the other, use the action :nothing / notifies pattern:

execute "bye" do
  command "xxx"
  action :nothing
end


foo "bar" do
  action :helloworld
  notifies :run, "execute[bye]"
end

If you actually need to send the exit status from one resource to the other, then you'll probably need to hack something on your provider to populate a node attribute, I think… :)

- cassiano

On Monday, May 20, 2013 at 14:22, howard chen wrote:

I have written a custom provider, foo

action :helloworld do
...
end

And in my recipe, I have lines..

foo "bar" do
  action : helloworld
end

..
..
execute "bye" do
  command "xxx"
  action :run
end

How to make my last execute block run only if my custom provider "foo" is executed correctly?

i.e. How to make my helloworld action return success/error status and such that the later block can make use of this value?


Thanks.





Archive powered by MHonArc 2.6.16.

§