Thanks for the info. Yeah, I understand that one need to think more in Chef way than the conventional programming style.
I will explore the Mixlib::ShellOut
From: Matt Ray email@example.com
To: "firstname.lastname@example.org" email@example.com
Sent: Monday, 11 March 2013 11:23 PM
Subject: [chef] RE: Re: Is there mechanism in Chef to capture return value of the command executed using “execute resource”?
Or if what you’re looking for is a signal of when a resource successfully executes, you can use notifications:
Senior Technical Evangelist | Opscode Inc.
firstname.lastname@example.org | (512) 731-2218
Twitter, IRC, GitHub: mattray
From: Adam Jacob [email@example.com]
Sent: Monday, March 11, 2013 11:18 AM
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
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.
On 3/11/13 7:48 AM, "firstname.lastname@example.org"
Is there mechanism in Chef to capture return value of the command
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
be string or number.
Based on the return value of “foo”, I should decide whether to execute
following resources or not !
if ‘foo’ returns "apple"
if ‘foo’ returns "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
false return value.
I want to achieve something like below -
if (foo() == apple)
else if(foo() == tomato)
else if …