Here's the `common.sh` I find myself using in tasks at the moment. Attaching since Jira likes to ruin formatting. The `fail` function is a bit different from the one going into puppetlabs-service. It makes $1 the key of the object, the idea being the step that failed can be identified. Something like
fail "install_foo" "it no work" 1 |
Produces:
"install_foo": { |
"status": "error", |
"message": "it no work" |
} |
With an exit code of 1. I really like the indirection since you don't have to keep doing things like name=$PT_name, it just makes them available to you by sourcing the script. The trap and cleanup function would be nice, but I don't think it works as is. |