[chef] Re: knife exit codes on windows?


Chronological Thread 
  • From: Larry Wright < >
  • To:
  • Subject: [chef] Re: knife exit codes on windows?
  • Date: Mon, 10 Feb 2014 21:53:53 -0600

WinRM is… special. Ok, that’s being too nice. It’s an abomination, but it’s all we have on Windows unless you want to install an SSH daemon. There is not, as far as I can tell, any way to get the exit code of a process called via WinRM. Your best bet is to parse the output, unless someone else knows of something that I have overlooked.

Larry Wright

On Feb 10, 2014, at 9:17 AM, Brian Anderson < "> > wrote:

I feel like I'm missing something obvious here.  No matter what happens in the run, knife winrm always seems to return 0.

To demonstrate this I did a remote run of chef-client, calling an invalid override run list.

First on linux:
 
~ ]$ knife ssh -m linhost -x user -i key.pem "sudo chef-client --force-logger -l info -o recipe[nosuch::recipel]"
[...]
linhost [2014-02-10T09:57:56-05:00] FATAL: Chef::Exceptions::RecipeNotFound: could not find recipe fooszl for cookbook affdex
~ ]$ echo $?
1



Then Windows:

knife winrm -m winhost -x Administrator -P password "chef-client --force-logger -l info -o recipe[affdex::fooszl]"
[...]
winhost [2014-02-10T09:58:33-05:00] FATAL: Chef::Exceptions::RecipeNotFound: could not find recipe fooszl for cookbook affdex
~ ]$ echo $?
0

Then I tried using the --returns arg to knife winrm:


knife winrm --returns 0 -m winhost -x Administrator -P password "chef-client --force-logger -l info -o recipe[affdex::fooszl]"
[...]
winhost [2014-02-10T09:59:03-05:00] FATAL: Chef::Exceptions::RecipeNotFound: could not find recipe fooszl for cookbook affdex
ERROR: Failed to execute command on winhost return code 1
~ ]$ echo $?
0


Is there some way that I am missing to get knife winrm to return 1 when the chef run fails, like knife ssh does?


Thanks,

Brian
--
Brian Anderson | Operations Engineer
Phone 781.696.1304
 


www.affectiva.com

     




Archive powered by MHonArc 2.6.16.

§