(PDB-1485) Add default PuppetDB root context

This commit changes the terminus configuration to use the new root
prefix for PuppetDB and changes the connection validator to do the same.

This commit also adds the terminus package name changes `terminus` to
`termini` and tries to be smart about the default, checking to see what
version of PuppetDB was passed in and defaulting off of that value.
This commit is contained in:
Andrew Roetker 2015-05-15 14:10:08 -07:00
parent 4e407f8aae
commit 829626f6cb
7 changed files with 60 additions and 44 deletions

View file

@ -139,6 +139,15 @@ You can also manually trigger puppet runs on the nodes in the correct order (Pos
Upgrading
---------
###Upgrading from 4.x to version 5.x
Significant parameter changes are listed below:
* The PuppetDB module now supports PuppetDB 3.0.0 by default
* If you want to use 5.x of the module with PuppetDB 2.x, you'll need to set the `test_url => /v3/version` and either `puppetdb_version => 2.y.z` or `terminus_package => 2.y.z`
See the CHANGELOG file for more detailed information on changes for each release.
###Upgrading from 3.x to version 4.x
For this release, all dependency versions have been bumped to their latest. Significant parameter changes are listed below:
@ -557,7 +566,7 @@ Conditionally manages the PostgresQL server via `postgresql::server`. Defaults t
####`test_url`
The URL to use for testing if the PuppetDB instance is running. Defaults to `/v3/version`.
The URL to use for testing if the PuppetDB instance is running. Defaults to `/pdb/meta/v1/version`.
####`manage_package_repo`

View file

@ -10,7 +10,7 @@ module Puppet
attr_reader :test_path
attr_reader :test_headers
def initialize(puppetdb_server, puppetdb_port, use_ssl=true, test_path = "/v3/version")
def initialize(puppetdb_server, puppetdb_port, use_ssl=true, test_path = "/pdb/meta/v1/version")
@puppetdb_server = puppetdb_server
@puppetdb_port = puppetdb_port
@use_ssl = use_ssl

View file

@ -23,14 +23,27 @@ class puppetdb::master::config (
$puppet_confdir = $puppetdb::params::puppet_confdir,
$puppet_conf = $puppetdb::params::puppet_conf,
$puppetdb_version = $puppetdb::params::puppetdb_version,
$terminus_package = $puppetdb::params::terminus_package,
$terminus_package = '',
$puppet_service_name = $puppetdb::params::puppet_service_name,
$puppetdb_startup_timeout = $puppetdb::params::puppetdb_startup_timeout,
$test_url = $puppetdb::params::test_url,
$restart_puppet = true,
) inherits puppetdb::params {
package { $terminus_package:
if empty($terminus_package) {
$old_terminus_name = versioncmp($puppetdb_version, '3.0.0') < 0
$terminus_package_name = $puppetdb_version ? {
/(latest|present|absent)/ => 'puppetdb-termini',
default => $old_terminus_name ? {
true => 'puppetdb-terminus',
false => 'puppetdb-termini'
}
}
} else {
$terminus_package_name = $terminus_package
}
package { $terminus_package_name:
ensure => $puppetdb_version,
}
@ -52,7 +65,7 @@ class puppetdb::master::config (
default => true,
},
timeout => $puppetdb_startup_timeout,
require => Package[$terminus_package],
require => Package[$terminus_package_name],
test_url => $test_url,
}
@ -71,7 +84,7 @@ class puppetdb::master::config (
masterless => $masterless,
require => $strict_validation ? {
true => Puppetdb_conn_validator['puppetdb_conn'],
default => Package[$terminus_package],
default => Package[$terminus_package_name],
},
}
}
@ -85,7 +98,7 @@ class puppetdb::master::config (
masterless => $masterless,
require => $strict_validation ? {
true => Puppetdb_conn_validator['puppetdb_conn'],
default => Package[$terminus_package],
default => Package[$terminus_package_name],
},
}
}
@ -100,7 +113,7 @@ class puppetdb::master::config (
enable => $enable_reports,
require => $strict_validation ? {
true => Puppetdb_conn_validator['puppetdb_conn'],
default => Package[$terminus_package],
default => Package[$terminus_package_name],
},
}
}
@ -115,7 +128,7 @@ class puppetdb::master::config (
puppet_confdir => $puppet_confdir,
require => $strict_validation ? {
true => Puppetdb_conn_validator['puppetdb_conn'],
default => Package[$terminus_package],
default => Package[$terminus_package_name],
},
}
}

