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:
parent
f7740f2a05
commit
7a74314a1e
@ -1,9 +1,9 @@
|
|||||||
---
|
|
||||||
fixtures:
|
fixtures:
|
||||||
forge_modules:
|
forge_modules:
|
||||||
concat:
|
concat:
|
||||||
repo: "puppetlabs/concat"
|
repo: "puppetlabs/concat"
|
||||||
ref: "1.0.0"
|
ref: "1.0.0"
|
||||||
stdlib: "puppetlabs/stdlib"
|
stdlib: "puppetlabs/stdlib"
|
||||||
|
module_data: "ripienaar/module_data"
|
||||||
symlinks:
|
symlinks:
|
||||||
bind: "#{source_dir}"
|
bind: "#{source_dir}"
|
||||||
|
|||||||
3
Gemfile
3
Gemfile
@ -3,7 +3,7 @@ source 'https://rubygems.org'
|
|||||||
if ENV.include?('PUPPET_VERSION')
|
if ENV.include?('PUPPET_VERSION')
|
||||||
puppetversion = "~>#{ENV['PUPPET_VERSION']}"
|
puppetversion = "~>#{ENV['PUPPET_VERSION']}"
|
||||||
else
|
else
|
||||||
puppetversion = '3.4.1'
|
puppetversion = '~>3.7.0'
|
||||||
end
|
end
|
||||||
|
|
||||||
gem 'rake'
|
gem 'rake'
|
||||||
@ -11,3 +11,4 @@ gem 'puppet', puppetversion
|
|||||||
gem 'puppet-lint'
|
gem 'puppet-lint'
|
||||||
gem 'rspec-puppet'
|
gem 'rspec-puppet'
|
||||||
gem 'puppetlabs_spec_helper'
|
gem 'puppetlabs_spec_helper'
|
||||||
|
gem 'metadata-json-lint'
|
||||||
|
|||||||
15
Gemfile.lock
15
Gemfile.lock
@ -1,18 +1,21 @@
|
|||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
|
CFPropertyList (2.2.8)
|
||||||
diff-lcs (1.2.5)
|
diff-lcs (1.2.5)
|
||||||
facter (1.7.6)
|
facter (2.3.0)
|
||||||
|
CFPropertyList (~> 2.2.6)
|
||||||
hiera (1.3.4)
|
hiera (1.3.4)
|
||||||
json_pure
|
json_pure
|
||||||
json_pure (1.8.1)
|
json_pure (1.8.1)
|
||||||
metaclass (0.0.4)
|
metaclass (0.0.4)
|
||||||
|
metadata-json-lint (0.0.2)
|
||||||
mocha (1.1.0)
|
mocha (1.1.0)
|
||||||
metaclass (~> 0.0.1)
|
metaclass (~> 0.0.1)
|
||||||
puppet (3.4.1)
|
puppet (3.7.3)
|
||||||
facter (~> 1.6)
|
facter (> 1.6, < 3)
|
||||||
hiera (~> 1.0)
|
hiera (~> 1.0)
|
||||||
rgen (~> 0.6.5)
|
json_pure
|
||||||
puppet-lint (1.1.0)
|
puppet-lint (1.1.0)
|
||||||
puppet-syntax (1.3.0)
|
puppet-syntax (1.3.0)
|
||||||
rake
|
rake
|
||||||
@ -24,7 +27,6 @@ GEM
|
|||||||
rspec
|
rspec
|
||||||
rspec-puppet
|
rspec-puppet
|
||||||
rake (10.4.2)
|
rake (10.4.2)
|
||||||
rgen (0.6.6)
|
|
||||||
rspec (3.1.0)
|
rspec (3.1.0)
|
||||||
rspec-core (~> 3.1.0)
|
rspec-core (~> 3.1.0)
|
||||||
rspec-expectations (~> 3.1.0)
|
rspec-expectations (~> 3.1.0)
|
||||||
@ -44,7 +46,8 @@ PLATFORMS
|
|||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
puppet (= 3.4.1)
|
metadata-json-lint
|
||||||
|
puppet (~> 3.7.0)
|
||||||
puppet-lint
|
puppet-lint
|
||||||
puppetlabs_spec_helper
|
puppetlabs_spec_helper
|
||||||
rake
|
rake
|
||||||
|
|||||||
33
Rakefile
33
Rakefile
@ -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 '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
|
Rake::Task[:lint].clear
|
||||||
PuppetLint::RakeTask.new :lint do |config|
|
PuppetLint::RakeTask.new :lint do |config|
|
||||||
config.fail_on_warnings
|
config.fail_on_warnings = true
|
||||||
config.ignore_paths = [ 'pkg/**/*', 'spec/**/*', 'gemfiles/vendor/**/*' ]
|
config.ignore_paths = exclude_paths
|
||||||
config.disable_checks = [
|
config.disable_checks = [
|
||||||
'80chars',
|
'80chars',
|
||||||
'class_parameter_defaults',
|
'class_parameter_defaults',
|
||||||
@ -14,4 +21,20 @@ PuppetLint::RakeTask.new :lint do |config|
|
|||||||
]
|
]
|
||||||
end
|
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
8
data/common.yaml
Normal 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
6
data/hiera.yaml
Normal 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
13
data/osfamily/Debian.yaml
Normal 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'
|
||||||
@ -6,7 +6,7 @@ define bind::acl (
|
|||||||
|
|
||||||
concat::fragment { "bind-acl-${name}":
|
concat::fragment { "bind-acl-${name}":
|
||||||
order => '10',
|
order => '10',
|
||||||
target => "${bind::params::confdir}/acls.conf",
|
target => "${bind::confdir}/acls.conf",
|
||||||
content => template('bind/acl.erb'),
|
content => template('bind/acl.erb'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
# ex: syntax=puppet si ts=4 sw=4 et
|
# ex: syntax=puppet si ts=4 sw=4 et
|
||||||
|
|
||||||
class bind (
|
class bind (
|
||||||
$confdir = $::bind::params::confdir,
|
$confdir = undef,
|
||||||
$cachedir = $::bind::params::cachedir,
|
$cachedir = undef,
|
||||||
$forwarders = '',
|
$forwarders = undef,
|
||||||
$dnssec = true,
|
$dnssec = undef,
|
||||||
$version = '',
|
$version = undef,
|
||||||
$rndc = $::bind::params::bind_rndc,
|
$rndc = undef,
|
||||||
) {
|
) {
|
||||||
include params
|
include params
|
||||||
|
|
||||||
|
|||||||
@ -17,9 +17,7 @@ define bind::key (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (defined(Class['bind'])) {
|
if (defined(Class['bind'])) {
|
||||||
Package[$bind::params::bind_package] ->
|
Package['bind'] -> File["${keydir}/${name}"] ~> Service['bind']
|
||||||
File["${keydir}/${name}"] ~>
|
|
||||||
Service[$bind::params::bind_service]
|
|
||||||
|
|
||||||
concat::fragment { "bind-key-${name}":
|
concat::fragment { "bind-key-${name}":
|
||||||
order => '10',
|
order => '10',
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
# ex: syntax=puppet si ts=4 sw=4 et
|
# ex: syntax=puppet si ts=4 sw=4 et
|
||||||
|
|
||||||
class bind::keydir (
|
class bind::keydir (
|
||||||
$keydir = "${::bind::params::confdir}/keys",
|
$keydir,
|
||||||
) {
|
) {
|
||||||
file { $keydir:
|
file { $keydir:
|
||||||
ensure => directory,
|
ensure => directory,
|
||||||
|
|||||||
@ -1,35 +1,29 @@
|
|||||||
# ex: syntax=puppet si ts=4 sw=4 et
|
# ex: syntax=puppet si ts=4 sw=4 et
|
||||||
|
|
||||||
class bind::params {
|
class bind::params (
|
||||||
|
$supported,
|
||||||
case $::osfamily {
|
$bind_user,
|
||||||
'Debian': {
|
$bind_group,
|
||||||
$bind_package = 'bind9'
|
$bind_package,
|
||||||
$bind_service = 'bind9'
|
$bind_service,
|
||||||
$confdir = '/etc/bind'
|
$nsupdate_package,
|
||||||
$cachedir = '/var/cache/bind'
|
) {
|
||||||
$bind_user = 'bind'
|
unless $supported {
|
||||||
$bind_group = 'bind'
|
fail('Platform is not supported')
|
||||||
$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}")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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",
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,15 @@
|
|||||||
# ex: syntax=puppet si ts=4 sw=4 et
|
# ex: syntax=puppet si ts=4 sw=4 et
|
||||||
|
|
||||||
class bind::updater (
|
class bind::updater (
|
||||||
$nsupdate_package = $::bind::params::nsupdate_package,
|
$keydir = undef,
|
||||||
$keydir = "${::bind::params::confdir}/keys",
|
|
||||||
) {
|
) {
|
||||||
include params
|
include params
|
||||||
|
|
||||||
package {'nsupdate':
|
if $::bind::params::nsupdate_package {
|
||||||
ensure => present,
|
package { 'nsupdate':
|
||||||
name => $nsupdate_package,
|
ensure => present,
|
||||||
}
|
name => $::bind::params::nsupdate_package,
|
||||||
|
}
|
||||||
file { $::bind::params::confdir:
|
|
||||||
ensure => directory,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class { 'bind::keydir':
|
class { 'bind::keydir':
|
||||||
|
|||||||
@ -8,11 +8,11 @@ define bind::view (
|
|||||||
$recursion_match_clients = 'any',
|
$recursion_match_clients = 'any',
|
||||||
$recursion_match_destinations = '',
|
$recursion_match_destinations = '',
|
||||||
) {
|
) {
|
||||||
$confdir = $bind::params::confdir
|
$confdir = $::bind::confdir
|
||||||
|
|
||||||
concat::fragment { "bind-view-${name}":
|
concat::fragment { "bind-view-${name}":
|
||||||
order => '10',
|
order => '10',
|
||||||
target => "${bind::params::confdir}/views.conf",
|
target => "${::bind::confdir}/views.conf",
|
||||||
content => template('bind/view.erb'),
|
content => template('bind/view.erb'),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,7 +43,7 @@ define bind::zone (
|
|||||||
owner => $bind::params::bind_user,
|
owner => $bind::params::bind_user,
|
||||||
group => $bind::params::bind_group,
|
group => $bind::params::bind_group,
|
||||||
mode => '0755',
|
mode => '0755',
|
||||||
require => Package[$bind::params::bind_package],
|
require => Package['bind'],
|
||||||
}
|
}
|
||||||
|
|
||||||
file { "${cachedir}/${name}/${_domain}":
|
file { "${cachedir}/${name}/${_domain}":
|
||||||
@ -85,8 +85,8 @@ define bind::zone (
|
|||||||
group => $bind::params::bind_group,
|
group => $bind::params::bind_group,
|
||||||
mode => '0644',
|
mode => '0644',
|
||||||
content => template('bind/zone.conf.erb'),
|
content => template('bind/zone.conf.erb'),
|
||||||
notify => Service[$bind::params::bind_service],
|
notify => Service['bind'],
|
||||||
require => Package[$bind::params::bind_package],
|
require => Package['bind'],
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,5 +20,6 @@
|
|||||||
],
|
],
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
{ "name": "puppetlabs/concat", "version_requirement": ">=1.0.0 <2.0.0" }
|
{ "name": "puppetlabs/concat", "version_requirement": ">=1.0.0 <2.0.0" }
|
||||||
|
{ "name": "ripienaar/module_data", "version_requirement": ">=0.0.4" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,28 +3,22 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe 'bind' do
|
describe 'bind' do
|
||||||
let(:facts) { { :concat_basedir => '/wtf' } }
|
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
|
it { should contain_file('_CONFDIR_/named.conf').that_requires('Package[bind]') }
|
||||||
let(:facts) { super().merge({ :osfamily => 'Debian' }) }
|
it { should contain_file('_CONFDIR_/named.conf').that_notifies('Service[bind]') }
|
||||||
|
|
||||||
it {
|
it {
|
||||||
should contain_package('bind').with({
|
should contain_service('bind').with({
|
||||||
'ensure' => 'latest',
|
'ensure' => 'running',
|
||||||
'name' => 'bind9'
|
'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_service('bind').with({
|
|
||||||
'ensure' => 'running',
|
|
||||||
'name' => 'bind9'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
6
spec/classes/updater_spec.rb
Normal file
6
spec/classes/updater_spec.rb
Normal 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
2
spec/fixtures/hiera/common.yaml
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
bind::confdir: '_CONFDIR_'
|
||||||
9
spec/fixtures/hiera/hiera.yaml
vendored
Normal file
9
spec/fixtures/hiera/hiera.yaml
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
:hierarchy:
|
||||||
|
- "tests/%{::test_config}"
|
||||||
|
- common
|
||||||
|
:backends:
|
||||||
|
- yaml
|
||||||
|
- module_data
|
||||||
|
:yaml:
|
||||||
|
:datadir: 'spec/fixtures/hiera'
|
||||||
@ -1 +1,14 @@
|
|||||||
require 'puppetlabs_spec_helper/module_spec_helper'
|
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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user