diff --git a/dns/manifests/init.pp b/dns/manifests/init.pp index 6ccdfa3..1af49a6 100644 --- a/dns/manifests/init.pp +++ b/dns/manifests/init.pp @@ -72,39 +72,6 @@ class dns::server { require => Exec["rndc-confgen"], } - define populate_zones() { - $zone = $name - file { "${confdir}/db.${zone}": - ensure => present, - content => template("dns/db.erb"), - mode => 0640, - owner => "root", - group => "bind", - require => Package["bind"], - notify => Service["named"], - } - file { "${confdir}/db.${zone}-dynamic": - ensure => present, - source => [ "puppet:///files/dns/db.${zone}-dynamic.${homename}", - "puppet:///files/dns/empty", ], - mode => 0640, - owner => "root", - group => "bind", - require => Package["bind"], - notify => Service["named"], - } - file { "${confdir}/db.${zone}-static": - ensure => present, - source => [ "puppet:///files/dns/db.${zone}-static.${homename}", - "puppet:///files/dns/empty", ], - mode => 0640, - owner => "root", - group => "bind", - require => Package["bind"], - notify => Service["named"], - } - } - case $operatingsystem { "ubuntu": { $ipaddr = $dns_listener_ipaddr @@ -119,14 +86,13 @@ class dns::server { } file { "${confdir}/named.conf.options": ensure => present, - content => template("dns/named.conf.options.erb"), + content => template("dns/named.conf.options.erb"), mode => 0640, owner => "root", group => "bind", require => Package["bind"], notify => Service["named"], } - populate_zones { $dns_zones: } } default: { file { "${confdir}/named.conf": @@ -147,6 +113,77 @@ class dns::server { } +# Configure interface. +# +# === Parameters +# +# $name: +# Zone name. +# $role: +# The role {master, slave} of this host. +# $master: +# IP address and FQDN or hostname of the DNS master for this zone. +# $slaves: +# IP addresess and FQDNs or hostnames of the DNS slaves for this zone. +# +define dns::zone($role = "master", $master = {}, $slaves = {}) { + + $zone = $name + + case $operatingsystem { + "centos","fedora": { + $confdir = "/var/named/chroot/etc" + } + "ubuntu": { + $confdir = "/etc/bind" + } + default: { + $confdir = "/var/named/etc" + } + } + + file { "${confdir}/zone.${zone}": + ensure => present, + content => template("dns/zone.$role.erb"), + mode => 0640, + owner => "root", + group => "bind", + require => Package["bind"], + notify => Service["named"], + } + file { "${confdir}/db.${zone}": + ensure => present, + content => template("dns/db.erb"), + mode => 0640, + owner => "root", + group => "bind", + require => Package["bind"], + notify => Service["named"], + } + file { "${confdir}/db.${zone}-dynamic": + ensure => present, + source => [ "puppet:///files/dns/db.${zone}-dynamic.${homename}", + "puppet:///files/dns/empty", ], + mode => 0640, + owner => "root", + group => "bind", + require => Package["bind"], + notify => Service["named"], + } + file { "${confdir}/db.${zone}-static": + ensure => present, + source => [ "puppet:///files/dns/db.${zone}-static.${homename}", + "puppet:///files/dns/empty", ], + mode => 0640, + owner => "root", + group => "bind", + require => Package["bind"], + notify => Service["named"], + } + +} + + # Install dynamic DNS update script # # === Global variables