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'
You'd put your script in files/default/. In default. rb, which would have a 'cookbook_file' resource that places the script onto the host, and the above execute command. You'd then upload the cookbook to the chef server and add recipe[COOKBOOKNAME] to the runlist of your node.
Use the execute resource to execute a single command. Commands that are executed with this resource are (by their nature) not idempotent, as they are typically unique to the environment in which they are run. Use not_if and only_if to guard this resource for idempotence.
Chef-Guard is a feature rich Chef add-on that protects your Chef server from untested and uncommitted (i.e. potentially dangerous) cookbooks by running several validations and checks during the cookbook upload process.
There are two stages to a chef run though. A compile phase, to organise what resources need to be run and resolve all variables. Then a run phase where each resource is actually executed. You can write recipes that trigger actions during the compile phase which may make it seem out of order.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With