Skip to content

Instantly share code, notes, and snippets.

@norrs
Created February 25, 2012 03:19
Show Gist options
  • Save norrs/1905738 to your computer and use it in GitHub Desktop.
Save norrs/1905738 to your computer and use it in GitHub Desktop.
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