Skip to content

Commit

Permalink
add default values for openSUSE / SLES
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
tampakrap committed Jan 11, 2017
1 parent 1866ba2 commit 7f6464c
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 22 deletions.
27 changes: 27 additions & 0 deletions files/suse_default-zones
Original file line number Diff line number Diff line change
@@ -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";
};

24 changes: 18 additions & 6 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
72 changes: 57 additions & 15 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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.')
}
Expand Down Expand Up @@ -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}"
Expand Down
12 changes: 12 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@
"operatingsystemrelease": [
"14.04"
]
},
{
"operatingsystem": "SLES",
"operatingsystemrelease": [
"12"
]
},
{
"operatingsystem": "openSUSE",
"operatingsystemrelease": [
"42.2"
]
}
],
"dependencies": [
Expand Down
2 changes: 2 additions & 0 deletions spec/defines/bind_generate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
'/etc/bind'
when 'RedHat'
'/etc/named'
when 'Suse'
'/etc/named.d'
end
end

Expand Down
2 changes: 2 additions & 0 deletions spec/defines/bind_key_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
'/etc/bind'
when 'RedHat'
'/etc/named'
when 'Suse'
'/etc/named.d'
end
end

Expand Down
2 changes: 2 additions & 0 deletions spec/defines/bind_view_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'/etc/bind'
when 'RedHat'
'/etc/named'
when 'Suse'
'/etc/named.d'
end
end

Expand Down
4 changes: 3 additions & 1 deletion spec/defines/bind_zone_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@
'/etc/bind'
when 'RedHat'
'/etc/named'
when 'Suse'
'/etc/named.d'
end
end

let(:bind_group) do
case facts[:osfamily]
when 'Debian'
'bind'
when 'RedHat'
when 'RedHat' or 'Suse'
'named'
end
end
Expand Down
2 changes: 2 additions & 0 deletions templates/named.conf.options.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ options {
<%end -%>
};

<%- unless @logging.empty? -%>
logging {
<% @logging['channels'].sort.each do |key, hash| -%>
channel <%=key%> {
Expand All @@ -40,3 +41,4 @@ logging {
};
<%end -%>
};
<%end -%>

0 comments on commit 7f6464c

Please sign in to comment.