Catch Execute exit codes


#1

I’m using an execute resource to unzip a file. When that fails, the exit
code is 9. Is there a way to catch specific exit codes from execute
resources and take some custom action?

Thanks,
Doug


#2

An execute resource will fail the chef rub unless a return code from the returns attribute to the resource is returned from the command or ignore failure is set on the resource, so there’s no handling of specific return codes I’m aware of, just success/fail.

If it’s just a matter of trying again you could use the retries and retry_delay attributes to the execute resource.

For more sophisticated error handling you’re probably going to want to use a ruby_block or a script resource instead of an execute and write in error handling in the ruby code or script

On Sep 27, 2015, at 2:11 PM, Douglas Garstang doug.garstang@gmail.com wrote:

I’m using an execute resource to unzip a file. When that fails, the exit code is 9. Is there a way to catch specific exit codes from execute resources and take some custom action?

Thanks,
Doug


#3

I would recomend the ark cookbook instead.
On 27 Sep 2015 22:35, “Yoshi Spendiff” yoshi@spendiff.net wrote:

An execute resource will fail the chef rub unless a return code from the
returns attribute to the resource is returned from the command or ignore
failure is set on the resource, so there’s no handling of specific return
codes I’m aware of, just success/fail.

If it’s just a matter of trying again you could use the retries and
retry_delay attributes to the execute resource.

For more sophisticated error handling you’re probably going to want to use
a ruby_block or a script resource instead of an execute and write in error
handling in the ruby code or script

On Sep 27, 2015, at 2:11 PM, Douglas Garstang doug.garstang@gmail.com
wrote:

I’m using an execute resource to unzip a file. When that fails, the exit
code is 9. Is there a way to catch specific exit codes from execute
resources and take some custom action?

Thanks,
Doug