Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration of the check-names and transfer-format options #138

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
cbb7db1
Allow specifying a transfer-format
carlgarner Mar 8, 2018
42decb4
Add transfer_format to zone and view
carlgarner Mar 8, 2018
50b1280
Add transfer_format to global options
carlgarner Mar 8, 2018
762f7e6
Add check_names to zone configuration
carlgarner Mar 8, 2018
5e0a3aa
Add check_names to view and global configuration
carlgarner Mar 8, 2018
5d48e21
Square brace in wrong place
carlgarner Mar 8, 2018
f7e23ce
Alter defaults and tests for content
carlgarner Mar 8, 2018
511f670
Alter defaults and tests for content on views
carlgarner Mar 8, 2018
24b1651
Change undef to '' for template
carlgarner Apr 5, 2018
4090051
Allow specifying options for files, allowing bind to rotate it's own …
carlgarner Apr 12, 2018
2e1711b
Merge branch 'master' of https://github.com/inkblot/puppet-bind into …
carlgarner Aug 3, 2018
80bef80
Merge pull request #2 from carlgarner/inkblot-master
carlgarner Aug 3, 2018
9db0907
Helpful when changes are actually saved
carlgarner Aug 3, 2018
6a1c27f
Use the source if it's set
carlgarner Aug 20, 2018
e6728ef
Attempt service checks before restarting bind
carlgarner Oct 23, 2018
e394570
Add geoip-directory support
carlgarner Jul 8, 2019
440f2eb
ACL geoip support
carlgarner Jul 8, 2019
f5533bf
Merge pull request #3 from pikseluls/geoip
carlgarner Jul 8, 2019
b710b69
rogue semicolon
carlgarner Jul 8, 2019
46fada8
Merge pull request #4 from pikseluls/geoip
carlgarner Jul 8, 2019
846ce4c
variable wrapping
carlgarner Jul 8, 2019
4ce304f
Merge pull request #5 from pikseluls/geoip
carlgarner Jul 8, 2019
b59f0dc
change else if to elsif
carlgarner Jul 8, 2019
c9fd64d
Merge pull request #6 from pikseluls/geoip
carlgarner Jul 8, 2019
8bdff4b
Allow us to disable deploying a cache file
carlgarner Jul 12, 2019
e97d5d2
Merge pull request #7 from pikseluls/geoip
carlgarner Jul 12, 2019
b2edf9f
Allow specifying of in-view to allow zone duplicating across views
carlgarner Jul 16, 2019
adfcc8c
Allow passing an array into the ACL definition
carlgarner Jul 16, 2019
043229f
Merge remote-tracking branch 'origin/geoip' into geoip
carlgarner Jul 17, 2019
0e0dc77
Merge pull request #8 from pikseluls/geoip
carlgarner Jul 17, 2019
e11c99c
What sort of language doesn't have else?
carlgarner Jul 17, 2019
c600ea9
Merge pull request #9 from pikseluls/geoip
carlgarner Jul 17, 2019
f32a437
inverted close
carlgarner Jul 17, 2019
7ff4cc7
Merge pull request #10 from pikseluls/geoip
carlgarner Jul 17, 2019
7a6d900
Updates to improve geo capabilities
carlgarner Jul 17, 2019
5163a11
Merge pull request #11 from pikseluls/geoip
carlgarner Jul 17, 2019
b2b788a
Try directory cleaning
carlgarner Jul 17, 2019
a4cbc36
Merge pull request #12 from pikseluls/geoip
carlgarner Jul 17, 2019
9e592c4
revert to namevar
carlgarner Jul 18, 2019
eafba9e
Merge pull request #13 from pikseluls/geoip
carlgarner Jul 18, 2019
ebeeb50
change dnssec-lookaside from auto to no to prevent issues
carlgarner Mar 25, 2020
133db75
Merge pull request #14 from pikseluls/dnssec-lookaside
carlgarner Mar 25, 2020
aa79d42
remove the dnssec-lookaside option to future proof
carlgarner Mar 25, 2020
24c1025
Merge pull request #15 from pikseluls/dnssec-lookaside
carlgarner Mar 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions manifests/acl.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

