diff --git a/dns/manifests/init.pp b/dns/manifests/init.pp index 2c95c81..6f1c4ea 100644 --- a/dns/manifests/init.pp +++ b/dns/manifests/init.pp @@ -2,113 +2,110 @@ # 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, + if $operatingsystem != "OpenBSD" { + package { "bind": + name => $operatingsystem ? { + "ubuntu" => "bind9", + default => "bind-chroot", } } - ubuntu: { - $rootdir = "/etc/bind" - $rndckey = "${rootdir}/rndc.key" - $service = "bind9" - package { "bind": - name => "bind9", - ensure => installed, - } - } - default: { - $rootdir = "/var/named" - } } - file { "${rndckey}": + case $operatingsystem { + "centos","fedora": { + $confdir = "/var/named/chroot/etc" + } + "ubuntu": { + $confdir = "/etc/bind" + } + default: { + $confdir = "/var/named/etc" + } + } + + file { "${confdir}/rndc.key": ensure => present, mode => 0640, - owner => root, + owner => "root", group => $operatingsystem ? { - ubuntu => bind, - default => named, - }, + "ubuntu" => "bind", + default => "named", + }, require => $operatingsystem ? { - openbsd => undef, - default => Package["bind"], + "openbsd" => undef, + default => Package["bind"], }, } exec { "rndc-confgen": - command => "rndc-confgen -a -t ${rootdir}", + command => "rndc-confgen -a -t ${confdir}", path => "/bin:/usr/bin:/sbin:/usr/sbin", - unless => "test -s ${rndckey}", - require => File[$rndckey], + unless => "test -s ${confdir}/rndc.key", + require => File["${confdir}/rndc.key"], } - 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", + case $operatingsystem { + "centos","fedora": { + file { "/etc/rndc.key": + ensure => "${confdir}/rndc.key", + owner => "root", + group => "root", + require => Exec["rndc-confgen"], + } + } } - service { "${service}": + service { "named": + name => $operatingsystem ? { + "ubuntu" => "bind9", + default => "named", + }, ensure => running, enable => true, status => "/usr/sbin/rndc status", stop => $operatingsystem ? { - openbsd => "pkill -u named", - ubuntu => "/etc/init.d/bind9 stop", - default => undef, + "openbsd" => "pkill -u named", + default => undef, }, start => $operatingsystem ? { - openbsd => "/usr/sbin/named", - ubuntu => "/etc/init.d/bind9 start", - default => undef, + "openbsd" => "/usr/sbin/named", + default => undef, }, require => Exec["rndc-confgen"], } case $operatingsystem { - ubuntu: { - file { "${rootdir}/named.conf.local": + "ubuntu": { + file { "${confdir}/named.conf.local": ensure => present, - source => [ "puppet:///files/dns/named.conf.${fqdn}", ], + source => "puppet:///files/dns/named.conf.${fqdn}", mode => 0640, - owner => root, - group => bind, + owner => "root", + group => "bind", require => Package["bind"], - notify => Service["${service}"], + notify => Service["named"], } - file { "${rootdir}/named.conf.options": + file { "${confdir}/named.conf.options": ensure => present, - source => [ "puppet:///files/dns/named.conf.options.${fqdn}", ], + source => "puppet:///files/dns/named.conf.options.${fqdn}", mode => 0640, - owner => root, - group => bind, + owner => "root", + group => "bind", require => Package["bind"], - notify => Service["${service}"], + notify => Service["named"], } } default: { - file { "${rootdir}/etc/named.conf": + file { "${confdir}/named.conf": ensure => present, source => [ "puppet:///files/dns/named.conf.${fqdn}", "puppet:///files/dns/named.conf", ], mode => 0640, - owner => root, - group => named, + owner => "root", + group => "named", require => $operatingsystem ? { openbsd => undef, default => Package["bind"], }, - notify => Service["${service}"], + notify => Service["named"], } } }