Make it all work again.

Previous iterations and even a release were all broken. The module works again,
sorry for the interlude.

- Giving up on params and moving to module_data (WIP)
- Change the Package and Service references to the static 'bind' name
- Add a meager amount of test coverage
This commit is contained in:
Nate Riffe 2015-01-08 08:09:32 -06:00
parent f7740f2a05
commit 7a74314a1e
21 changed files with 156 additions and 88 deletions

View File

@ -1,9 +1,9 @@
---
fixtures:
forge_modules:
concat:
repo: "puppetlabs/concat"
ref: "1.0.0"
stdlib: "puppetlabs/stdlib"
module_data: "ripienaar/module_data"
symlinks:
bind: "#{source_dir}"

View File

@ -3,7 +3,7 @@ source 'https://rubygems.org'
if ENV.include?('PUPPET_VERSION')
puppetversion = "~>#{ENV['PUPPET_VERSION']}"
else
puppetversion = '3.4.1'
puppetversion = '~>3.7.0'
end
gem 'rake'
@ -11,3 +11,4 @@ gem 'puppet', puppetversion
gem 'puppet-lint'
gem 'rspec-puppet'
gem 'puppetlabs_spec_helper'
gem 'metadata-json-lint'

View File

@ -1,18 +1,21 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (2.2.8)
diff-lcs (1.2.5)
facter (1.7.6)
facter (2.3.0)
CFPropertyList (~> 2.2.6)
hiera (1.3.4)
json_pure
json_pure (1.8.1)
metaclass (0.0.4)
metadata-json-lint (0.0.2)
mocha (1.1.0)
metaclass (~> 0.0.1)
puppet (3.4.1)
facter (~> 1.6)
puppet (3.7.3)
facter (> 1.6, < 3)
hiera (~> 1.0)
rgen (~> 0.6.5)
json_pure
puppet-lint (1.1.0)
puppet-syntax (1.3.0)
rake
@ -24,7 +27,6 @@ GEM
rspec
rspec-puppet
rake (10.4.2)
rgen (0.6.6)
rspec (3.1.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
@ -44,7 +46,8 @@ PLATFORMS
ruby
DEPENDENCIES
puppet (= 3.4.1)
metadata-json-lint
puppet (~> 3.7.0)
puppet-lint
puppetlabs_spec_helper
rake

View File

@ -1,11 +1,18 @@
# ex: syntax=ruby ts=2 ts=2 si et
require 'puppet-lint/tasks/puppet-lint'
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'puppet-syntax/tasks/puppet-syntax'
exclude_paths = [
'bundle/**/*',
'pkg/**/*',
'vendor/**/*',
'spec/**/*'
]
Rake::Task[:lint].clear
PuppetLint::RakeTask.new :lint do |config|
config.fail_on_warnings
config.ignore_paths = [ 'pkg/**/*', 'spec/**/*', 'gemfiles/vendor/**/*' ]
config.fail_on_warnings = true
config.ignore_paths = exclude_paths
config.disable_checks = [
'80chars',
'class_parameter_defaults',
@ -14,4 +21,20 @@ PuppetLint::RakeTask.new :lint do |config|
]
end
task :default => [ :spec, :lint ]
PuppetSyntax.exclude_paths = exclude_paths
RSpec::Core::RakeTask.new(:acceptance) do |t|
t.pattern = 'spec/acceptance'
end
task :metadata do
sh 'metadata-json-lint metadata.json'
end
desc 'Run syntax, lint, and spec tests.'
task :test => [
:syntax,
:lint,
:spec,
:metadata
]

8
data/common.yaml Normal file
View File

@ -0,0 +1,8 @@
---
bind::params::supported: false
bind::forwarders: ''
bind::dnssec: true
bind::version: ''
bind::updater::keydir: '/etc/nsupdate-keys'

6
data/hiera.yaml Normal file
View File

@ -0,0 +1,6 @@
# ex: si ts=2 sw=2 et
:hierarchy:
- osfamily/%{::osfamily}/%{::operatingsystem}/%{lsbdistrelease}
- osfamily/%{::osfamily}/%{::operatingsystem}
- osfamily/%{::osfamily}
- common

13
data/osfamily/Debian.yaml Normal file
View File

@ -0,0 +1,13 @@
---
bind::params::supported: true
bind::params::bind_user: 'bind'
bind::params::bind_group: 'bind'
bind::params::bind_package: 'bind9'
bind::params::bind_service: 'bind9'
bind::params::nsupdate_package: 'dnsutils'
bind::confdir: '/etc/bind'
bind::cachedir: '/var/cache/bind'
bind::rndc: true
bind::updater::keydir: '/etc/bind/keys'

View File

@ -6,7 +6,7 @@ define bind::acl (
concat::fragment { "bind-acl-${name}":
order => '10',
target => "${bind::params::confdir}/acls.conf",
target => "${bind::confdir}/acls.conf",
content => template('bind/acl.erb'),
}

View File

@ -1,12 +1,12 @@
# ex: syntax=puppet si ts=4 sw=4 et
class bind (
$confdir = $::bind::params::confdir,
$cachedir = $::bind::params::cachedir,
$forwarders = '',
$dnssec = true,
$version = '',
$rndc = $::bind::params::bind_rndc,
$confdir = undef,
$cachedir = undef,
$forwarders = undef,
$dnssec = undef,
$version = undef,
$rndc = undef,
) {
include params

View File

@ -17,9 +17,7 @@ define bind::key (
}
if (defined(Class['bind'])) {
Package[$bind::params::bind_package] ->
File["${keydir}/${name}"] ~>
Service[$bind::params::bind_service]
Package['bind'] -> File["${keydir}/${name}"] ~> Service['bind']
concat::fragment { "bind-key-${name}":
order => '10',

View File

@ -1,7 +1,7 @@
# ex: syntax=puppet si ts=4 sw=4 et
class bind::keydir (
$keydir = "${::bind::params::confdir}/keys",
$keydir,
) {
file { $keydir:
ensure => directory,

View File

@ -1,35 +1,29 @@
# ex: syntax=puppet si ts=4 sw=4 et
class bind::params {
case $::osfamily {
'Debian': {
$bind_package = 'bind9'
$bind_service = 'bind9'
$confdir = '/etc/bind'
$cachedir = '/var/cache/bind'
$bind_user = 'bind'
$bind_group = 'bind'
$bind_rndc = true
$nsupdate_package = 'dnsutils'
$bind_files = [
"${confdir}/bind.keys",
"${confdir}/db.empty",
"${confdir}/db.local",
"${confdir}/db.root",
"${confdir}/db.0",
"${confdir}/db.127",
"${confdir}/db.255",
"${confdir}/named.conf.default-zones",
"${confdir}/rndc.key",
"${confdir}/zones.rfc1918",
]
}
default: {
fail("Operating system is not supported ${::osfamily}")
}
class bind::params (
$supported,
$bind_user,
$bind_group,
$bind_package,
$bind_service,
$nsupdate_package,
) {
unless $supported {
fail('Platform is not supported')
}
if $::osfamily == 'Debian' {
$bind_files = [
"${::bind::confdir}/bind.keys",
"${::bind::confdir}/db.empty",
"${::bind::confdir}/db.local",
"${::bind::confdir}/db.root",
"${::bind::confdir}/db.0",
"${::bind::confdir}/db.127",
"${::bind::confdir}/db.255",
"${::bind::confdir}/named.conf.default-zones",
"${::bind::confdir}/rndc.key",
"${::bind::confdir}/zones.rfc1918",
]
}
}

View File

@ -1,18 +1,15 @@
# ex: syntax=puppet si ts=4 sw=4 et
class bind::updater (
$nsupdate_package = $::bind::params::nsupdate_package,
$keydir = "${::bind::params::confdir}/keys",
$keydir = undef,
) {
include params
package {'nsupdate':
ensure => present,
name => $nsupdate_package,
}
file { $::bind::params::confdir:
ensure => directory,
if $::bind::params::nsupdate_package {
package { 'nsupdate':
ensure => present,
name => $::bind::params::nsupdate_package,
}
}
class { 'bind::keydir':

View File

@ -8,11 +8,11 @@ define bind::view (
$recursion_match_clients = 'any',
$recursion_match_destinations = '',
) {
$confdir = $bind::params::confdir
$confdir = $::bind::confdir
concat::fragment { "bind-view-${name}":
order => '10',
target => "${bind::params::confdir}/views.conf",
target => "${::bind::confdir}/views.conf",
content => template('bind/view.erb'),
}
}

View File

@ -43,7 +43,7 @@ define bind::zone (
owner => $bind::params::bind_user,
group => $bind::params::bind_group,
mode => '0755',
require => Package[$bind::params::bind_package],
require => Package['bind'],
}
file { "${cachedir}/${name}/${_domain}":
@ -85,8 +85,8 @@ define bind::zone (
group => $bind::params::bind_group,
mode => '0644',
content => template('bind/zone.conf.erb'),
notify => Service[$bind::params::bind_service],
require => Package[$bind::params::bind_package],
notify => Service['bind'],
require => Package['bind'],
}
}

View File

@ -20,5 +20,6 @@
],
"dependencies": [
{ "name": "puppetlabs/concat", "version_requirement": ">=1.0.0 <2.0.0" }
{ "name": "ripienaar/module_data", "version_requirement": ">=0.0.4" }
]
}

View File

@ -3,28 +3,22 @@ require 'spec_helper'
describe 'bind' do
let(:facts) { { :concat_basedir => '/wtf' } }
let(:params) { { :confdir => '_CONFDIR_' } }
it {
should contain_package('bind').with({
'ensure' => 'latest',
'name' => 'bind9'
})
}
context 'on Debian-derived systems' do
let(:facts) { super().merge({ :osfamily => 'Debian' }) }
it {
should contain_package('bind').with({
'ensure' => 'latest',
'name' => 'bind9'
})
}
it { should contain_file('_CONFDIR_/named.conf').that_requires('Package[bind]') }
it { should contain_file('_CONFDIR_/named.conf').that_notifies('Service[bind]') }
it { should contain_file('_CONFDIR_/named.conf').that_requires('Package[bind]') }
it { should contain_file('_CONFDIR_/named.conf').that_notifies('Service[bind]') }
it {
should contain_service('bind').with({
'ensure' => 'running',
'name' => 'bind9'
})
}
end
it {
should contain_service('bind').with({
'ensure' => 'running',
'name' => 'bind9'
})
}
end

View File

@ -0,0 +1,6 @@
require 'spec_helper'
describe 'bind::updater' do
it { should compile }
it { should compile.with_all_deps }
end

2
spec/fixtures/hiera/common.yaml vendored Normal file
View File

@ -0,0 +1,2 @@
---
bind::confdir: '_CONFDIR_'

9
spec/fixtures/hiera/hiera.yaml vendored Normal file
View File

@ -0,0 +1,9 @@
---
:hierarchy:
- "tests/%{::test_config}"
- common
:backends:
- yaml
- module_data
:yaml:
:datadir: 'spec/fixtures/hiera'

View File

@ -1 +1,14 @@
require 'puppetlabs_spec_helper/module_spec_helper'
require 'fixtures/modules/module_data/lib/hiera/backend/module_data_backend.rb'
RSpec.configure do |c|
c.default_facts = {
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:lsbdistcodename => 'wheezy',
:architecture => 'amd64',
:kernel => 'Linux',
:test_config => 'default'
}
c.hiera_config = File.join('spec', 'fixtures', 'hiera', 'hiera.yaml')
end