Override the chef bash return code
Asked Answered
S

1

6

I am running a chef recipie to install Websphere fixpacks. The fixpack retuns and exitcode [2] which is for partial install. Its an expected behaviour, but chef is just taking it as an error. Is there any way to override it.

I want chef to move ahead with the next task, even if the return exit code is [2]

================================================================================
Error executing action `run` on resource 'bash[was-install-fixpacks]'
================================================================================


Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '2'
Steele answered 7/6, 2013 at 2:22 Comment(0)
S
13

A quick look into the documentation reveals the parameter returns:

The return value for a command. This may be an array of accepted values. An exception is raised when the return value(s) do not match. Default value: 0.

Example:

bash "was-install-fixpacks" do
  command ..
  returns [0, 2]
end
Seleucid answered 7/6, 2013 at 6:43 Comment(1)
You are absolutely right, did read the returns but wasn't able to understand it properly. Thanks a lot for the clear example.Steele

© 2022 - 2024 — McMap. All rights reserved.