Skip to content

Commit

Permalink
Merge pull request #40 from n1tr0g/master
Browse files Browse the repository at this point in the history
Solved Syntax error at 'inherits' in ::dns::server::options.pp:18
  • Loading branch information
solarkennedy committed Apr 5, 2014
2 parents 5b72292 + 3168e66 commit d0db3d3
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
18 changes: 12 additions & 6 deletions manifests/server/options.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@
# 'forwarders' => [ '8.8.8.8', '8.8.4.4' ],
# }
#
define dns::server::options inherits dns::server::params (
define dns::server::options(
$forwarders = [],
) {

if ! defined(Class['::dns::server']) {
fail('You must include the ::dns::server base class before using any dns options defined resources')
}

validate_array($forwarders)

file { $title:
ensure => present,
owner => $owner,
group => $group,
owner => $::dns::server::params::owner,
group => $::dns::server::params::group,
mode => '0644',
require => [File[${cfg_dir}], Class['dns::server::install']],
content => template("${module_name}/named.conf.options.erb"),
notify => Class['dns::server::service'],
require => [File[$::dns::server::params::cfg_dir], Class['::dns::server::install']],
content => template("${module_name}/named.conf.options.erb"),
notify => Class['::dns::server::service'],
}

}
4 changes: 2 additions & 2 deletions spec/defines/dns__acl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
describe 'dns::acl' do
let(:title) { 'trusted' }

let(:facts) { { :concat_basedir => '/tmp' } }

context 'passing a string to data' do
let :facts do { :concat_basedir => '/dne', } end
let :params do
{ :data => '192.168.0.0/24' }
end
Expand All @@ -15,7 +16,6 @@
end

context 'passing an array to data' do
let :facts do { :concat_basedir => '/dne', } end
let :params do
{ :data => [ '192.168.0.0/24' ] }
end
Expand Down
37 changes: 37 additions & 0 deletions spec/defines/dns_server_options_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
require 'spec_helper'

describe 'dns::server::options', :type => :define do
let :pre_condition do
'class { "::dns::server": }'
end

let(:facts) { { :osfamily => 'Debian', :concat_basedir => '/tmp' } }

let(:title) { '/etc/bind/named.conf.options' }

context 'passing valid array to forwarders' do
let :params do
{ :forwarders => [ '8.8.8.8', '4.4.4.4' ] }
end

it { should contain_file('/etc/bind/named.conf.options') }
it { should contain_file('/etc/bind/named.conf.options').with_content(/8\.8\.8\.8;$/) }
it { should contain_file('/etc/bind/named.conf.options').with_content(/4\.4\.4\.4;$/) }
it { should contain_file('/etc/bind/named.conf.options').with_ensure("present") }
it { should contain_file('/etc/bind/named.conf.options').with_owner("bind") }
it { should contain_file('/etc/bind/named.conf.options').with_group("bind") }

end

context 'passing a string to forwarders' do
let :params do
{ :forwarders => '8.8.8.8' }
end

it 'should fail input validation' do
expect { subject }.to raise_error(Puppet::Error, /is not an Array/)
end
end

end

0 comments on commit d0db3d3

Please sign in to comment.