[chef] RE: Re: Is there mechanism in Chef to capture return value of the command executed using "execute resource"?


Chronological Thread 
  • From: Matt Ray < >
  • To: " " < >
  • Subject: [chef] RE: Re: Is there mechanism in Chef to capture return value of the command executed using "execute resource"?
  • Date: Mon, 11 Mar 2013 17:53:23 +0000
  • Accept-language: en-US

Or if what you're looking for is a signal of when a resource successfully 
executes, you can use notifications:
http://docs.opscode.com/chef/resources.html#notifications

Thanks,
Matt Ray
Senior Technical Evangelist | Opscode Inc.

 | (512) 731-2218
Twitter, IRC, GitHub: mattray

________________________________________
From: Adam Jacob 

Sent: Monday, March 11, 2013 11:18 AM
To: 

Subject: [chef] Re: Is there mechanism in Chef to capture return value of the 
command executed using "execute resource"?

Not like that, no. The question here is what exactly are you trying to
accomplish? Sometimes there are easier, more "chef" like ways to get
things done.

If you do need to do this, check out Mixlib::ShellOut
(https://github.com/opscode/mixlib-shellout) which will allow you to run a
command and look at the output.

Adam

On 3/11/13 7:48 AM, 
" "
< >
 wrote:

>
>Is there mechanism in Chef to capture return value of the  command
>executed
>using "execute resource"?
>
>For example, consider I am calling following resource in some recipe.
>
>execute "execute_foo" do
>   command "foo"     <<< "foo" is executable which returns some value. It
>could
>be string or number.
>end
>
>Based on the return value of "foo", I should decide whether to execute
>following resources or not !
>
>if 'foo' returns "apple"
>       execute "apple"
>if 'foo' returns "tomato"
>       execute "tomato"
>etc . . .
>
>I try to use notify, only_if or not_if clauses but couldn't develop logic
>around it. As per my understanding those do binary comparison based on
>true or
>false return value.
>
>I want to achieve something like below -
>
>if (foo() == apple)
>       print fruit
>else if(foo() == tomato)
>       print vegetable
>else if ...
>
>
>Thanks,
>Aditya
>







Archive powered by MHonArc 2.6.16.

§