Skip to content

Ordering #45

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.*.sw?
/pkg
/spec/fixtures
/.rspec_system
/.vagrant
/.bundle
/vendor
/Gemfile.lock
/junit
/log
.yardoc
coverage
6 changes: 5 additions & 1 deletion manifests/server/conf.pp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
# 'masters { mymasters; }',
# ],
# }
# keys => {
# keys => {
# 'example.org-tsig' => [
# 'algorithm hmac-md5',
# 'secret "aaabbbcccddd"',
Expand Down Expand Up @@ -118,12 +118,16 @@
$keys = {},
$includes = [],
$views = {},
$packagenameprefix = $::bind::params::packagenameprefix,
) {
# ::bind::server::conf has a dependency on bind
include ::bind

# Everything is inside a single template
file { $title:
notify => Class['::bind::service'],
content => template('bind/named.conf.erb'),
require => Package[$packagenameprefix],
}

}
25 changes: 14 additions & 11 deletions manifests/server/file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
# Zone file content (usually template-based). Default: none
# $ensure:
# Whether the zone file should be 'present' or 'absent'. Default: present.
# $packagenameprefix:
# The name of the package providing the bind service. Default: osfamily-dependent
#
# Sample Usage :
# bind::server::file { 'example.com':
Expand All @@ -29,17 +31,18 @@
# }
#
define bind::server::file (
$zonedir = '/var/named',
$owner = 'root',
$group = undef,
$mode = '0640',
$dirmode = '0750',
$source = undef,
$source_base = undef,
$content = undef,
$ensure = undef,
$zonedir = '/var/named',
$owner = 'root',
$group = undef,
$mode = '0640',
$dirmode = '0750',
$source = undef,
$source_base = undef,
$content = undef,
$ensure = undef,
$packagenameprefix = $::bind::params::packagenameprefix,
) {

include ::bind
include '::bind::params'

if $group {
Expand Down Expand Up @@ -70,7 +73,7 @@
notify => Class['::bind::service'],
# For the parent directory
require => [
Class['::bind::package'],
Package[$packagenameprefix],
File[$zonedir],
],
}
Expand Down
1 change: 0 additions & 1 deletion manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@
hasstatus => true,
require => Class['bind::package'],
}

}
28 changes: 14 additions & 14 deletions spec/classes/bind_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

it { should contain_package('bind').with_ensure('installed') }
it { should contain_service('named').with({
'hasstatus' => true,
'enable' => true,
'ensure' => 'running',
'restart' => '/sbin/service named reload'
})}
'hasstatus' => true,
'enable' => true,
'ensure' => 'running',
'restart' => '/sbin/service named reload',
})}

it 'should create the logging directory' do
expect { should contain_file('/var/log/named').with({
'ensure' => 'directory',
'owner' => 'root',
'group' => 'named',
'mode' => '0770',
'seltype' => 'var_log_t'
})}
expect { should contain_file('/var/log/named').with({
'ensure' => 'directory',
'owner' => 'root',
'group' => 'named',
'mode' => '0770',
'seltype' => 'var_log_t',
})}
end

end
end
95 changes: 61 additions & 34 deletions spec/defines/bind_server_conf_spec.rb
Original file line number Diff line number Diff line change
@@ -1,39 +1,66 @@
require 'spec_helper'

describe 'bind::server::conf' do
let (:title) { '/etc/named.conf' }
let (:params) { {
:acls => {
'rfc1918' => [ '10/8', '172.16/12', '192.168/16' ]
},
:masters => {
'mymasters' => ['192.0.2.1', '198.51.100.1']
},
:zones => {
'example.com' => [
'type master',
'file "example.com"',
],
'example.org' => [
'type slave',
'file "slaves/example.org"',
'masters { mymasters; }',
],
},
:includes => [
'/etc/myzones.conf',
],
} }
let (:title) { '/etc/named.conf' }
let (:params) { {
:acls => {
'rfc1918' => [ '10/8', '172.16/12', '192.168/16' ]
},
:masters => {
'mymasters' => ['192.0.2.1', '198.51.100.1']
},
:zones => {
'example.com' => [
'type master',
'file "example.com"',
],
'example.org' => [
'type slave',
'file "slaves/example.org"',
'masters { mymasters; }',
],
},
:includes => [
'/etc/myzones.conf',
],
} }

it 'should generate the bind configuration' do
expect { should contain_file ('/etc/named.conf')}
content = catalogue.resource('file', '/etc/named.conf').send(:parameters)[:content]
content.should_not be_empty
content.should match('acl rfc1918')
content.should match('masters mymasters')
content.should match('zone "example.com"')
content.should match('zone "example.org"')
content.should match('include "/etc/myzones.conf"')
end
it 'should generate the bind configuration' do
expect { should contain_file ('/etc/named.conf')}
content = catalogue.resource('file', '/etc/named.conf').send(:parameters)[:content]
content.should_not be_empty
content.should match('acl rfc1918')
content.should match('masters mymasters')
content.should match('zone "example.com"')
content.should match('zone "example.org"')
content.should match('include "/etc/myzones.conf"')
end

end
context 'RedHat family' do
let (:facts) { {
:osfamily => 'RedHat',
} }

it { should contain_package('bind') }
end

context 'Debian family' do
let (:facts) { {
:osfamily => 'Debian',
} }

it { should contain_package('bind9') }
end

context 'FreeBSD family' do
let (:facts) { {
:osfamily => 'Freebsd',
} }

it { should contain_package('bind910') }
end

context 'Other families' do
it { should contain_package('bind') }
end
end
40 changes: 34 additions & 6 deletions spec/defines/bind_server_file_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
require 'spec_helper'

describe 'bind::server::file' do
let(:title) { 'example.com' }
let (:params) {{
:source => 'puppet:///modules/bind/named.empty'
}}
let(:title) { 'example.com' }
let (:params) {{
:source => 'puppet:///modules/bind/named.empty'
}}

it { should contain_file('/var/named/example.com') }
end
it { should contain_file('/var/named/example.com') }

context 'RedHat family' do
let (:facts) { {
:osfamily => 'RedHat',
} }

it { should contain_package('bind') }
end

context 'Debian family' do
let (:facts) { {
:osfamily => 'Debian',
} }

it { should contain_package('bind9') }
end

context 'FreeBSD family' do
let (:facts) { {
:osfamily => 'Freebsd',
} }

it { should contain_package('bind910') }
end

context 'Other families' do
it { should contain_package('bind') }
end
end