Skip to content

Instantly share code, notes, and snippets.

@stensonb
Created May 15, 2013 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stensonb/5585093 to your computer and use it in GitHub Desktop.
Save stensonb/5585093 to your computer and use it in GitHub Desktop.
Powershell LWRP "returns" attribute not working
powershell "exit-code-greater-than-one" do
returns 42
code <<-EOH
exit 42
EOH
end
@stensonb
Copy link
Author

Resource Declaration:

In c:/chef/cache/cookbooks/ppa_ssrs/providers/folder.rb

26: powershell "exit-code-greater-than-one" do
27: returns 42
28: code <<-EOH
29: exit 42
30: EOH
31: end
32:

Compiled Resource:

Declared in c:/chef/cache/cookbooks/ppa_ssrs/providers/folder.rb:26:in `block

in class_from_file'

powershell("exit-code-greater-than-one") do
action :run
retries 0
retry_delay 2
cookbook_name "crappy_powershell"
code " exit 42\n"
returns 42
end

[2013-05-15T08:58:26-07:00] ERROR: Running exception handlers
[2013-05-15T08:58:26-07:00] FATAL: Saving node information to c:/chef/cache/fail
ed-run-data.json
[2013-05-15T08:58:26-07:00] INFO: Email Subject:
[2013-05-15T08:58:26-07:00] INFO: Chef run failed on SEA-2500-67.paraport.com

[2013-05-15T08:58:26-07:00] INFO: Email Message:
[2013-05-15T08:58:26-07:00] INFO: Mixlib::ShellOut::ShellCommandFailed: powershe
ll[exit-code-greater-than-one](c line /chef/cache/cookbooks/ppa_ssrs/providers/folder.r
b) had an error: Mixlib::ShellOut::ShellCommandFailed: execute[exit-code-greater-than-one](dynamically defined) had an error: Mixlib::ShellOut::ShellCommandFailed: Exp
ected process to exit with [42], but received '1'
---- Begin output of C:\Windows\sysnative\WindowsPowershell\v1.0\powershell.exe
-NoLogo -NonInteractive -NoProfile -ExecutionPolicy RemoteSigned -InputFormat No
ne -Command "C:\Users\bryans\AppData\Local\Temp\2\chef-script20130515-3228-kvs9u
h.ps1" ----
STDOUT:
STDERR:
---- End output of C:\Windows\sysnative\WindowsPowershell\v1.0\powershell.exe -N
oLogo -NonInteractive -NoProfile -ExecutionPolicy RemoteSigned -InputFormat None
-Command "C:\Users\bryans\AppData\Local\Temp\2\chef-script20130515-3228-kvs9uh.
ps1" ----
Ran C:\Windows\sysnative\WindowsPowershell\v1.0\powershell.exe -NoLogo -NonInter
active -NoProfile -ExecutionPolicy RemoteSigned -InputFormat None -Command "C:\U
sers\bryans\AppData\Local\Temp\2\chef-script20130515-3228-kvs9uh.ps1" returned 1

C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.1.0-x86-ming
w32/lib/mixlib/shellout.rb:248:in invalid!' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.1.0-x86-ming w32/lib/mixlib/shellout.rb:234:inerror!'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/mixin/sh
ell_out.rb:36:in shell_out!' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/provider /execute.rb:62:inblock in action_run'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/mixin/wh
y_run.rb:52:in call' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/mixin/wh y_run.rb:52:inadd_action'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/provider
.rb:152:in converge_by' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/provider /execute.rb:61:inaction_run'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/provider
.rb:115:in run_action' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/resource .rb:597:inrun_action'
c:/chef/cache/cookbooks/powershell/providers/default.rb:70:in block in class_fr om_file' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/provider .rb:203:ininstance_eval'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/provider
.rb:203:in block in action' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/provider .rb:119:inrun_action'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/resource
.rb:597:in run_action' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/runner.r b:49:inrun_action'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/runner.r
b:81:in block (2 levels) in converge' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/runner.r b:81:ineach'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/runner.r
b:81:in block in converge' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/resource _collection.rb:94:inblock in execute_each_resource'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/resource
_collection/stepable_iterator.rb:116:in call' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/resource _collection/stepable_iterator.rb:116:incall_iterator_block'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/resource
_collection/stepable_iterator.rb:85:in step' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/resource _collection/stepable_iterator.rb:104:initerate'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/resource
_collection/stepable_iterator.rb:55:in each_with_index' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/resource _collection.rb:92:inexecute_each_resource'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/runner.r
b:80:in converge' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/client.r b:378:inconverge'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/client.r
b:420:in do_run' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/client.r b:176:inrun'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/applicat
ion.rb:140:in run_chef_client' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/applicat ion/client.rb:274:inblock in run_application'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/applicat
ion/client.rb:267:in loop' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/applicat ion/client.rb:267:inrun_application'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/applicat
ion.rb:72:in run' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/bin/chef-client:2 6:in<top (required)>'
C:/opscode/chef/bin/chef-client:23:in load' C:/opscode/chef/bin/chef-client:23:in

'
[2013-05-15T08:58:26-07:00] INFO: Attempting to send email to DevOps <bstenson@p
araport.com>
[2013-05-15T08:58:27-07:00] ERROR: Exception handlers complete
[2013-05-15T08:58:27-07:00] FATAL: Stacktrace dumped to c:/chef/cache/chef-stack
trace.out
[2013-05-15T08:58:27-07:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: powersh
ell[exit-code-greater-than-one](c line /chef/cache/cookbooks/ppa_ssrs/providers/folder.
rb) had an error: Mixlib::ShellOut::ShellCommandFailed: execute[exit-code-greater-than-one](dynamically defined) had an error: Mixlib::ShellOut::ShellCommandFailed: Ex
pected process to exit with [42], but received '1'
---- Begin output of C:\Windows\sysnative\WindowsPowershell\v1.0\powershell.exe
-NoLogo -NonInteractive -NoProfile -ExecutionPolicy RemoteSigned -InputFormat No
ne -Command "C:\Users\bryans\AppData\Local\Temp\2\chef-script20130515-3228-kvs9u
h.ps1" ----
STDOUT:
STDERR:
---- End output of C:\Windows\sysnative\WindowsPowershell\v1.0\powershell.exe -N
oLogo -NonInteractive -NoProfile -ExecutionPolicy RemoteSigned -InputFormat None
-Command "C:\Users\bryans\AppData\Local\Temp\2\chef-script20130515-3228-kvs9uh.
ps1" ----
Ran C:\Windows\sysnative\WindowsPowershell\v1.0\powershell.exe -NoLogo -NonInter
active -NoProfile -ExecutionPolicy RemoteSigned -InputFormat None -Command "C:\U
sers\bryans\AppData\Local\Temp\2\chef-script20130515-3228-kvs9uh.ps1" returned 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment