Skip to content

Commit

Permalink
Merge pull request #48 from danzilio/lint-and-tests-on-dns-key
Browse files Browse the repository at this point in the history
Reformatted dns::key and wrote tests for it
  • Loading branch information
danzilio committed Apr 22, 2014
2 parents 6bf0dbf + 4018348 commit 175a920
Show file tree
Hide file tree
Showing 13 changed files with 141 additions and 183 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
pkg/
vendor/
.bundle
.*.sw?
pkg
spec/fixtures
Gemfile.lock
.rspec_system
.vagrant
42 changes: 24 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,30 @@ rvm:
- 1.8.7
- 1.9.3
- 2.0.0
script: bundle exec rake spec

- 2.1.0
script: bundle exec rake test
env:
matrix:
- PUPPET_GEM_VERSION="~> 2.7.0"
- PUPPET_GEM_VERSION="~> 3.0.0"
- PUPPET_GEM_VERSION="~> 3.1.0"
- PUPPET_GEM_VERSION="~> 3.2.0"

- PUPPET_VERSION="~> 2.7.0"
- PUPPET_VERSION="~> 3.1.0"
- PUPPET_VERSION="~> 3.2.0"
- PUPPET_VERSION="~> 3.3.0"
- PUPPET_VERSION="~> 3.4.0"
- PUPPET_VERSION="~> 3.5.0"
matrix:
exclude:
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 2.7.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 2.7.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.0.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.1.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 3.2.0"
- rvm: 1.9.3
env: PUPPET_VERSION="~> 2.7.0"
- rvm: 2.0.0
env: PUPPET_VERSION="~> 2.7.0"
- rvm: 2.0.0
env: PUPPET_VERSION="~> 3.1.0"
- rvm: 2.1.0
env: PUPPET_VERSION="~> 2.7.0"
- rvm: 2.1.0
env: PUPPET_VERSION="~> 3.1.0"
- rvm: 2.1.0
env: PUPPET_VERSION="~> 3.2.0"
- rvm: 2.1.0
env: PUPPET_VERSION="~> 3.3.0"
- rvm: 2.1.0
env: PUPPET_VERSION="~> 3.4.0"
20 changes: 9 additions & 11 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
source 'https://rubygems.org'
source "https://rubygems.org"

gem 'rake'
gem 'puppet-lint'
gem 'rspec-puppet'
gem 'rspec-system-puppet'
gem 'puppetlabs_spec_helper'
gem 'travis'
gem 'travis-lint'
gem 'puppet-syntax'
gem 'puppet', ENV['PUPPET_VERSION'] || '~> 3.2.0'
gem 'vagrant-wrapper'
group :test do
gem "rake"
gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.4.0'
gem "puppet-lint"
gem "rspec-puppet", '~> 1.0.0'
gem "puppet-syntax"
gem "puppetlabs_spec_helper"
end
107 changes: 12 additions & 95 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,54 +1,15 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.3.5)
backports (3.3.3)
builder (3.2.2)
coderay (1.0.9)
diff-lcs (1.2.4)
ethon (0.6.0)
ffi (>= 1.3.0)
mime-types (~> 1.18)
facter (1.7.2)
faraday (0.8.8)
multipart-post (~> 1.2.0)
faraday_middleware (0.9.0)
faraday (>= 0.7.4, < 0.9)
ffi (1.9.0)
gh (0.11.3)
addressable
backports
faraday (~> 0.8)
multi_json (~> 1.0)
net-http-persistent (>= 2.7)
net-http-pipeline
hashr (0.0.22)
hiera (1.2.1)
diff-lcs (1.2.5)
facter (1.7.5)
hiera (1.3.2)
json_pure
highline (1.6.19)
json_pure (1.8.0)
kwalify (0.7.2)
launchy (2.3.0)
addressable (~> 2.3)
json_pure (1.8.1)
metaclass (0.0.1)
method_source (0.8.2)
mime-types (1.24)
mocha (0.14.0)
metaclass (~> 0.0.1)
multi_json (1.7.9)
multipart-post (1.2.0)
net-http-persistent (2.9)
net-http-pipeline (1.0.1)
net-scp (1.1.2)
net-ssh (>= 2.6.5)
net-ssh (2.6.8)
netrc (0.7.7)
nokogiri (1.5.10)
pry (0.9.12.2)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.4)
puppet (3.2.4)
puppet (3.4.3)
facter (~> 1.6)
hiera (~> 1.0)
rgen (~> 0.6.5)
Expand All @@ -61,70 +22,26 @@ GEM
rake
rspec (>= 2.9.0)
rspec-puppet (>= 0.1.1)
pusher-client (0.3.1)
ruby-hmac (~> 0.4.0)
websocket (~> 1.0.0)
rake (10.1.0)
rbvmomi (1.6.0)
builder
nokogiri (>= 1.4.1)
trollop
rgen (0.6.5)
rgen (0.6.6)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.5)
rspec-expectations (2.14.2)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.3)
rspec-puppet (0.1.6)
rspec-mocks (2.14.6)
rspec-puppet (1.0.1)
rspec
rspec-system (2.2.0)
kwalify (~> 0.7.2)
net-scp (~> 1.1)
net-ssh (~> 2.6)
nokogiri (~> 1.5.9)
rbvmomi (~> 1.6)
rspec (~> 2.13)
systemu (~> 2.5)
rspec-system-puppet (2.1.0)
rspec-system (~> 2.0)
ruby-hmac (0.4.0)
slop (3.4.6)
systemu (2.5.2)
travis (1.5.1)
backports
faraday (~> 0.8.7)
faraday_middleware (~> 0.9)
gh
highline (~> 1.6)
launchy (~> 2.1)
netrc (~> 0.7)
pry (~> 0.9)
pusher-client (~> 0.3, >= 0.3.1)
typhoeus (~> 0.5)
websocket-native (~> 1.0)
travis-lint (1.7.0)
hashr (~> 0.0.22)
trollop (2.0)
typhoeus (0.6.4)
ethon (~> 0.6.0)
vagrant-wrapper (1.2.1.1)
websocket (1.0.7)
websocket-native (1.0.0)

