From 5a7d38bc88b62f3a60e97b1278d54978c9c69fc3 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 7 Dec 2021 17:34:03 +0100 Subject: [PATCH] Generating servers configuration for tsig keys --- lib/pp_admintools/deploy_zones_from_pdns.py | 23 ++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/pp_admintools/deploy_zones_from_pdns.py b/lib/pp_admintools/deploy_zones_from_pdns.py index 3f94286..d5bfb01 100644 --- a/lib/pp_admintools/deploy_zones_from_pdns.py +++ b/lib/pp_admintools/deploy_zones_from_pdns.py @@ -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: -- 2.39.5