diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..6dfe023fc --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +.*.sw? +/pkg +/spec/fixtures +/.rspec_system +/.vagrant +/.bundle +/vendor +/Gemfile.lock +/junit +/log +.yardoc +coverage diff --git a/manifests/server/conf.pp b/manifests/server/conf.pp index 14fcbc1fc..b50ff2226 100644 --- a/manifests/server/conf.pp +++ b/manifests/server/conf.pp @@ -80,7 +80,7 @@ # 'masters { mymasters; }', # ], # } -# keys => { +# keys => { # 'example.org-tsig' => [ # 'algorithm hmac-md5', # 'secret "aaabbbcccddd"', @@ -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], } } diff --git a/manifests/server/file.pp b/manifests/server/file.pp index dc59b203a..43c2bac81 100644 --- a/manifests/server/file.pp +++ b/manifests/server/file.pp @@ -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': @@ -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 { @@ -70,7 +73,7 @@ notify => Class['::bind::service'], # For the parent directory require => [ - Class['::bind::package'], + Package[$packagenameprefix], File[$zonedir], ], } diff --git a/manifests/service.pp b/manifests/service.pp index db91cb70c..2ed7312dc 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -17,5 +17,4 @@ hasstatus => true, require => Class['bind::package'], } - } diff --git a/spec/classes/bind_server_spec.rb b/spec/classes/bind_server_spec.rb index b42cf5610..578fe637c 100644 --- a/spec/classes/bind_server_spec.rb +++ b/spec/classes/bind_server_spec.rb @@ -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 \ No newline at end of file +end diff --git a/spec/defines/bind_server_conf_spec.rb b/spec/defines/bind_server_conf_spec.rb index f271c658b..1e736c16a 100644 --- a/spec/defines/bind_server_conf_spec.rb +++ b/spec/defines/bind_server_conf_spec.rb @@ -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 \ No newline at end of file + 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 diff --git a/spec/defines/bind_server_file_spec.rb b/spec/defines/bind_server_file_spec.rb index 12097295f..568e0c312 100644 --- a/spec/defines/bind_server_file_spec.rb +++ b/spec/defines/bind_server_file_spec.rb @@ -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 \ No newline at end of file + 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