[chef] Re: Powershell LWRP, returns attribute, and idempotency


Chronological Thread 
  • From: Daniel DeLeo < >
  • To:
  • Subject: [chef] Re: Powershell LWRP, returns attribute, and idempotency
  • Date: Wed, 15 May 2013 10:06:13 -0700


On Wednesday, May 15, 2013 at 9:13 AM, Bryan Stenson wrote:

Ohai!

I'm trying to catch exit codes from my powershell code block to determine whether my provider has affected change (to correctly set updated_by_last_action).

I think I should be able to do this using the "returns" attribute of the Powershell LWRP, but I'm having trouble getting it to work (and I haven't found many good examples).  I can see the "returns" attribute should be either an Array or Integer of acceptable exit codes, and I've set it to my expected values.

However, no matter what my code block returns, Chef gets an exit code of "1" for all non-zero return codes from Mixlib::ShellOut::ShellCommandFailed.

Here's my sample recipe, and chef-client run error: https://gist.github.com/stensonb/5585093

Even if I successfully get a non-one error code response, how do I access this return code?

I'm hoping I'm just using it wrong.  Anybody have an example?

Bryan

Chef's design makes it difficult to get data about what happens in a provider back out to a resource, so your LWRP is better off using the powershell library code directly.

https://github.com/opscode-cookbooks/powershell/blob/master/libraries/powershell_out.rb

I don't have any experience using it so I can't say what the issue with exit codes might be.

-- 
Daniel DeLeo




Archive powered by MHonArc 2.6.16.

§