From c91be3206f9dea5844eb4ee0bbbd416226428305 Mon Sep 17 00:00:00 2001 From: Jussi Date: Mon, 18 Apr 2011 13:56:59 +0300 Subject: [PATCH] Modified dns manifest to work with Ubuntu --- dns/manifests/init.pp | 80 ++++++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 20 deletions(-) diff --git a/dns/manifests/init.pp b/dns/manifests/init.pp index 7405b09..2c95c81 100644 --- a/dns/manifests/init.pp +++ b/dns/manifests/init.pp @@ -5,21 +5,35 @@ 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 { "${rootdir}/etc/rndc.key": + file { "${rndckey}": ensure => present, mode => 0640, owner => root, - group => named, + group => $operatingsystem ? { + ubuntu => bind, + default => named, + }, require => $operatingsystem ? { openbsd => undef, default => Package["bind"], @@ -28,50 +42,76 @@ class dns::server { exec { "rndc-confgen": command => "rndc-confgen -a -t ${rootdir}", path => "/bin:/usr/bin:/sbin:/usr/sbin", - unless => "test -s ${rootdir}/etc/rndc.key", - require => File["${rootdir}/etc/rndc.key"], + unless => "test -s ${rndckey}", + require => File[$rndckey], } file { "/etc/rndc.key": - ensure => "${rootdir}/etc/rndc.key", + ensure => "${rndckey}", owner => root, group => $operatingsystem ? { openbsd => wheel, + ubuntu => bind, default => root, }, require => Exec["rndc-confgen"], - notify => Service["named"], + notify => Service["${service}"], seltype => "dnssec_t", } - service { "named": + 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"], } - 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["named"], + 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}"], + } + } } - }