allow exporting process to run arbitrary hooks#49
allow exporting process to run arbitrary hooks#49mzagrabe wants to merge 4 commits intocvicente:masterfrom
Conversation
This commit allows local Netdot instances to run their own code at various hook points in the exporting process. This commit only adds hook points for exporting BIND configs. However, adding hook points for other classes should be straightforward and simple due to leveraging the 'hook' subroutine. Pertinent data is passed to the hook programs via a JSON encoded data structure on the command line.
|
Hi Carlos, I saw on the -users mailing a question (circa 2012) about a hook to restart BIND after the zone file was generated: Subject: [Netdot-users] Hook to restart bind after export To which Vincent.Magnin responded with a patch to directly modify the Netdot sources. This branch works around that by implementing a "hooks" system where each export class can have hook points and the site administrator can create scripts inside corresponding hook directories to be run whenever the exported configs are created. For instance, this branch creates three hook points in the BIND exporter: before-all-zones-written For our Netdot install, we run git pull for "before-all-zones-written". Then on "after-zone-written" we perform: named-checkzone $ZONE Finally, the "after-all-zones-written" we run a git add; git commit; git push. It works pretty slick. Here is the output on the export page: INFO - VCS update successful via: git pull And when it blows up: INFO - VCS update successful via: git pull I believe others would benefit from this branch and I'd appreciate it if you'd look it over for inclusion. Thanks! -m |
External programs can make good use of various metadata - such as the Netdot name - thus we pass it along.
It will beneficial to be able to order the hook programs. Such as: hooks/BIND/after-zone-written/0001-copy-zone-to-production hooks/BIND/after-zone-written/0002-reload-zone hooks/BIND/after-zone-written/0003-flush-cache-on-recursive-servers
This commit allows local Netdot instances to run their own code at various
hook points in the exporting process.
This commit only adds hook points for exporting BIND configs. However, adding
hook points for other classes should be straightforward and simple due to
leveraging the 'hook' subroutine.
Pertinent data is passed to the hook programs via a JSON encoded data
structure on the command line.