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


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

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.

§