# Install DNS server. # class dns::server { case $operatingsystem { centos,fedora: { $rootdir = "/var/named/chroot" $rndckey = "${rootdir}/etc/rndc.key" $service = "named" package { "bind": name => "bind-chroot", ensure => installed, } } ubuntu: { $rootdir = "/etc/bind" $rndckey = "${rootdir}/rndc.key" $service = "bind9" package { "bind": name => "bind9", ensure => installed, } } default: { $rootdir = "/var/named" } } file { "${rndckey}": ensure => present, mode => 0640, owner => root, group => $operatingsystem ? { ubuntu => bind, default => named, }, require => $operatingsystem ? { openbsd => undef, default => Package["bind"], }, } exec { "rndc-confgen": command => "rndc-confgen -a -t ${rootdir}", path => "/bin:/usr/bin:/sbin:/usr/sbin", unless => "test -s ${rndckey}", require => File[$rndckey], } file { "/etc/rndc.key": ensure => "${rndckey}", owner => root, group => $operatingsystem ? { openbsd => wheel, ubuntu => bind, default => root, }, require => Exec["rndc-confgen"], notify => Service["${service}"], seltype => "dnssec_t", } service { "${service}": ensure => running, enable => true, status => "/usr/sbin/rndc status", stop => $operatingsystem ? { openbsd => "pkill -u named", ubuntu => "/etc/init.d/bind9 stop", default => undef, }, start => $operatingsystem ? { openbsd => "/usr/sbin/named", ubuntu => "/etc/init.d/bind9 start", default => undef, }, require => Exec["rndc-confgen"], } case $operatingsystem { ubuntu: { file { "${rootdir}/named.conf.local": ensure => present, source => [ "puppet:///files/dns/named.conf.${fqdn}", ], mode => 0640, owner => root, group => bind, require => Package["bind"], notify => Service["${service}"], } file { "${rootdir}/named.conf.options": ensure => present, source => [ "puppet:///files/dns/named.conf.options.${fqdn}", ], mode => 0640, owner => root, group => bind, require => Package["bind"], notify => Service["${service}"], } } default: { file { "${rootdir}/etc/named.conf": ensure => present, source => [ "puppet:///files/dns/named.conf.${fqdn}", "puppet:///files/dns/named.conf", ], mode => 0640, owner => root, group => named, require => $operatingsystem ? { openbsd => undef, default => Package["bind"], }, notify => Service["${service}"], } } } } # Install dynamic DNS update script # # === Global variables # # $dns_nsupdate_name: # FQDN to update into DNS. # # $dns_nsupdate_key: # DNS key to use when updating entry. Usually in format: # # for example: # gw1.example.com. sZ6GgTZLBX83LXCoo # # $dns_nsupdate_server: # DNS server address where to update entry. # # $dns_nsupdate_zone: # Zone name to update. Defaults to domain part of # $dns_nsupdate_name variable. # class dns::nsupdate { file { "/usr/local/sbin/nsupdate.sh": ensure => present, content => template("dns/nsupdate.sh.erb"), mode => 0700, owner => root, group => $operatingsystem ? { openbsd => wheel, default => root, }, } cron { "nsupdate": ensure => present, command => "/usr/local/sbin/nsupdate.sh", minute => "*/5", require => File["/usr/local/sbin/nsupdate.sh"], } }