PLATFORMS
ruby

DEPENDENCIES
puppet (~> 3.2.0)
puppet (~> 3.4.0)
puppet-lint
puppet-syntax
puppetlabs_spec_helper
rake
rspec-puppet
rspec-system-puppet
travis
travis-lint
vagrant-wrapper
rspec-puppet (~> 1.0.0)
27 changes: 19 additions & 8 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'puppet-syntax/tasks/puppet-syntax'
require 'rspec-system/rake_task'

# These two gems aren't always present, for instance
# on Travis with --without development
begin
require 'puppet_blacksmith/rake_tasks'
rescue LoadError
end

PuppetLint.configuration.send("disable_80chars")
PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}"
PuppetLint.configuration.fail_on_warnings = true

# Forsake support for Puppet 2.6.2 for the benefit of cleaner code.
# http://puppet-lint.com/checks/class_parameter_defaults/
Expand All @@ -14,16 +20,21 @@ PuppetLint.configuration.send('disable_class_parameter_defaults')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')

exclude_paths = [
"pkg/**/*",
"vendor/**/*",
"spec/**/*",
"pkg/**/*",
"vendor/**/*",
"spec/**/*",
]
PuppetLint.configuration.ignore_paths = exclude_paths
PuppetSyntax.exclude_paths = exclude_paths

desc "Run acceptance tests"
RSpec::Core::RakeTask.new(:acceptance) do |t|
t.pattern = 'spec/acceptance'
end

desc "Run syntax, lint, and spec tests."
task :test => [
:syntax,
:lint,
:spec,
:syntax,
:lint,
:spec,
]
52 changes: 26 additions & 26 deletions manifests/key.pp
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
define dns::key {

file {"/tmp/${name}-secret.sh":
ensure => file,
file { "/tmp/${name}-secret.sh":
ensure => file,
mode => '0777',
content => template('dns/secret.erb'),
notify => Exec["dnssec-keygen-${name}"],
notify => Exec["dnssec-keygen-${name}"],
}


exec {"dnssec-keygen-${name}":
exec { "dnssec-keygen-${name}":
command => "/usr/sbin/dnssec-keygen -a HMAC-MD5 -r /dev/urandom -b 128 -n USER ${name}",
cwd => '/etc/bind/bind.keys.d',
require => [Package['dnssec-tools','bind9'],File['/etc/bind/bind.keys.d']],
require => [
Package['dnssec-tools','bind9'],
File['/etc/bind/bind.keys.d']
],
refreshonly => true,
notify => Exec["get-secret-from-${name}"],
notify => Exec["get-secret-from-${name}"],
}

exec {"get-secret-from-${name}":
command => "/tmp/${name}-secret.sh",
exec { "get-secret-from-${name}":
command => "/tmp/${name}-secret.sh",
cwd => '/etc/bind/bind.keys.d',
creates => "/etc/bind/bind.keys.d/${name}.secret",
require => [Exec["dnssec-keygen-${name}"],File['/etc/bind/bind.keys.d',"/tmp/${name}-secret.sh"]],
require => [
Exec["dnssec-keygen-${name}"],
File['/etc/bind/bind.keys.d',"/tmp/${name}-secret.sh"]],
refreshonly => true,
}

file { "/etc/bind/bind.keys.d/${name}.secret":
require => Exec["get-secret-from-${name}"],
}
Expand All @@ -36,32 +40,28 @@
notify => Class['dns::server::service']
}

concat::fragment { "${name}.key-header":
Concat::Fragment {
ensure => present,
target => "/etc/bind/bind.keys.d/${name}.key",
require => [
Exec["get-secret-from-${name}"],
File["/etc/bind/bind.keys.d/${name}.secret"]
],
}

concat::fragment { "${name}.key-header":
order => 1,
content => template('dns/key.erb'),
require => [Exec["get-secret-from-${name}"], File["/etc/bind/bind.keys.d/${name}.secret"]],
}

concat::fragment { "${name}.key-secret":
ensure => present,
target => "/etc/bind/bind.keys.d/${name}.key",
order => 2,
# content => template("/etc/bind/bind.keys.d/${name}.secret"),
source => "/etc/bind/bind.keys.d/${name}.secret",
require => [ Exec[ "get-secret-from-${name}" ], File["/etc/bind/bind.keys.d/${name}.secret"]],
}

concat::fragment { "${name}.key-footer":
ensure => present,
target => "/etc/bind/bind.keys.d/${name}.key",
order => 3,
content => '}:',
require => [Exec["get-secret-from-${name}"], File["/etc/bind/bind.keys.d/${name}.secret"]],
content => '}:',
}
#concat::fragment{"named.conf.local.${name}.key":
# ensure => present,
# target => '/etc/bind/named.conf.local',
# content => templates
#}

}
10 changes: 1 addition & 9 deletions manifests/member.pp
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
class dns::member {
@@member { $::fqdn:
domain => $::domain,
hostname => $::hostname,
ipaddress => $::ipaddress
}
}

define member ($domain, $hostname, $ipaddress) {
define dns::member ($domain, $hostname, $ipaddress) {
dns::record::a { $hostname:
zone => $domain,
data => $ipaddress,
Expand Down
Loading

0 comments on commit 175a920

Please sign in to comment.