diff --git a/cmdeploy/src/cmdeploy/deployers.py b/cmdeploy/src/cmdeploy/deployers.py index 9a8276a1..88fdfd48 100644 --- a/cmdeploy/src/cmdeploy/deployers.py +++ b/cmdeploy/src/cmdeploy/deployers.py @@ -171,16 +171,14 @@ class UnboundDeployer(Deployer): "unbound-anchor -a /var/lib/unbound/root.key || true", ], ) - if self.config.disable_ipv6: - self.ensure_directory( - path="/etc/unbound/unbound.conf.d", - ) - self.put_template( - "unbound/unbound.conf.j2", - "/etc/unbound/unbound.conf.d/chatmail.conf", - ) - else: - self.remove_file("/etc/unbound/unbound.conf.d/chatmail.conf") + self.ensure_directory( + path="/etc/unbound/unbound.conf.d", + ) + self.put_template( + "unbound/unbound.conf.j2", + "/etc/unbound/unbound.conf.d/chatmail.conf", + disable_ipv6=self.config.disable_ipv6, + ) def activate(self): server.shell( diff --git a/cmdeploy/src/cmdeploy/unbound/unbound.conf.j2 b/cmdeploy/src/cmdeploy/unbound/unbound.conf.j2 index 98766e3b..faa7cd49 100644 --- a/cmdeploy/src/cmdeploy/unbound/unbound.conf.j2 +++ b/cmdeploy/src/cmdeploy/unbound/unbound.conf.j2 @@ -1,5 +1,7 @@ # Managed by cmdeploy server: +{% if disable_ipv6 %} interface: 127.0.0.1 do-ip6: no +{% endif %} cache-max-negative-ttl: 0