From 594d850cb2dea97d6b5d6d005fcff5ce1c52f116 Mon Sep 17 00:00:00 2001 From: Nate Riffe Date: Mon, 3 Sep 2012 21:52:38 -0500 Subject: [PATCH] Add templates for named.conf and for view fragments --- manifests/init.pp | 17 ++++++++++------- manifests/view.pp | 14 ++++++++++++++ templates/named.conf.erb | 3 +++ templates/view.erb | 22 ++++++++++++++++++++++ 4 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 manifests/view.pp create mode 100644 templates/named.conf.erb create mode 100644 templates/view.erb diff --git a/manifests/init.pp b/manifests/init.pp index 35aedfb..50f44b1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,4 +1,5 @@ class bind ( + $confdir = $bind::params::confdir, ) { include bind::params @@ -14,10 +15,18 @@ class bind ( require => Package[$bind::params::bind_package], } + file { "${bind::params::confdir}/named.conf": + ensure => present, + owner => $bind::params::bind_user, + group => $bind::params::bind_group, + mode => '0644', + content => template('bind/named.conf.erb'), + notify => Service[$bind::params::bind_service], + } + concat { [ "${bind::params::confdir}/acls.conf", "${bind::params::confdir}/views.conf", - "${bind::params::confdir}/zones.conf", ]: owner => $bind::params::bind_user, group => $bind::params::bind_group, @@ -36,10 +45,4 @@ class bind ( target => "${bind::params::confdir}/views.conf", content => "# This file is managed by puppet - changes will be lost\n", } - - concat::fragment { "named-zones-header": - order => '00', - target => "${bind::params::confdir}/zones.conf", - content => "# This file is managed by puppet - changes will be lost\n", - } } diff --git a/manifests/view.pp b/manifests/view.pp new file mode 100644 index 0000000..08374f2 --- /dev/null +++ b/manifests/view.pp @@ -0,0 +1,14 @@ +define bind::view ( + $match_clients = [ 'any' ], + $match_destinations = [], + $zones = [], + $recursion = true, +) { + $confdir = $bind::params::confdir + + concat::fragment { "bind-view-${name}": + order = '10', + target = "${bind::params::confdir}/views.conf", + content = template('bind/view.erb'), + } +} diff --git a/templates/named.conf.erb b/templates/named.conf.erb new file mode 100644 index 0000000..c677f4e --- /dev/null +++ b/templates/named.conf.erb @@ -0,0 +1,3 @@ +# This file is managed by puppet - changes will be lost +include "<%= confdir %>/acls.conf"; +include "<%= confdir %>/views.conf"; diff --git a/templates/view.erb b/templates/view.erb new file mode 100644 index 0000000..2b2fa95 --- /dev/null +++ b/templates/view.erb @@ -0,0 +1,22 @@ +view "<%= name %>" { +<%- if not match_clients.empty? -%> + match-clients { +<%- match_clients.each do |match_client| -%> + <%= match_client %>; +<%- end -%> + }; +<%- end -%> +<%- if not match_destinations.empty? -%> + match-destinations { +<%- match_destinations.each do |match_destination| -%> + <%= match_destination %> +<%- end -%> + }; +<%- end -%> + recursion <%= recursion ? 'yes' : 'no' %> + +<%- zones.each do |zone| -%> + include "<%= confdir %>/zones/${zone}.conf" +<%- end -%> +} +