Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
fixtures:
repositories:
'inifile': "git://github.com/cprice-puppet/puppetlabs-inifile.git"
symlinks:
"puppetdb": "#{source_dir}"
repositories:
'inifile' : 'git://github.com/cprice-puppet/puppetlabs-inifile.git'
'stdlib' : 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
'postgresql': 'git://github.com/puppetlabs/puppet-postgresql.git'
'firewall' : 'git://github.com/puppetlabs/puppetlabs-firewall.git'
'apt' : 'git://github.com/puppetlabs/puppetlabs-apt.git'
'concat' : 'git://github.com/ripienaar/puppet-concat.git'
symlinks:
'puppetdb': '#{source_dir}'
6 changes: 6 additions & 0 deletions .gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source :rubygems

puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7']
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'puppet-lint', '>= 0.3.2'
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
pkg/
metadata.json
*.swp
.DS_Store
coverage/
spec/fixtures/modules/*
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: ruby
before_script: "gem install --no-ri --no-rdoc bundler"
after_script:
script: "rake spec"
notifications:
email: false
rvm:
- 1.9.3
- 1.8.7
env:
- PUPPET_VERSION=2.6.9
- PUPPET_VERSION=2.7.13
- PUPPET_VERSION=3.1.1
gemfile: .gemfile
matrix:
allow_failures:
- env: PUPPET_VERSION=2.6.9
5 changes: 5 additions & 0 deletions Modulefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ project_page 'https://github.com/puppetlabs-puppet/puppetlabs-puppetdb'
dependency 'cprice404/inifile', '>= 0.9.0'
dependency 'puppetlabs/postgresql', '2.x'
dependency 'puppetlabs/firewall', '>= 0.0.4'
dependency 'puppetlabs/stdlib', '>= 3.2.x'

# needed by puppetlabs/postgresql and included here for spec tests
dependency 'puppetlabs/apt', '>=1.x'
dependency 'ripienaar/concat', '>= 0.2.x'
34 changes: 32 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
# '0.0.0.0' = all)
# ['listen_port'] - The port on which the puppetdb web server should
# accept HTTP requests (defaults to 8080).
# ['open_listen_port'] - If true, open the http listen port on the firewall.
# ['open_listen_port'] - If true, open the http listen port on the firewall.
# (defaults to false).
# ['ssl_listen_address'] - The address that the web server should bind to
# for HTTPS requests. (defaults to `$::clientcert`.)
# Set to '0.0.0.0' to listen on all addresses.
# ['ssl_listen_port'] - The port on which the puppetdb web server should
# accept HTTPS requests (defaults to 8081).
# ['open_ssl_listen_port'] - If true, open the ssl listen port on the firewall.
# ['open_ssl_listen_port'] - If true, open the ssl listen port on the firewall.
# (defaults to true).
# ['database'] - Which database backend to use; legal values are
# `postgres` (default) or `embedded`. (The `embedded`
Expand Down Expand Up @@ -106,6 +106,36 @@
$confdir = $puppetdb::params::confdir
) inherits puppetdb::params {

# Apply necessary suffix if zero is specified.
if $node_ttl == '0' {
$node_ttl_real = '0s'
} else {
$node_ttl_real = downcase($node_ttl)
}

# Validate node_ttl
validate_re ($node_ttl_real, ['^(\d)+[s,m,d]$'], "node_ttl is <${node_ttl}> which does not match the regex validation")

# Apply necessary suffix if zero is specified.
if $node_purge_ttl == '0' {
$node_purge_ttl_real = '0s'
} else {
$node_purge_ttl_real = downcase($node_purge_ttl)
}

# Validate node_purge_ttl
validate_re ($node_purge_ttl_real, ['^(\d)+[s,m,d]$'], "node_purge_ttl is <${node_purge_ttl}> which does not match the regex validation")

# Apply necessary suffix if zero is specified.
if $report_ttl == '0' {
$report_ttl_real = '0s'
} else {
$report_ttl_real = downcase($report_ttl)
}

# Validate report_ttl
validate_re ($report_ttl_real, ['^(\d)+[s,m,d]$'], "report_ttl is <${report_ttl}> which does not match the regex validation")

if ($manage_redhat_firewall != undef) {
notify {'Deprecation notice: `$manage_redhat_firewall` has been deprecated in `puppetdb` class and will be removed in a future versions. Use $open_ssl_listen_port and $open_postgres_port instead.':}
}
Expand Down
34 changes: 32 additions & 2 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
# Set to '0.0.0.0' to listen on all addresses.
# ['listen_port'] - The port on which the puppetdb web server should
# accept HTTP requests (defaults to 8080).
# ['open_listen_port'] - If true, open the http listen port on the firewall.
# ['open_listen_port'] - If true, open the http listen port on the firewall.
# (defaults to false).
# ['ssl_listen_address'] - The address that the web server should bind to
# for HTTPS requests. (defaults to `$::clientcert`.)
# Set to '0.0.0.0' to listen on all addresses.
# ['ssl_listen_port'] - The port on which the puppetdb web server should
# accept HTTPS requests (defaults to 8081).
# ['open_ssl_listen_port'] - If true, open the ssl listen port on the firewall.
# ['open_ssl_listen_port'] - If true, open the ssl listen port on the firewall.
# (defaults to true).
# ['database'] - Which database backend to use; legal values are
# `postgres` (default) or `embedded`. (The `embedded`
Expand Down Expand Up @@ -115,6 +115,36 @@
$confdir = $puppetdb::params::confdir,
) inherits puppetdb::params {

# Apply necessary suffix if zero is specified.
if $node_ttl == '0' {
$node_ttl_real = '0s'
} else {
$node_ttl_real = downcase($node_ttl)
}

# Validate node_ttl
validate_re ($node_ttl_real, ['^(\d)+[s,m,d]$'], "node_ttl is <${node_ttl}> which does not match the regex validation")

# Apply necessary suffix if zero is specified.
if $node_purge_ttl == '0' {
$node_purge_ttl_real = '0s'
} else {
$node_purge_ttl_real = downcase($node_purge_ttl)
}

# Validate node_purge_ttl
validate_re ($node_purge_ttl_real, ['^(\d)+[s,m,d]$'], "node_purge_ttl is <${node_purge_ttl}> which does not match the regex validation")

# Apply necessary suffix if zero is specified.
if $report_ttl == '0' {
$report_ttl_real = '0s'
} else {
$report_ttl_real = downcase($report_ttl)
}

# Validate report_ttl
validate_re ($report_ttl_real, ['^(\d)+[s,m,d]$'], "report_ttl is <${report_ttl}> which does not match the regex validation")

package { $puppetdb_package:
ensure => $puppetdb_version,
notify => Service[$puppetdb_service],
Expand Down
2 changes: 1 addition & 1 deletion manifests/server/validate_db.pp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

# We don't need any validation for the embedded database, presumably.
if ($database == 'postgres') {
::postgresql::validate_db_connection { 'validate puppetdb postgres connection':
postgresql::validate_db_connection { 'validate puppetdb postgres connection':
database_host => $database_host,
database_port => $database_port,
database_username => $database_username,
Expand Down
48 changes: 48 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require 'spec_helper'
describe 'puppetdb' do

ttl_args = ['node_ttl','node_purge_ttl','report_ttl']

context 'on a supported platform' do
let(:facts) { { :osfamily => 'RedHat',
:postgres_default_version => '9.1',
:concat_basedir => '/var/lib/puppet/concat',
} }

describe 'when using default values for puppetdb class' do
it {
should contain_class('puppetdb')
}
end

ttl_args.each do |ttl_arg|

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't really test what you want to test, I'm removing it for now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kbarber

Lines 4-16 should be testing that if you just 'include puppetdb' and use all the defaults, that it should contain the puppetdb class, ie: not fail.

Is that the code to which you are referring?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now - I mean the block referenced by line 18.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, that part need the :params hash set to use '0' for the ttl_args

The next part on line 23 should have the :params hash to set something like 1S (capital) which should still work since the code uses downcase()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep - you'll need a new PR for that though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the insight and help.

describe "when using 0 for #{ttl_arg} puppetdb class" do
it {
should contain_class('puppetdb')
}
describe "when using a capitalized time signifier for #{ttl_arg} for puppetdb class" do
it {
should contain_class('puppetdb')
}
end
end
end
end

context 'with invalid arguments on a supported platform' do
let(:facts) { { :osfamily => 'RedHat',
:postgres_default_version => '9.1',
:concat_basedir => '/var/lib/puppet/concat',
} }
ttl_args.each do |ttl_arg|
let(:params) { { ttl_arg => 'invalid_value' } }
describe "when using a value that does not match the validation regex for #{ttl_arg} puppetdb class" do
it {
expect {
should contain_class('puppetdb')
}.to raise_error(Puppet::Error)
}
end
end
end
end
Empty file added spec/fixtures/manifests/site.pp
Empty file.
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require 'rubygems'
require 'puppetlabs_spec_helper/module_spec_helper'