View file

@ -16,14 +16,9 @@ class puppetdb::master::puppetdb_conf (
path => "${puppet_confdir}/puppetdb.conf",
}
ini_setting { 'puppetdbserver':
setting => 'server',
value => $server,
}
ini_setting { 'puppetdbport':
setting => 'port',
value => $port,
ini_setting { 'puppetdbserver_urls':
setting => 'server_urls',
value => "https://#{server}:#{port}/",
}
ini_setting { 'soft_write_failure':

View file

@ -58,14 +58,13 @@ class puppetdb::params {
$manage_firewall = true
$java_args = {}
$test_url = '/v3/version'
$test_url = '/pdb/meta/v1/version'
$puppetdb_package = 'puppetdb'
$puppetdb_service = 'puppetdb'
$puppetdb_user = 'puppetdb'
$puppetdb_group = 'puppetdb'
$masterless = false
$terminus_package = 'puppetdb-terminus'
case $::osfamily {
'RedHat', 'Suse', 'Archlinux': {

View file

@ -26,53 +26,53 @@ describe 'puppetdb::master::config', :type => :class do
context 'when PuppetDB and Puppet Master are on the same server' do
context 'when using default values' do
let(:pre_condition) { 'class { "puppetdb": }' }
it { should contain_puppetdb_conn_validator('puppetdb_conn').with(
:puppetdb_server => 'puppetdb.example.com',
:puppetdb_port => '8081',
:use_ssl => 'true') }
:puppetdb_server => 'puppetdb.example.com',
:puppetdb_port => '8081',
:use_ssl => 'true') }
end
context 'when puppetdb class is declared with disable_ssl => true' do
let(:pre_condition) { 'class { "puppetdb": disable_ssl => true }' }
it { should contain_puppetdb_conn_validator('puppetdb_conn').with(
:puppetdb_port => '8080',
:use_ssl => 'false')
}
:puppetdb_port => '8080',
:use_ssl => 'false')}
end
context 'when puppetdb_port => 1234' do
let(:pre_condition) { 'class { "puppetdb": }' }
let(:params) do { :puppetdb_port => '1234' } end
it { should contain_puppetdb_conn_validator('puppetdb_conn').with(
:puppetdb_port => '1234',
:use_ssl => 'true')
}
:puppetdb_port => '1234',
:use_ssl => 'true')}
end
context 'when puppetdb_port => 1234 AND the puppetdb class is declared with disable_ssl => true' do
let(:pre_condition) { 'class { "puppetdb": disable_ssl => true }' }
let(:params) do {
:puppetdb_port => '1234'
} end
let(:params) do {:puppetdb_port => '1234'} end
it { should contain_puppetdb_conn_validator('puppetdb_conn').with(
:puppetdb_port => '1234',
:use_ssl => 'false')
}
:puppetdb_port => '1234',
:use_ssl => 'false')}
end
context 'when using default values' do
let (:pre_condition) { 'class { "puppetdb": }' }
it { should contain_package('puppetdb-termini').with( :ensure => 'present' )}
end
context 'when using an older puppetdb version' do
let (:pre_condition) { 'class { "puppetdb": puppetdb_version => "2.2.0", }' }
let (:params) do { :puppetdb_version => '2.2.0' } end
it { should contain_package('puppetdb-terminus').with( :ensure => '2.2.0' )}
end
end

View file

@ -12,12 +12,12 @@ describe 'Puppet::Util::PuppetdbValidator' do
response_not_found.stubs(:msg).returns('Not found')
conn_ok = stub()
conn_ok.stubs(:get).with('/v3/version', {"Accept" => "application/json"}).returns(response_ok)
conn_ok.stubs(:get).with('/pdb/meta/v1/version', {"Accept" => "application/json"}).returns(response_ok)
conn_ok.stubs(:read_timeout=).with(2)
conn_ok.stubs(:open_timeout=).with(2)
conn_not_found = stub()
conn_not_found.stubs(:get).with('/v3/version', {"Accept" => "application/json"}).returns(response_not_found)
conn_not_found.stubs(:get).with('/pdb/meta/v1/version', {"Accept" => "application/json"}).returns(response_not_found)
Puppet::Network::HttpPool.stubs(:http_instance).raises('Unknown host')
Puppet::Network::HttpPool.stubs(:http_instance).with('mypuppetdb.com', 8080, true).raises('Connection refused')