Execute a scripts included in the cookbook


#1

HI,

I would like to include a native script and execute it from a recipe rather than in-lining it into the recipe.

Is this possiblem

Cheers,
Florian

LEGAL DISCLAIMER
This communication and any attached documents are strictly confidential and/or legally privileged and they may not be used or disclosed by someone who is not a named recipient. If you have received this electronic communication in error please notify the sender by replying to this electronic communication inserting the word “misdirected” as the subject and delete this communication from your system.


#2

yes you can, you can use the cookbook_file to dirstribute/install the
script in a location (say /usr/local/foo) and use the execute resource to
invoke it (execute “/usr/local/foo”),

On Fri, Jul 12, 2013 at 6:52 AM, Florian Hehlen <
Florian.Hehlen@mri-group.com> wrote:

HI,

I would like to include a native script and execute it from a recipe
rather than in-lining it into the recipe.

Is this possiblem

Cheers,

Florian

LEGAL DISCLAIMER
This communication and any attached documents are strictly confidential
and/or legally privileged and they may not be used or disclosed by someone
who is not a named recipient. If you have received this electronic
communication in error please notify the sender by replying to this
electronic communication inserting the word “misdirected” as the subject
and delete this communication from your system.


#3

Hi,

Thanks for that pointer.

Is there a way to pipe the output of the script back into chef? I am running a powershell script and get a “successfully run” message although it clearly has not run

Cheers,
florian

From: Ranjib Dey [mailto:dey.ranjib@gmail.com]
Sent: 12 July 2013 16:04
To: chef@lists.opscode.com
Subject: [chef] Re: execute a scripts included in the cookbook

yes you can, you can use the cookbook_file to dirstribute/install the script in a location (say /usr/local/foo) and use the execute resource to invoke it (execute “/usr/local/foo”),

On Fri, Jul 12, 2013 at 6:52 AM, Florian Hehlen <Florian.Hehlen@mri-group.commailto:Florian.Hehlen@mri-group.com> wrote:
HI,

I would like to include a native script and execute it from a recipe rather than in-lining it into the recipe.

Is this possiblem

Cheers,
Florian

LEGAL DISCLAIMER
This communication and any attached documents are strictly confidential and/or legally privileged and they may not be used or disclosed by someone who is not a named recipient. If you have received this electronic communication in error please notify the sender by replying to this electronic communication inserting the word “misdirected” as the subject and delete this communication from your system.

LEGAL DISCLAIMER
This communication and any attached documents are strictly confidential and/or legally privileged and they may not be used or disclosed by someone who is not a named recipient. If you have received this electronic communication in error please notify the sender by replying to this electronic communication inserting the word “misdirected” as the subject and delete this communication from your system.


#4

Execute resource will give u the stdout & stderr of your script in case it
breaks, i.e. returns non zero values. It is the responsibility of your
power shell script to do the error checking and return a non zero value in
case bad things happen. You can run the chef client in debug mode (-l
debug) and see if that shows the output. Another option will be to use
mixlib/shellout to execute the command inside a ruby_block resource , then
you can explicitly print the command.stdout using Chef::Log.info
On Jul 12, 2013 8:14 AM, “Florian Hehlen” Florian.Hehlen@mri-group.com
wrote:

Hi,

Thanks for that pointer.

Is there a way to pipe the output of the script back into chef? I am
running a powershell script and get a “successfully run” message although
it clearly has not run

Cheers,

florian

From: Ranjib Dey [mailto:dey.ranjib@gmail.com]
Sent: 12 July 2013 16:04
To: chef@lists.opscode.com
Subject: [chef] Re: execute a scripts included in the cookbook

yes you can, you can use the cookbook_file to dirstribute/install the
script in a location (say /usr/local/foo) and use the execute resource to
invoke it (execute “/usr/local/foo”),

On Fri, Jul 12, 2013 at 6:52 AM, Florian Hehlen <
Florian.Hehlen@mri-group.com> wrote:

HI,

I would like to include a native script and execute it from a recipe
rather than in-lining it into the recipe.

Is this possiblem

Cheers,

Florian

LEGAL DISCLAIMER
This communication and any attached documents are strictly confidential
and/or legally privileged and they may not be used or disclosed by someone
who is not a named recipient. If you have received this electronic
communication in error please notify the sender by replying to this
electronic communication inserting the word “misdirected” as the subject
and delete this communication from your system.

LEGAL DISCLAIMER
This communication and any attached documents are strictly confidential
and/or legally privileged and they may not be used or disclosed by someone
who is not a named recipient. If you have received this electronic
communication in error please notify the sender by replying to this
electronic communication inserting the word “misdirected” as the subject
and delete this communication from your system.


#5

Under Unix the exit code of the script is what determines success (0 is
fine, anything else is bad). Not sure if Windows supports that, though?

On Friday, July 12, 2013, Florian Hehlen wrote:

Hi,

Thanks for that pointer.

Is there a way to pipe the output of the script back into chef? I am
running a powershell script and get a “successfully run” message although
it clearly has not run

Cheers,

florian

From: Ranjib Dey [mailto:dey.ranjib@gmail.com <javascript:_e({},
‘cvml’, ‘dey.ranjib@gmail.com’);>]
Sent: 12 July 2013 16:04
To: chef@lists.opscode.com <javascript:_e({}, ‘cvml’,
‘chef@lists.opscode.com’);>
Subject: [chef] Re: execute a scripts included in the cookbook

yes you can, you can use the cookbook_file to dirstribute/install the
script in a location (say /usr/local/foo) and use the execute resource to
invoke it (execute “/usr/local/foo”),

On Fri, Jul 12, 2013 at 6:52 AM, Florian Hehlen <
Florian.Hehlen@mri-group.com <javascript:_e({}, ‘cvml’,
‘Florian.Hehlen@mri-group.com’);>> wrote:

HI,

I would like to include a native script and execute it from a recipe
rather than in-lining it into the recipe.

Is this possiblem

Cheers,

Florian

LEGAL DISCLAIMER
This communication and any attached documents are strictly confidential
and/or legally privileged and they may not be used or disclosed by someone
who is not a named recipient. If you have received this electronic
communication in error please notify the sender by replying to this
electronic communication inserting the word “misdirected” as the subject
and delete this communication from your system.

LEGAL DISCLAIMER
This communication and any attached documents are strictly confidential
and/or legally privileged and they may not be used or disclosed by someone
who is not a named recipient. If you have received this electronic
communication in error please notify the sender by replying to this
electronic communication inserting the word “misdirected” as the subject
and delete this communication from your system.

~~ StormeRider ~~

“Every world needs its heroes […] They inspire us to be better than we
are. And they protect from the darkness that’s just around the corner.”

(from Smallville Season 6x1: “Zod”)

On why I hate the phrase “that’s so lame”… http://bit.ly/Ps3uSS