From 31cc74951bb9e21d90867f7369177e6c86633c21 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Fri, 16 Oct 2020 20:40:05 +0200 Subject: [PATCH] bundles/powerdns: only reload pdns on zone changes, don't restart --- bundles/powerdns/items.py | 40 +++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/bundles/powerdns/items.py b/bundles/powerdns/items.py index 3f903a8..414290e 100644 --- a/bundles/powerdns/items.py +++ b/bundles/powerdns/items.py @@ -75,6 +75,16 @@ svc_systemd = { }, } +actions = { + 'powerdns_reload_zones': { + 'triggered': True, + 'command': 'pdns_control rediscover; pdns_control reload', + 'needs': { + 'svc_systemd:pdns', + }, + }, +} + if node.metadata['powerdns'].get('features', {}).get('bind', False): primary_zones = set() for zone in listdir(zone_path): @@ -97,7 +107,7 @@ if node.metadata['powerdns'].get('features', {}).get('bind', False): }, 'source': 'bind-zones/{}'.format(zone), 'triggers': { - 'svc_systemd:pdns:reload', + 'action:powerdns_reload_zones', }, } @@ -106,7 +116,7 @@ if node.metadata['powerdns'].get('features', {}).get('bind', False): 'pkg_apt:pdns-backend-bind', }, 'triggers': { - 'svc_systemd:pdns:restart', + 'action:powerdns_reload_zones', }, } @@ -119,7 +129,7 @@ if node.metadata['powerdns'].get('features', {}).get('bind', False): 'pkg_apt:pdns-backend-bind', }, 'triggers': { - 'svc_systemd:pdns:reload', + 'action:powerdns_reload_zones', }, } @@ -133,22 +143,20 @@ if node.metadata['powerdns'].get('features', {}).get('pgsql', False): 'pkg_apt:pdns-backend-pgsql', }, 'triggers': { - 'svc_systemd:pdns:restart', + 'action:powerdns_reload_zones', }, } files['/etc/powerdns/schema.pgsql.sql'] = {} - actions = { - 'powerdns_load_pgsql_schema': { - 'command': 'PGPASSWORD={pw} psql -h 127.0.0.1 -d powerdns -U powerdns -w < /etc/powerdns/schema.pgsql.sql'.format(pw=node.metadata['postgresql']['users']['powerdns']['password']), - 'unless': 'sudo -u postgres psql -d powerdns -c "\dt" | grep domains 2>&1 >/dev/null', - 'needs': { - 'bundle:postgresql', - 'file:/etc/powerdns/schema.pgsql.sql', - }, - 'needed_by': { - 'svc_systemd:pdns', - }, - } + actions['powerdns_load_pgsql_schema'] = { + 'command': 'PGPASSWORD={pw} psql -h 127.0.0.1 -d powerdns -U powerdns -w < /etc/powerdns/schema.pgsql.sql'.format(pw=node.metadata['postgresql']['users']['powerdns']['password']), + 'unless': 'sudo -u postgres psql -d powerdns -c "\dt" | grep domains 2>&1 >/dev/null', + 'needs': { + 'bundle:postgresql', + 'file:/etc/powerdns/schema.pgsql.sql', + }, + 'needed_by': { + 'svc_systemd:pdns', + }, }