Email Notify afterdeployment
ruben-herold opened this issue · 4 comments
hi,
I want implement that we got an email after each successful deployed certificate.
In the code I found:
deploy_cert() {
if [[ -n "${PDNS_DEPLOY_CERT_HOOK:-}" ]]; then
${PDNS_DEPLOY_CERT_HOOK}
fi
}
I found nothing in the documentation about it. A simple PDNS_DEPLOY_CERT_HOOK='echo "new certificate for ${1}" | mail -s "new certificate for ${1}" test@test.com'
did not work
PDNS_DEPLOY_CERT_HOOK
should point to a binary with arguments. It is not executed in a shell, so a pipe will not work. I think your code will result in the following output: "new certificate for ${1}" | mail -s "new certificate for ${1}" test@test.com
Note that it is a better idea to wrap pdns_api.sh
in your own script if you want to implement things around it. Quick (and untested) example:
#!/usr/bin/env bash
set -euo pipefail
pdns_api.sh "$@"
if [[ "$1" = "deploy_cert" ]]; then
echo "new certificate for ${2}" | mail -s "new certificate for ${2}" test@test.com
fi
Thx I did something similar but in pdns_api.sh. But we I like the idea from PDNS_DEPLOY_CERT_HOOK so could you think to document and extend it?
Since pdns.api.sh is already a hook plugin of dehydrated but made solely for handling the DNS API, why not use the well documented hook infrastructure of dehydrated itself?
https://github.com/dehydrated-io/dehydrated/blob/master/docs/examples/hook.sh
Thx I did something similar but in pdns_api.sh. But we I like the idea from PDNS_DEPLOY_CERT_HOOK so could you think to document and extend it?
The hooks are now documented in the README, including their limitations.
Since pdns.api.sh is already a hook plugin of dehydrated but made solely for handling the DNS API, why not use the well documented hook infrastructure of dehydrated itself?
This is definitely the way to do it, and I have included this in the README.