Package: dzonegit
Git hooks to manage a repository of DNS zonesdzonegitis a set of Git hooks allowing you to manage DNS zone files in a
git repository. First, zone file sanity checks are run bypre-commithook
on your computer. After pushing changes to a bare repository on the DNS server,
the sanity checks are run again on the server and if everything is OK,
repository is checked out to a directory, DNS software configuration
snippets are re-generated from a simple template and finally reload command
is issued.Main featurescheck if zone file compiles properly usingnamed-compilezone(8)autodetect zone name from file name or$ORIGINdirectiveenforce updating serial number when zone content is changedoptionalsmudgefilter to replace$UNIXTIMEdirective with current UNIX timebothpre-commitandpre-receive/updatehooks to enforce similar checks in the remote repositorypost-receivehook to checkout the working copy from a bare repository, generate config snippets for various DNS server software and reload themonly Python 3.5+ standard library is usedRequirementsPython 3.5+named-compilezone(8)(part ofbind9utilspackage)gitSimple instalation (especially for workstations)Since there is no other Python dependency than the standard library, you can
simply download thedzonegit.pyfile, make it executable and rename/symlink
it to an appropriate hook location inside the Git repository.git/hooks/pre-commit. This is especially handy for the end users not
experienced with Python packaging ecosystem.Full instalation and usageinstall all the requirementsinstalldzonegitPython package using your
favourite tool (virtualenvwrapper,venv,pipenv, etc.)in the local repository, create a symlink for thepre-commithook:$ ln-s$(whichdzonegit-pre-commit)/path/to/repo/.git/hooks/pre-commiton the server, install some git repository management software,
preferablyGitoliteon the server, install eitherpre-receiveorupdatehook
(both do the same) as  well as thepost-receivehook. SeeGitolite
documentation on how to add custom hookson the server, set up the configuration options for each repositorySupport for $UNIXTIME directiveIf you want to use$UNIXTIMEin your zone files instead of serial number,
you have to install asmudgefilter on the server, that will replace the
directive with current unix time on every checkout. First, set up the filter
in the Git configuration:$gitconfig--globalfilter.dzonegit.smudge$(whichdzonegit-smudge-serial)Then, apply the filter on all zone files using either.git/info/attributesor directly.gitattributesfile inside the repository:*.zone filter=dzonegitConfiguration optionsAll configuration options are stored ingit-config(1)in the section
nameddzonegit.  All boolean options default toFalse.dzonegit.ignorewhitespaceerrorsIgnore white space errors inpre-commitandpre-receive/updatehooks.dzonegit.allowfancynamesInpre-commitandpre-receive/updatehooks, do not enforce zone
file name to be similar to the name of the zone.dzonegit.noserialupdateDo not try to automatically update zone serial number if necessary.
Valid only in thepre-commithook.dzonegit.nomissingdotcheckDo not check for forgotten final dot on the right-hand side of PTR records.
Valid only in thepre-commithook.dzonegit.checkoutpathPath to a writable directory, to whichpost-receivehook checks out
currentHEADafter each update.dzonegit.conffiletemplatePath to a JSON file containing template for generating DNS server
configuration snippet. See below for file format specification. More
files can be provided by appending single digit from 1 to 9 to this option.dzonegit.conffilepathPath to a writable file to generate DNS server configuration snippet.
More files can be provided by appending single digit from 1 to 9 to this
option. Each file is generated using the template with corresponding suffix.dzonegit.reconfigcmdA command to run when zones are introduced, deleted or renamed in the
repository. Should do something likerndc reconfig. More commands
can be provided by appending single digit from 1 to 9 to this option.dzonegit.zonereloadcmdA command to run for each zone, where zone file has been modified. Zone
name is automatically appended as the last argument. Should do something
likerndc reload. More commands can be provided by appending single digit
from 1 to 9 to this option.dzonegit.zoneblacklistPath to a text file containing list of zone names without trailing dots,
one per line. If zone is found on the blacklist, it is ignored whenpost-receivehook generates configuration. Wildcards can be used as
well, seeJSON templatebelow.dzonegit.zonewhitelistPath to a text file containing list of zone names without trailing dots,
one per line. If not empty and zone is not found on the whitelist,
it is ignored whenpost-receivehook generates configuration. Wildcards
can be used as well, seeJSON templatebelow.JSON templateThe DNS server configuration snippets are generated using a simple JSON-based
template. All keys are optional but please make sure the file is a valid JSON
file. It is possible to define a zone-specific options, for instance for
changing DNSSEC parameters per zone. Those zone-specific options allow usage of
wildcards; if an exact match of zone name is not found, the leftmost label is
substituted with*. If still no match is found, the leftmost label is dropped
and the second one is again substituted with*. In the end, a single*is
checked. Only if even this key is not found, the value ofdefaultvaris used
as the zone-specific option.Valid keys are:headerA string that is templated to the begining of the output file.footerA string that is templated to the end of the output file.itemA string that is templated for each zone.defaultvarA string that would template variable$zonevarexpand to if there is not
a zone-specific variable defined, nor any wildcard matched.zonevarsAn object mapping zone names (without the final dot) to a zone-specific
variable to which template variable$zonevarwould expand to. Using
wildcards is possible by replacing the leftmost label with*. Ultimately,
a key with label*will match every single zone (makingdefaultvaroption litte bit pointless)In the template strings, these placeholders are supported:$datetimeCurrent date and time in human readable format$zonenameZone name, without the trailing dot$zonefileFull path to the zone file$zonerelfilePath to the zone file, relative to checkout path (useful for chroot environments)$zonevarPer-zone specific variable, see aboveExample JSON template for Knot DNS{"header":"# Managed by dzonegit, do not edit.\nzone:","footer":"","item":" - domain: \"$zonename\"\n   file: \"$zonefile\"\n   $zonevar\n","defaultvar":"template: default","zonevars":{"example.com":"template: signed","*.cz":"template: czdomains","*.in-addr.arpa":"template: ipv4reverse"}}Example JSON template for BIND{"header":"# Autogenerated by dzonegit on $datetime. Do not edit.\n","item":"zone \"$zonename\" {\n type master;\n file \"$zonefile\";\n};"}