From 7f6464c07783d9e7abd6d636aef51c7ac63fee1e Mon Sep 17 00:00:00 2001 From: Theo Chatzimichos Date: Fri, 30 Sep 2016 23:56:23 +0200 Subject: [PATCH] add default values for openSUSE / SLES - create files/suse_default-zones, as the default zones are inside in /etc/named.conf in suse distros - do not create /var/log/bind on suse - do not create default_logging in suse - move the default_logging inside the distro defaults in params.pp - add empty default_logging hash in suse - do not create logging block in named.conf.options template if @logging is empty --- files/suse_default-zones | 27 +++++++++++ manifests/config.pp | 24 +++++++--- manifests/params.pp | 72 +++++++++++++++++++++++------- metadata.json | 12 +++++ spec/defines/bind_generate_spec.rb | 2 + spec/defines/bind_key_spec.rb | 2 + spec/defines/bind_view_spec.rb | 2 + spec/defines/bind_zone_spec.rb | 4 +- templates/named.conf.options.erb | 2 + 9 files changed, 125 insertions(+), 22 deletions(-) create mode 100644 files/suse_default-zones diff --git a/files/suse_default-zones b/files/suse_default-zones new file mode 100644 index 0000000..98c84cc --- /dev/null +++ b/files/suse_default-zones @@ -0,0 +1,27 @@ +# Managed by Puppet +# Extracted from SUSE's default /etc/named.conf + +# The following zone definitions don't need any modification. The first one +# is the definition of the root name servers. The second one defines +# localhost while the third defines the reverse lookup for localhost. + +zone "." in { + type hint; + file "root.hint"; +}; + +zone "localhost" in { + type master; + file "localhost.zone"; +}; + +zone "0.0.127.in-addr.arpa" in { + type master; + file "127.0.0.zone"; +}; + +zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN { + type master; + file "127.0.0.zone"; +}; + diff --git a/manifests/config.pp b/manifests/config.pp index e3294c8..554bb0f 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -92,12 +92,24 @@ mode => '0775', } - file {'/var/log/named': - ensure => directory, - group => 'adm', - mode => '0750', - owner => $bind::params::bind_user, - seltype => 'named_log_t', + if $::osfamily == 'Debian' or $::osfamily == 'RedHat' { + file {'/var/log/named': + ensure => directory, + group => 'adm', + mode => '0750', + owner => $bind::params::bind_user, + seltype => 'named_log_t', + } + } + + if $::osfamily == 'Suse' { + file {'/etc/named.d/default-zones': + ensure => file, + owner => 'root', + group => 'root', + mode => '0644', + source => 'puppet:///modules/bind/suse_default-zones', + } } $opts = { diff --git a/manifests/params.pp b/manifests/params.pp index 401ae09..db577dc 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -4,21 +4,6 @@ # Please refer to Class['bind']. class bind::params { - $default_logging = { - 'channels' => { - 'simple_log' => { - 'file' => '"/var/log/named/bind.log"', - 'severity' => 'warning', - 'print-time' => 'yes', - 'print-severity' => 'yes', - 'print-category' => 'yes', - }, - }, - 'categories' => { - 'default' => 'simple_log', - }, - } - if $::osfamily == 'Debian' { $package_name = 'bind9' $service_name = 'bind9' @@ -44,6 +29,20 @@ 'auth-nxdomain' => 'no', 'listen-on-v6' => ['any'], } + $default_logging = { + 'channels' => { + 'simple_log' => { + 'file' => '"/var/log/named/bind.log"', + 'severity' => 'warning', + 'print-time' => 'yes', + 'print-severity' => 'yes', + 'print-category' => 'yes', + }, + }, + 'categories' => { + 'default' => 'simple_log', + }, + } if $bind::chroot { fail('Chroot mode is not yet implemented for Debian in this module.') } @@ -94,6 +93,49 @@ 'session-keyfile' => '"/run/named/session.key"', 'statistics-file' => '"/var/named/data/named_stats.txt"', } + $default_logging = { + 'channels' => { + 'simple_log' => { + 'file' => '"/var/log/named/bind.log"', + 'severity' => 'warning', + 'print-time' => 'yes', + 'print-severity' => 'yes', + 'print-category' => 'yes', + }, + }, + 'categories' => { + 'default' => 'simple_log', + }, + } + } + elsif $::osfamily == 'Suse' { + $package_name = 'bind' + $service_name = 'named' + $named_local_name = 'named.conf.include' + $bind_user = 'named' + $bind_group = 'named' + $service_pattern = undef + $service_restart = "/usr/bin/systemctl reload ${service_name}" + $service_has_status = true + $config_base_dir = '/etc' + $named_conf_name = 'named.conf' + $zones_directory = '/etc/named.d/zones' + $pri_directory = '/etc/named.d/pri' + $keys_directory = '/etc/named.d/keys' + $dynamic_directory = '/etc/named.d/dyn' + $acls_directory = '/etc/named.d/acls' + $views_directory = '/etc/named.d/views' + $default_zones_file = 'named.d/default-zones' + $default_config = { + 'directory' => '"/var/lib/named"', + 'managed-keys-directory' => '"/var/lib/named/dyn"', + 'dump-file' => '"/var/log/named_dump.db"', + 'statistics-file' => '"/var/log/named.stats"', + 'listen-on-v6' => ['any'], + 'notify' => 'no', + 'disable-empty-zone' => '"1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA"', + } + $default_logging = {} } else { fail "Unknown ${::operatingsystem}" diff --git a/metadata.json b/metadata.json index ff26aee..ce0212b 100644 --- a/metadata.json +++ b/metadata.json @@ -28,6 +28,18 @@ "operatingsystemrelease": [ "14.04" ] + }, + { + "operatingsystem": "SLES", + "operatingsystemrelease": [ + "12" + ] + }, + { + "operatingsystem": "openSUSE", + "operatingsystemrelease": [ + "42.2" + ] } ], "dependencies": [ diff --git a/spec/defines/bind_generate_spec.rb b/spec/defines/bind_generate_spec.rb index b32ee60..1876e13 100644 --- a/spec/defines/bind_generate_spec.rb +++ b/spec/defines/bind_generate_spec.rb @@ -22,6 +22,8 @@ '/etc/bind' when 'RedHat' '/etc/named' + when 'Suse' + '/etc/named.d' end end diff --git a/spec/defines/bind_key_spec.rb b/spec/defines/bind_key_spec.rb index 47f2d08..5066399 100644 --- a/spec/defines/bind_key_spec.rb +++ b/spec/defines/bind_key_spec.rb @@ -22,6 +22,8 @@ '/etc/bind' when 'RedHat' '/etc/named' + when 'Suse' + '/etc/named.d' end end diff --git a/spec/defines/bind_view_spec.rb b/spec/defines/bind_view_spec.rb index 2149334..79c1b07 100644 --- a/spec/defines/bind_view_spec.rb +++ b/spec/defines/bind_view_spec.rb @@ -20,6 +20,8 @@ '/etc/bind' when 'RedHat' '/etc/named' + when 'Suse' + '/etc/named.d' end end diff --git a/spec/defines/bind_zone_spec.rb b/spec/defines/bind_zone_spec.rb index 3f0248e..0842692 100644 --- a/spec/defines/bind_zone_spec.rb +++ b/spec/defines/bind_zone_spec.rb @@ -22,6 +22,8 @@ '/etc/bind' when 'RedHat' '/etc/named' + when 'Suse' + '/etc/named.d' end end @@ -29,7 +31,7 @@ case facts[:osfamily] when 'Debian' 'bind' - when 'RedHat' + when 'RedHat' or 'Suse' 'named' end end diff --git a/templates/named.conf.options.erb b/templates/named.conf.options.erb index be6a19a..3a58db0 100644 --- a/templates/named.conf.options.erb +++ b/templates/named.conf.options.erb @@ -16,6 +16,7 @@ options { <%end -%> }; +<%- unless @logging.empty? -%> logging { <% @logging['channels'].sort.each do |key, hash| -%> channel <%=key%> { @@ -40,3 +41,4 @@ logging { }; <%end -%> }; +<%end -%>