Perform named-checkconf before reloading named.

This tries to minimize the risk of reloading broken config or invalid
zone files, and kill our DNS infrastructure while doing so.
This commit is contained in:
Ossi Herrala 2012-11-29 14:13:28 +00:00
parent 15a3dacdec
commit 954955bd39

View file

@ -107,6 +107,16 @@ class dns::server {
} }
} }
exec { "named-checkconf":
command => $chroot ? {
"" => "/usr/sbin/named-checkconf -z",
default => "/usr/sbin/named-checkconf -z -t ${chroot}"
},
refreshonly => true,
subscribe => File["named.conf"],
notify => Service["named"],
}
service { "named": service { "named":
name => $::operatingsystem ? { name => $::operatingsystem ? {
"ubuntu" => "bind9", "ubuntu" => "bind9",
@ -155,7 +165,7 @@ class dns::server {
user => "root", user => "root",
refreshonly => true, refreshonly => true,
require => File["/usr/local/sbin/generate-named-conf.sh"], require => File["/usr/local/sbin/generate-named-conf.sh"],
notify => Service["named"], notify => Exec["named-checkconf"],
} }
file { "${chroot}${confdir}/named.conf.options": file { "${chroot}${confdir}/named.conf.options":
@ -170,7 +180,7 @@ class dns::server {
"openbsd" => undef, "openbsd" => undef,
default => Package["bind"], default => Package["bind"],
}, },
notify => Service["named"], notify => Exec["named-checkconf"]
} }
file { "${chroot}${confdir}/named.conf.local": file { "${chroot}${confdir}/named.conf.local":
@ -185,7 +195,7 @@ class dns::server {
"openbsd" => undef, "openbsd" => undef,
default => Package["bind"], default => Package["bind"],
}, },
notify => Service["named"], notify => Exec["named-checkconf"]
} }
} }
@ -225,7 +235,7 @@ class dns::server::ldap inherits dns::server {
command => "dnsdump.py --notest /var/named/master.in /var/named/master", command => "dnsdump.py --notest /var/named/master.in /var/named/master",
require => File["/usr/local/sbin/dnsdump.py"], require => File["/usr/local/sbin/dnsdump.py"],
unless => "dnsdump.py --test /var/named/master.in /var/named/master", unless => "dnsdump.py --test /var/named/master.in /var/named/master",
notify => Service["named"] notify => Exec["named-checkconf"],
} }
} }
@ -389,7 +399,7 @@ define dns::zone($role = "master", $master = "", $slaves = [], $forwarders = [],
"openbsd" => undef, "openbsd" => undef,
default => Package["bind"], default => Package["bind"],
}, },
notify => Service["named"], notify => Exec["named-checkconf"],
} }
file { "${dns::server::chroot}${zonedir}/db.${zone}-dynamic": file { "${dns::server::chroot}${zonedir}/db.${zone}-dynamic":
ensure => present, ensure => present,
@ -405,7 +415,7 @@ define dns::zone($role = "master", $master = "", $slaves = [], $forwarders = [],
"openbsd" => undef, "openbsd" => undef,
default => Package["bind"], default => Package["bind"],
}, },
notify => Service["named"], notify => Exec["named-checkconf"],
} }
file { "${dns::server::chroot}${zonedir}/db.${zone}-static": file { "${dns::server::chroot}${zonedir}/db.${zone}-static":
ensure => present, ensure => present,
@ -421,7 +431,7 @@ define dns::zone($role = "master", $master = "", $slaves = [], $forwarders = [],
"openbsd" => undef, "openbsd" => undef,
default => Package["bind"], default => Package["bind"],
}, },
notify => Service["named"], notify => Exec["named-checkconf"],
} }
} }
} }
@ -468,5 +478,4 @@ class dns::nsupdate {
minute => "*/5", minute => "*/5",
require => File["/usr/local/sbin/nsupdate.sh"], require => File["/usr/local/sbin/nsupdate.sh"],
} }
} }