Reputation: 1252
Is it possible to do something in Chef after the first error?
I want to gather logs from applications that caused Chef to fail. For example, some application fails to install and stores detailed logs in specific file (you can't see them in stdout). Chef should stop on this error, but also should zip this file (and maybe a few others, if existing) and save it for user.
I know there is ignore_failure
parameter, but it isn't ideally what I wan't, because it won't stop Chef resources, just simply skip problematic one.
I thought about some try/catch
mechanism, but it would be hard to define global way of handling errors.
Upvotes: 1
Views: 146
Reputation: 54181
What you want is to define an event handler. This API allows defining callbacks for all kinds of events, including run failure. You can log things however you want from inside there.
Upvotes: 2