]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Generating servers configuration for tsig keys
authorFrank Brehm <frank@brehm-online.com>
Tue, 7 Dec 2021 16:34:03 +0000 (17:34 +0100)
committerFrank Brehm <frank@brehm-online.com>
Tue, 7 Dec 2021 16:34:03 +0000 (17:34 +0100)
lib/pp_admintools/deploy_zones_from_pdns.py

index 3f942863b8156a2a945c1eb865bed3dbbf428084..d5bfb01ff4786f8e24d2cc987c583d5575802bab 100644 (file)
@@ -39,7 +39,7 @@ from .pidfile import PidFileError, PidFile
 
 from .xlate import XLATOR
 
-__version__ = '0.7.3'
+__version__ = '0.7.4'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -397,10 +397,6 @@ class PpDeployZonesApp(PpPDNSApplication):
 
             self.init_temp_objects()
             self.generate_slave_cfg_file()
-            if self.servers:
-                LOG.debug(_("Collected server configuration:") + '\n' + pp(self.servers))
-            else:
-                LOG.debug(_("Collected server configuration:") + ' ' + _('None'))
             self.compare_files()
 
             try:
@@ -552,6 +548,23 @@ class PpDeployZonesApp(PpPDNSApplication):
             if zone_config:
                 content += '\n' + zone_config
 
+        if self.servers:
+            LOG.debug(_("Collected server configuration:") + '\n' + pp(self.servers))
+        else:
+            LOG.debug(_("Collected server configuration:") + ' ' + _('None'))
+
+        if self.servers:
+            for server in sorted(self.servers.keys()):
+                lines = []
+                lines.append('')
+                lines.append('server {} {{'.format(server))
+                lines.append('\tkeys {')
+                for key_id in sorted(self.servers[server]['keys']):
+                    lines.append("\t\t{};".format(key_id))
+                lines.append('\t};')
+                lines.append('};')
+                content += '\n'.join(lines) + '\n'
+
         content += '\n// vim: ts=8 filetype=named noet noai\n'
 
         with open(self.temp_zones_cfg_file, 'w', **self.open_args) as fh: