From 8eb9f676694196b654c30d98b1ba5306a9c0f5c4 Mon Sep 17 00:00:00 2001 From: Andrew Roetker Date: Wed, 24 Jun 2015 09:10:32 -0700 Subject: [PATCH] (PDB-1657) Manage Postgres repos by default This commit moves to managing the Postgres repos by default. The reason for this is so that the `puppetdb` class will "just work" by default on most systems, because PostgreSQL 9.4 is not installed on 6/7 of the distros we support we need to manage the repos so we can install the latest version. --- README.md | 5 +++-- manifests/database/postgresql.pp | 8 +++----- manifests/init.pp | 4 ++-- manifests/params.pp | 2 +- spec/unit/classes/init_spec.rb | 2 ++ spec/unit/classes/master/config_spec.rb | 2 ++ spec/unit/classes/master/puppetdb_conf_spec.rb | 2 ++ 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 348759f..f4797ee 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,7 @@ Upgrading Significant parameter changes are listed below: * The PuppetDB module now supports PuppetDB 3.0.0 by default +* The PuppetDB module now manages Postgres repos by default. To turn this behavior off, set `manage_package_repo` to false. * If you want to use 5.x of the module with PuppetDB 2.x, you'll need to use the new `puppetdb::globals` class to set the version of PuppetDB you're using explicitly. The ability to configure the version has been therefore moved out of the `puppetdb` and `puppetdb::server` classes. For example if your config looked like this before: ~~~ruby @@ -598,11 +599,11 @@ The URL to use for testing if the PuppetDB instance is running. Defaults to `/pd ####`manage_package_repo` -if this is true, the official postgres.org repo will be added and postgres won't be installed from the regular repository. +If this is true, the official postgres.org repo will be added and postgres won't be installed from the regular repository. This setting defaults to `true`. ####`postgres_version` -if the postgres.org repo is installed, you can install several versions of postgres, this currently defaults to 9.4 which is the latest stable version. +If the postgres.org repo is installed, you can install several versions of postgres. This currently defaults to 9.4 which is the latest stable version. Implementation --------------- diff --git a/manifests/database/postgresql.pp b/manifests/database/postgresql.pp index 6156ff8..51f2e97 100644 --- a/manifests/database/postgresql.pp +++ b/manifests/database/postgresql.pp @@ -11,11 +11,9 @@ class puppetdb::database::postgresql( ) inherits puppetdb::params { if $manage_server { - if $manage_package_repo { - class { '::postgresql::globals': - manage_package_repo => true, - version => $postgres_version, - } + class { '::postgresql::globals': + manage_package_repo => $manage_package_repo, + version => $postgres_version, } # get the pg server up and running class { '::postgresql::server': diff --git a/manifests/init.pp b/manifests/init.pp index 92cff0b..1e9ef6d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -127,12 +127,12 @@ class puppetdb ( } if ($database == 'postgres') { - + $database_before = str2bool($database_validate) ? { false => Class['::puppetdb::server'], default => [Class['::puppetdb::server'], Class['::puppetdb::server::validate_db']], } - + class { '::puppetdb::database::postgresql': listen_addresses => $database_listen_address, database_name => $database_name, diff --git a/manifests/params.pp b/manifests/params.pp index d281f29..1148ee4 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -15,7 +15,7 @@ class puppetdb::params inherits puppetdb::globals { $puppetdb_version = $puppetdb::globals::version $database = $puppetdb::globals::database $manage_dbserver = true - $manage_pg_repo = false + $manage_pg_repo = true $postgres_version = '9.4' # The remaining database settings are not used for an embedded database diff --git a/spec/unit/classes/init_spec.rb b/spec/unit/classes/init_spec.rb index 83ba4db..f6bf9df 100644 --- a/spec/unit/classes/init_spec.rb +++ b/spec/unit/classes/init_spec.rb @@ -11,6 +11,8 @@ describe 'puppetdb', :type => :class do :operatingsystemrelease => '6.0', :kernel => 'Linux', :concat_basedir => '/var/lib/puppet/concat', + :lsbdistid => 'Debian', + :lsbdistcodename => 'foo', :id => 'root', :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', } diff --git a/spec/unit/classes/master/config_spec.rb b/spec/unit/classes/master/config_spec.rb index e9c8d80..ca4c7db 100644 --- a/spec/unit/classes/master/config_spec.rb +++ b/spec/unit/classes/master/config_spec.rb @@ -9,6 +9,8 @@ describe 'puppetdb::master::config', :type => :class do :operatingsystem => 'Debian', :operatingsystemrelease => '6.0', :kernel => 'Linux', + :lsbdistid => 'Debian', + :lsbdistcodename => 'foo', :concat_basedir => '/var/lib/puppet/concat', :id => 'root', :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', diff --git a/spec/unit/classes/master/puppetdb_conf_spec.rb b/spec/unit/classes/master/puppetdb_conf_spec.rb index 241e336..3329418 100644 --- a/spec/unit/classes/master/puppetdb_conf_spec.rb +++ b/spec/unit/classes/master/puppetdb_conf_spec.rb @@ -8,6 +8,8 @@ describe 'puppetdb::master::puppetdb_conf', :type => :class do :osfamily => 'Debian', :operatingsystem => 'Debian', :operatingsystemrelease => '6.0', + :lsbdistid => 'Debian', + :lsbdistcodename => 'foo', :kernel => 'Linux', :concat_basedir => '/var/lib/puppet/concat', :id => 'root',