Merge branch 'master' into feature/master/option_to_disable_ssl

This commit is contained in:
Christian Berg 2013-04-09 23:38:40 +02:00
commit 0a9d936670
13 changed files with 241 additions and 33 deletions

View file

@ -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}'

5
.gitignore vendored
View file

@ -1,2 +1,7 @@
pkg/
metadata.json
*.swp
.DS_Store
coverage/
spec/fixtures/modules/*
Gemfile.lock

40
.travis.yml Normal file
View file

@ -0,0 +1,40 @@
language: ruby
script: "bundle exec rake spec SPEC_OPTS='--format documentation'"
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
- ruby-head
env:
- PUPPET_GEM_VERSION="~> 2.6"
- PUPPET_GEM_VERSION="~> 2.7"
- PUPPET_GEM_VERSION="~> 3.0"
- PUPPET_GEM_VERSION="~> 3.1"
- PUPPET_GEM_VERSION="> 3.1"
matrix:
allow_failures:
- rvm: 2.0.0
- rvm: ruby-head
exclude:
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.1"
- rvm: ruby-head
env: PUPPET_GEM_VERSION="~> 3.1"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: ruby-head
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 2.7"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 2.7"
- rvm: ruby-head
env: PUPPET_GEM_VERSION="~> 2.7"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 2.6"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 2.6"
- rvm: ruby-head
env: PUPPET_GEM_VERSION="~> 2.6"
notifications:
email: false

View file

@ -4,6 +4,20 @@ Release notes for the puppetlabs-puppetdb module.
------------------------------------------
#### 1.2.1 - 2013/04/08
This is a minor bugfix that solves the PuppetDB startup exception:
java.lang.AssertionError: Assert failed: (string? s)
This was due to the default `node-ttl` and `node-purge-ttl` settings not having a time suffix by default. These settings required 's', 'm', 'd' etc. to be suffixed, even if they are zero.
#### Changes
* (Ken Barber) Add 's' suffix to period settings to avoid exceptions in PuppetDB
------------------------------------------
#### 1.2.0 - 2013/04/05
This release is primarily about providing full configuration file support in the module for PuppetDB 1.2.0. (The alignment of version is a coincidence I assure you :-).

13
Gemfile Normal file
View file

@ -0,0 +1,13 @@
source 'https://rubygems.org'
group :development, :test do
gem 'rake'
gem 'puppetlabs_spec_helper', :require => false
gem 'puppet-lint', '~> 0.3.2'
end
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end

View file

@ -1,12 +1,13 @@
name 'puppetlabs-puppetdb'
version '1.2.0'
source 'git://github.com/puppetlabs-puppet/puppetlabs-puppetdb.git'
version '1.2.1'
source 'git://github.com/puppetlabs/puppetlabs-puppetdb.git'
author 'Puppet Labs'
description 'PuppetDB resource types'
summary 'PuppetDB resource types'
license 'ASL 2.0'
project_page 'https://github.com/puppetlabs-puppet/puppetlabs-puppetdb'
project_page 'https://github.com/puppetlabs/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'

View file

@ -20,7 +20,7 @@
# '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`.)
@ -109,28 +109,61 @@ class puppetdb(
$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.':}
}
class { 'puppetdb::server':
listen_address => $listen_address,
listen_port => $listen_port,
open_listen_port => $open_listen_port,
ssl_listen_address => $ssl_listen_address,
ssl_listen_port => $ssl_listen_port,
disable_ssl => $disable_ssl,
open_ssl_listen_port => $open_ssl_listen_port,
database => $database,
database_port => $database_port,
database_username => $database_username,
database_password => $database_password,
database_name => $database_name,
puppetdb_package => $puppetdb_package,
puppetdb_version => $puppetdb_version,
puppetdb_service => $puppetdb_service,
manage_redhat_firewall => $manage_redhat_firewall,
confdir => $confdir
listen_address => $listen_address,
listen_port => $listen_port,
open_listen_port => $open_listen_port,
ssl_listen_address => $ssl_listen_address,
ssl_listen_port => $ssl_listen_port,
disable_ssl => $disable_ssl,
open_ssl_listen_port => $open_ssl_listen_port,
database => $database,
database_port => $database_port,
database_username => $database_username,
database_password => $database_password,
database_name => $database_name,
node_ttl => $node_ttl,
node_purge_ttl => $node_purge_ttl,
report_ttl => $report_ttl,
puppetdb_package => $puppetdb_package,
puppetdb_version => $puppetdb_version,
puppetdb_service => $puppetdb_service,
manage_redhat_firewall => $manage_redhat_firewall,
confdir => $confdir
}
if ($database == 'postgres') {

View file

@ -43,8 +43,8 @@ class puppetdb::params {
$database_password = 'puppetdb'
# These settings manage the various auto-deactivation and auto-purge settings
$node_ttl = '0'
$node_purge_ttl = '0'
$node_ttl = '0s'
$node_purge_ttl = '0s'
$report_ttl = '7d'
$puppetdb_version = 'present'

View file

@ -27,7 +27,7 @@
# 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`.)
@ -118,6 +118,36 @@ class puppetdb::server(
$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],
@ -138,6 +168,9 @@ class puppetdb::server(
database_username => $database_username,
database_password => $database_password,
database_name => $database_name,
node_ttl => $node_ttl,
node_purge_ttl => $node_purge_ttl,
report_ttl => $report_ttl,
confdir => $confdir,
notify => Service[$puppetdb_service],
}

View file

@ -43,6 +43,10 @@ class puppetdb::server::database_ini(
$database_username = $puppetdb::params::database_username,
$database_password = $puppetdb::params::database_password,
$database_name = $puppetdb::params::database_name,
$node_ttl = $puppetdb::params::node_ttl,
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
$report_ttl = $puppetdb::params::report_ttl,
$gc_interval = $puppetdb::params::gc_interval,
$confdir = $puppetdb::params::confdir,
) inherits puppetdb::params {
@ -111,21 +115,21 @@ class puppetdb::server::database_ini(
ini_setting {'puppetdb_gc_interval':
setting => 'gc-interval',
value => $puppetdb::params::gc_interval,
value => $gc_interval,
}
ini_setting {'puppetdb_node_ttl':
setting => 'node-ttl',
value => $puppetdb::params::node_ttl,
value => $node_ttl,
}
ini_setting {'puppetdb_node_purge_ttl':
setting => 'node-purge-ttl',
value => $puppetdb::params::node_purge_ttl,
value => $node_purge_ttl,
}
ini_setting {'puppetdb_report_ttl':
setting => 'report-ttl',
value => $puppetdb::params::report_ttl,
value => $report_ttl,
}
}

View file

@ -53,7 +53,7 @@ class puppetdb::server::validate_db(
# 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,

21
spec/spec_helper.rb Normal file
View file

@ -0,0 +1,21 @@
require 'puppetlabs_spec_helper/module_spec_helper'
RSpec.configure do |c|
c.include PuppetlabsSpec::Files
c.before :each do
# Ensure that we don't accidentally cache facts and environment
# between test cases.
Facter::Util::Loader.any_instance.stubs(:load_all)
Facter.clear
Facter.clear_messages
# Store any environment variables away to be restored later
@old_env = {}
ENV.each_key {|k| @old_env[k] = ENV[k]}
end
c.after :each do
PuppetlabsSpec::Files.cleanup
end
end

View file

@ -0,0 +1,39 @@
require 'spec_helper'
describe 'puppetdb', :type => :class do
ttl_args = ['node_ttl','node_purge_ttl','report_ttl']
context 'on a supported platform' do
let(:facts) do
{
:osfamily => 'RedHat',
:postgres_default_version => '9.1',
:concat_basedir => '/var/lib/puppet/concat',
}
end
describe 'when using default values for puppetdb class' do
it { should contain_class('puppetdb') }
end
end
context 'with invalid arguments on a supported platform' do
let(:facts) do
{
:osfamily => 'RedHat',
:postgres_default_version => '9.1',
:concat_basedir => '/var/lib/puppet/concat',
}
end
ttl_args.each do |ttl_arg|
let(:params) do
{
ttl_arg => 'invalid_value'
}
end
it "when using a value that does not match the validation regex for #{ttl_arg} puppetdb class" do
expect { should contain_class('puppetdb') }.to raise_error(Puppet::Error)
end
end
end
end