Skip to content

Instantly share code, notes, and snippets.

@norrs

norrs/server.pp

Created Feb 25, 2012
Embed
What would you like to do?
Ugly ugly ugly ugly hacks on puppet
define zonefile() {
if $name!="" and $name!="," {
file { "tmp.db.$name":
path => "/tmp/$title",
owner => "bind",
group => "bind",
mode => "0644",
source => "puppet:///modules/dns/db.$title",
require => File["/etc/bind/db.d"],
}
exec { "zonecheck.helper.$name":
command => "cp /tmp/$name /tmp/helper.$name",
path => "/usr/bin:/usr/sbin:/bin",
refreshonly => true,
subscribe => File["tmp.db.$name"],
before => Exec["zonecheck.$name"],
}
exec { "zonecheck.$name":
command => "sh -c 'echo named-checkzone $name /tmp/$name Failed, check your zonefile && cp /tmp/$name && exit 1'",
path => "/usr/bin:/usr/sbin:/bin",
logoutput => true,
loglevel => err,
unless => "named-checkzone $name /tmp/$name",
}
exec { "mv-zone-$name":
command => "cp /tmp/$name /etc/bind/db.d/$name",
path => "/usr/bin:/usr/sbin:/bin",
logoutput => on_failure,
subscribe => File["tmp.db.$name"],
refreshonly => true,
require => Exec["zonecheck.helper.$name"],
onlyif => "named-checkzone $name /tmp/helper.$name",
notify => Exec["zone-reload-$name"],
}
exec { "zone-reload-$name":
command => "rndc reload $name",
path => "/usr/bin:/usr/sbin:/bin",
logoutput => true,
refreshonly => true,
require => Exec["mv-zone-$name"],
}
File["tmp.db.$name"]
-> Exec["zonecheck.$name"]
-> Exec["mv-zone-$name"]
-> Exec["zone-reload-$name"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.