define bind::acl (
$addresses,
$geoip_type = undef,
$geoip_location = undef,
) {

concat::fragment { "bind-acl-${name}":
Expand Down
240 changes: 129 additions & 111 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,133 +1,151 @@
# ex: syntax=puppet si ts=4 sw=4 et

class bind (
$forwarders = undef,
$forward = undef,
$dnssec = undef,
$filter_ipv6 = undef,
$version = undef,
$statistics_port = undef,
$auth_nxdomain = undef,
$include_default_zones = true,
$include_local = false,
$tkey_gssapi_credential = undef,
$tkey_domain = undef,
$chroot = false,
$chroot_class = $::bind::defaults::chroot_class,
$chroot_dir = $::bind::defaults::chroot_dir,
# NOTE: we need to be able to override this parameter when declaring class,
# especially when not using hiera (i.e. when using Foreman as ENC):
$default_zones_include = $::bind::defaults::default_zones_include,
$forwarders = undef,
$forward = undef,
$dnssec = undef,
$filter_ipv6 = undef,
$version = undef,
$statistics_port = undef,
$auth_nxdomain = undef,
$include_default_zones = true,
$include_local = false,
$tkey_gssapi_credential = undef,
$tkey_domain = undef,
$chroot = false,
$chroot_class = $::bind::defaults::chroot_class,
$chroot_dir = $::bind::defaults::chroot_dir,
# NOTE: we need to be able to override this parameter when declaring class,
# especially when not using hiera (i.e. when using Foreman as ENC):
$default_zones_include = $::bind::defaults::default_zones_include,
$transfer_format = undef,
$check_names_type = '', #master, slave or response
$check_names_handling = '', #warn, fail or ignore
$geoip_directory = undef,
) inherits bind::defaults {
if $chroot and !$::bind::defaults::chroot_supported {
fail('Chroot for bind is not supported on your OS')
}
File {
ensure => present,
owner => 'root',
group => $::bind::defaults::bind_group,
mode => '0644',
require => Package['bind'],
notify => Service['bind'],
}

include ::bind::updater
if $chroot and !$::bind::defaults::chroot_supported {
fail('Chroot for bind is not supported on your OS')
}
File {
ensure => present,
owner => 'root',
group => $::bind::defaults::bind_group,
mode => '0644',
require => Package['bind'],
notify => Exec['bind-config-test'],
}

package { 'bind':
ensure => latest,
name => $::bind::defaults::bind_package,
}
include ::bind::updater

if $chroot and $::bind::defaults::chroot_class {
# When using a dedicated chroot class, service declaration is dedicated to this class
class { $::bind::defaults::chroot_class : }
}
package { 'bind':
ensure => latest,
name => $::bind::defaults::bind_package,
}

if $dnssec {
file { '/usr/local/bin/dnssec-init':
ensure => present,
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/bind/dnssec-init',
}
}
if $chroot and $::bind::defaults::chroot_class {
# When using a dedicated chroot class, service declaration is dedicated to this class
class { $::bind::defaults::chroot_class: }
}

# rndc only supports HMAC-MD5
bind::key { 'rndc-key':
algorithm => 'hmac-md5',
secret_bits => '512',
keydir => $bind::defaults::confdir,
keyfile => 'rndc.key',
include => false,
if $dnssec {
file { '/usr/local/bin/dnssec-init':
ensure => present,
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/bind/dnssec-init',
}
}

file { '/usr/local/bin/rndc-helper':
ensure => present,
owner => 'root',
group => 'root',
mode => '0755',
content => template('bind/rndc-helper.erb'),
}
# rndc only supports HMAC-MD5
bind::key { 'rndc-key':
algorithm => 'hmac-md5',
secret_bits => '512',
keydir => $bind::defaults::confdir,
keyfile => 'rndc.key',
include => false,
}

file { "${::bind::defaults::confdir}/zones":
ensure => directory,
mode => '2755',
}
file {
'/usr/local/bin/rndc-helper':
ensure => present,
owner => 'root',
group => 'root',
mode => '0755',
content => template('bind/rndc-helper.erb'),
;
"${::bind::defaults::confdir}/zones":
ensure => directory,
mode => '2755',
purge => true,
force => true,
;
"${::bind::defaults::confdir}/zones/geo":
ensure => directory,
mode => '2755',
purge => true,
force => true,
;
$::bind::defaults::namedconf:
content => template('bind/named.conf.erb'),
}

file { $::bind::defaults::namedconf:
content => template('bind/named.conf.erb'),
if $include_default_zones and $::bind::defaults::default_zones_source {
file { $default_zones_include:
source => $::bind::defaults::default_zones_source,
}
}

if $include_default_zones and $::bind::defaults::default_zones_source {
file { $default_zones_include:
source => $::bind::defaults::default_zones_source,
}
}
class { '::bind::keydir':
keydir => "${::bind::defaults::confdir}/keys",
}

class { '::bind::keydir':
keydir => "${::bind::defaults::confdir}/keys",
}
concat { [
"${::bind::defaults::confdir}/acls.conf",
"${::bind::defaults::confdir}/keys.conf",
"${::bind::defaults::confdir}/views.conf",
"${::bind::defaults::confdir}/servers.conf",
"${::bind::defaults::confdir}/logging.conf",
"${::bind::defaults::confdir}/view-mappings.txt",
"${::bind::defaults::confdir}/domain-mappings.txt",
]:
owner => 'root',
group => $::bind::defaults::bind_group,
mode => '0644',
warn => true,
require => Package['bind'],
notify => Exec['bind-config-test'],
}

concat { [
"${::bind::defaults::confdir}/acls.conf",
"${::bind::defaults::confdir}/keys.conf",
"${::bind::defaults::confdir}/views.conf",
"${::bind::defaults::confdir}/servers.conf",
"${::bind::defaults::confdir}/logging.conf",
"${::bind::defaults::confdir}/view-mappings.txt",
"${::bind::defaults::confdir}/domain-mappings.txt",
]:
owner => 'root',
group => $::bind::defaults::bind_group,
mode => '0644',
warn => true,
require => Package['bind'],
notify => Service['bind'],
}
concat::fragment { 'bind-logging-header':
order => '00-header',
target => "${::bind::defaults::confdir}/logging.conf",
content => "logging {\n";
}

concat::fragment { 'bind-logging-header':
order => '00-header',
target => "${::bind::defaults::confdir}/logging.conf",
content => "logging {\n";
}
concat::fragment { 'bind-logging-footer':
order => '99-footer',
target => "${::bind::defaults::confdir}/logging.conf",
content => "};\n";
}

concat::fragment { 'bind-logging-footer':
order => '99-footer',
target => "${::bind::defaults::confdir}/logging.conf",
content => "};\n";
# DO NOT declare a bind service when chrooting bind with bind::chroot::package class,
# because it needs another dedicated chrooted-bind service (i.e. named-chroot on RHEL)
# AND it also needs $::bind::defaults::bind_service being STOPPED and DISABLED.
if !$chroot or ($chroot and $::bind::defaults::chroot_class == 'bind::chroot::manual') {
exec { 'bind-config-test':
path => '/usr/sbin',
command => "named-checkconf ${::bind::defaults::namedconf} > ${::bind::defaults::confdir}/named-checkconf.output 2>&1",
refreshonly => true,
notify => Service['bind'],
}

# DO NOT declare a bind service when chrooting bind with bind::chroot::package class,
# because it needs another dedicated chrooted-bind service (i.e. named-chroot on RHEL)
# AND it also needs $::bind::defaults::bind_service being STOPPED and DISABLED.
if !$chroot or ($chroot and $::bind::defaults::chroot_class == 'bind::chroot::manual') {
service { 'bind':
ensure => running,
name => $::bind::defaults::bind_service,
enable => true,
hasrestart => true,
hasstatus => true,
}
service { 'bind':
ensure => running,
name => $::bind::defaults::bind_service,
enable => true,
hasrestart => true,
hasstatus => true,
}
}
}
1 change: 1 addition & 0 deletions manifests/logging/channel.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
$destination = 'file',
$file_path = $::bind::defaults::logdir,
$file_name = '',
$file_options = '',
$syslog_facility = '',
$severity = '',
$print_category = true,
Expand Down
21 changes: 11 additions & 10 deletions manifests/server.pp
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# ex: syntax=puppet si ts=4 sw=4 et

define bind::server (
$bogus = false,
$edns = true,
$key = undef,
$transfers = undef,
$bogus = false,
$edns = true,
$key = undef,
$transfers = undef,
$transfer_format = undef,
) {
include ::bind
include ::bind

concat::fragment { "bind-server-${name}":
order => 10,
target => "${::bind::confdir}/servers.conf",
content => template('bind/server.erb'),
}
concat::fragment { "bind-server-${name}":
order => 10,
target => "${::bind::confdir}/servers.conf",
content => template('bind/server.erb'),
}
}
4 changes: 4 additions & 0 deletions manifests/view.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
$empty_zones = '',
$order = '10',
$minimal_responses = false,
$transfer_format = '',
$check_names_type = '', #master, slave or response
$check_names_handling = '', #warn, fail or ignore
$geo_zones = [],
) {
$confdir = $::bind::confdir
$default_zones_include = $::bind::default_zones_include
Expand Down
36 changes: 28 additions & 8 deletions manifests/zone.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
$forward = '',
$source = '',
$forwarders_port = 53,
$transfer_format = '',
$check_names = '',
$deploy_file = true,
$in_view = '',
) {
# where there is a zone, there is a server
include ::bind
Expand Down Expand Up @@ -81,6 +85,10 @@
fail("source may only be provided for bind::zone resources with zone_type 'master' or 'hint'")
}

unless !($check_names != '' and ! member(['warn', 'fail', 'ignore'], $check_names)) {
fail("check_names must be 'warn', 'fail' or 'ignore'")
}

$zone_file_mode = $zone_type ? {
'master' => $dynamic ? {
true => 'init',
Expand Down Expand Up @@ -149,14 +157,26 @@
}
}

file { "${::bind::confdir}/zones/${name}.conf":
ensure => present,
owner => 'root',
group => $bind_group,
mode => '0644',
content => template('bind/zone.conf.erb'),
notify => Service['bind'],
require => Package['bind'],
if $in_view != '' {
file { "${::bind::confdir}/zones/geo/${name}.conf":
ensure => present,
owner => 'root',
group => $bind_group,
mode => '0644',
content => template('bind/zone.conf.erb'),
notify => Exec['bind-config-test'],
require => Package['bind'],
}
} else {
file { "${::bind::confdir}/zones/${name}.conf":
ensure => present,
owner => 'root',
group => $bind_group,
mode => '0644',
content => template('bind/zone.conf.erb'),
notify => Exec['bind-config-test'],
require => Package['bind'],
}
}

concat::fragment { "bind-zone-mapping-${name}":
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "inkblot-bind",
"version": "7.4.0",
"version": "7.4.0-a",
"author": "inkblot",
"license": "Apache-2.0",
"summary": "ISC BIND name server",
Expand Down
11 changes: 11 additions & 0 deletions templates/acl.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,15 @@ acl <%= @name %> {
<%- Array(@addresses).each do |address| -%>
<%= address %>;
<%- end -%>
<%- if @geoip_type and @geoip_location and @geoip_type == 'city' -%>
geoip <%= @geoip_type %> "<%= @geoip_location %>";
<%- elsif @geoip_type and @geoip_location -%>
<%- if @geoip_location.is_a?(Array) -%>
<%- Array(@geoip_location).each do |geo_loc| -%>
geoip <%= @geoip_type %> <%= geo_loc %>;
<%- end -%>
<%- else -%>
geoip <%= @geoip_type %> <%= @geoip_location %>;
<%- end -%>
<%- end -%>
};
Loading