From edc8d3c3e3407fdcb3e40540b115b5e533c66042 Mon Sep 17 00:00:00 2001 From: Joseph Yaworski Date: Fri, 29 Jan 2016 13:27:06 -0500 Subject: [PATCH 01/16] Add postgresql_version fact --- lib/facter/postgresql_version.rb | 8 ++++++++ spec/unit/postgresql_version_spec.rb | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 lib/facter/postgresql_version.rb create mode 100644 spec/unit/postgresql_version_spec.rb diff --git a/lib/facter/postgresql_version.rb b/lib/facter/postgresql_version.rb new file mode 100644 index 0000000000..605479e2fd --- /dev/null +++ b/lib/facter/postgresql_version.rb @@ -0,0 +1,8 @@ +Facter.add(:postgresql_version) do + setcode do + if Facter::Util::Resolution.which('psql') + postgresql_version = Facter::Util::Resolution.exec('psql -V 2>&1') + %r{^psql \(PostgreSQL\) ([\w\.]+)}.match(postgresql_version)[1] + end + end +end diff --git a/spec/unit/postgresql_version_spec.rb b/spec/unit/postgresql_version_spec.rb new file mode 100644 index 0000000000..efe45096ef --- /dev/null +++ b/spec/unit/postgresql_version_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe Facter::Util::Fact do + before do + Facter.clear + end + + describe 'postgresql_version' do + context 'with value' do + before :each do + allow(Facter::Util::Resolution).to receive(:which).with('psql').and_return(true) + allow(Facter::Util::Resolution).to receive(:exec).with('psql -V 2>&1').and_return('psql (PostgreSQL) 9.4.5') + end + it do + expect(Facter.fact(:postgresql_version).value).to eq('9.4.5') + end + end + end +end From d71e3f754d92f3e3cc6bbe6db2a5ba131cd366fb Mon Sep 17 00:00:00 2001 From: Brett Maton Date: Fri, 29 Jan 2016 11:14:47 +0000 Subject: [PATCH 02/16] Fix password change failing postgres db user password change failing when postgres is listening on non standard port number. --- manifests/server/passwd.pp | 1 + spec/unit/classes/server_spec.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/manifests/server/passwd.pp b/manifests/server/passwd.pp index 358a044ea4..ba50098196 100644 --- a/manifests/server/passwd.pp +++ b/manifests/server/passwd.pp @@ -22,6 +22,7 @@ cwd => '/tmp', environment => [ "PGPASSWORD=${postgres_password}", + "PGPORT=${port}", "NEWPASSWD_ESCAPED=${escaped}", ], # With this command we're passing -h to force TCP authentication, which diff --git a/spec/unit/classes/server_spec.rb b/spec/unit/classes/server_spec.rb index bd56193f1f..14891fe5f5 100644 --- a/spec/unit/classes/server_spec.rb +++ b/spec/unit/classes/server_spec.rb @@ -45,6 +45,7 @@ 'user' => 'postgres', 'environment' => [ "PGPASSWORD=new-p@s$word-to-set", + "PGPORT=5432", "NEWPASSWD_ESCAPED=$$new-p@s$word-to-set$$" ], 'unless' => "/usr/bin/psql -h localhost -p 5432 -c 'select 1' > /dev/null", From 5354d0f1eadfc676c783a29b611793e05fe66d5a Mon Sep 17 00:00:00 2001 From: James Sweeny Date: Thu, 28 Jan 2016 15:14:04 -0500 Subject: [PATCH 03/16] (MODULES-3024) Quote database objects when creating databases Prior to this commit, when creating databases with a name or owner that has characters which must be quoted (e.g., "pe-postgres"), the postgresql::server::database define fails due to a SQL syntax error. --- manifests/server/database.pp | 8 ++++---- spec/acceptance/db_spec.rb | 18 +++++++++--------- spec/unit/defines/server/database_spec.rb | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/manifests/server/database.pp b/manifests/server/database.pp index f1adf646b7..fab12b53ae 100644 --- a/manifests/server/database.pp +++ b/manifests/server/database.pp @@ -55,7 +55,7 @@ $template_option = $template ? { undef => '', - default => "TEMPLATE=${template}", + default => "TEMPLATE=\"${template}\"", } $encoding_option = $encoding ? { @@ -65,7 +65,7 @@ $tablespace_option = $tablespace ? { undef => '', - default => "TABLESPACE=${tablespace}", + default => "TABLESPACE=\"${tablespace}\"", } if $createdb_path != undef{ @@ -73,7 +73,7 @@ } postgresql_psql { "Create db '${dbname}'": - command => "CREATE DATABASE \"${dbname}\" WITH OWNER=${owner} ${template_option} ${encoding_option} ${locale_option} ${tablespace_option}", + command => "CREATE DATABASE \"${dbname}\" WITH OWNER=\"${owner}\" ${template_option} ${encoding_option} ${locale_option} ${tablespace_option}", unless => "SELECT datname FROM pg_database WHERE datname='${dbname}'", db => $default_db, require => Class['postgresql::server::service'] @@ -99,7 +99,7 @@ default => 'shobj_description', } Postgresql_psql[ "Create db '${dbname}'" ]-> - postgresql_psql {"COMMENT ON DATABASE ${dbname} IS '${comment}'": + postgresql_psql {"COMMENT ON DATABASE \"${dbname}\" IS '${comment}'": unless => "SELECT pg_catalog.${comment_information_function}(d.oid, 'pg_database') as \"Description\" FROM pg_catalog.pg_database d WHERE datname = '${dbname}' AND pg_catalog.${comment_information_function}(d.oid, 'pg_database') = '${comment}'", db => $dbname, } diff --git a/spec/acceptance/db_spec.rb b/spec/acceptance/db_spec.rb index 643511967e..5c62237d35 100644 --- a/spec/acceptance/db_spec.rb +++ b/spec/acceptance/db_spec.rb @@ -8,14 +8,14 @@ class { 'postgresql::server': postgres_password => 'space password', } - postgresql::server::tablespace { 'postgresql_test_db': + postgresql::server::tablespace { 'postgresql-test-db': location => '#{tmpdir}', } -> - postgresql::server::db { 'postgresql_test_db': + postgresql::server::db { 'postgresql-test-db': comment => 'testcomment', - user => 'test', + user => 'test-user', password => 'test1', - tablespace => 'postgresql_test_db', + tablespace => 'postgresql-test-db', } EOS @@ -27,12 +27,12 @@ class { 'postgresql::server': shell("chmod 600 /root/.pgpass") shell("psql -U postgres -h localhost --command='\\l'") - psql('--command="select datname from pg_database" postgresql_test_db') do |r| - expect(r.stdout).to match(/postgresql_test_db/) + psql('--command="select datname from pg_database" "postgresql-test-db"') do |r| + expect(r.stdout).to match(/postgresql-test-db/) expect(r.stderr).to eq('') end - psql('--command="SELECT 1 FROM pg_roles WHERE rolname=\'test\'"') do |r| + psql('--command="SELECT 1 FROM pg_roles WHERE rolname=\'test-user\'"') do |r| expect(r.stdout).to match(/\(1 row\)/) end @@ -43,11 +43,11 @@ class { 'postgresql::server': else comment_information_function = "obj_description" end - psql("--dbname postgresql_test_db --command=\"SELECT pg_catalog.#{comment_information_function}(d.oid, 'pg_database') FROM pg_catalog.pg_database d WHERE datname = 'postgresql_test_db' AND pg_catalog.#{comment_information_function}(d.oid, 'pg_database') = 'testcomment'\"") do |r| + psql("--dbname postgresql-test-db --command=\"SELECT pg_catalog.#{comment_information_function}(d.oid, 'pg_database') FROM pg_catalog.pg_database d WHERE datname = 'postgresql-test-db' AND pg_catalog.#{comment_information_function}(d.oid, 'pg_database') = 'testcomment'\"") do |r| expect(r.stdout).to match(/\(1 row\)/) end ensure - psql('--command="drop database postgresql_test_db" postgres') + psql('--command="drop database "postgresql-test-db" postgres') psql('--command="DROP USER test"') end end diff --git a/spec/unit/defines/server/database_spec.rb b/spec/unit/defines/server/database_spec.rb index 16564d76bd..439623ebcf 100644 --- a/spec/unit/defines/server/database_spec.rb +++ b/spec/unit/defines/server/database_spec.rb @@ -27,7 +27,7 @@ let (:params) {{ :comment => 'test comment', :connect_settings => {} }} - it { is_expected.to contain_postgresql_psql("COMMENT ON DATABASE test IS 'test comment'").with_connect_settings( {} ) } + it { is_expected.to contain_postgresql_psql("COMMENT ON DATABASE \"test\" IS 'test comment'").with_connect_settings( {} ) } end context "with specific db connection settings - default port" do From 810448afa0af3d3da61c4c8c90d45d5f780da76f Mon Sep 17 00:00:00 2001 From: Farzad FARID Date: Mon, 1 Feb 2016 19:27:22 +0100 Subject: [PATCH 04/16] Escape case where password ends with '$'. postgresql_escape returned an invalid string if the password end in '$': postgres=# alter role "postgres" password $$foo$$$; ERROR: syntax error at or near "$" LINE 1: alter role "postgres" password $$foo$$$; --- lib/puppet/parser/functions/postgresql_escape.rb | 4 ++-- spec/unit/functions/postgresql_escape_spec.rb | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/puppet/parser/functions/postgresql_escape.rb b/lib/puppet/parser/functions/postgresql_escape.rb index 4089a4e94d..1ec11b8579 100644 --- a/lib/puppet/parser/functions/postgresql_escape.rb +++ b/lib/puppet/parser/functions/postgresql_escape.rb @@ -11,7 +11,7 @@ module Puppet::Parser::Functions password = args[0] - if password !~ /\$\$/ + if password !~ /\$\$/ and password[-1] != '$' retval = "$$#{password}$$" else escape = Digest::MD5.hexdigest(password)[0..5].gsub(/\d/,'') @@ -20,6 +20,6 @@ module Puppet::Parser::Functions end retval = "$#{escape}$#{password}$#{escape}$" end - retval + retval end end diff --git a/spec/unit/functions/postgresql_escape_spec.rb b/spec/unit/functions/postgresql_escape_spec.rb index f7eec6a83f..b4c9488a26 100644 --- a/spec/unit/functions/postgresql_escape_spec.rb +++ b/spec/unit/functions/postgresql_escape_spec.rb @@ -8,3 +8,7 @@ it { is_expected.to run.with_params('fo$$o'). and_return('$ed$fo$$o$ed$') } end +describe 'postgresql_escape', :type => :puppet_function do + it { is_expected.to run.with_params('foo$'). + and_return('$a$foo$$a$') } +end From 7e27a989c03b3635c5bcba811ba67101888aacce Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Tue, 2 Feb 2016 10:51:20 -0800 Subject: [PATCH 05/16] Fix quoting --- spec/acceptance/db_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/db_spec.rb b/spec/acceptance/db_spec.rb index 5c62237d35..449c4b0fe2 100644 --- a/spec/acceptance/db_spec.rb +++ b/spec/acceptance/db_spec.rb @@ -47,7 +47,7 @@ class { 'postgresql::server': expect(r.stdout).to match(/\(1 row\)/) end ensure - psql('--command="drop database "postgresql-test-db" postgres') + psql('--command=\'drop database "postgresql-test-db" postgres\'') psql('--command="DROP USER test"') end end From baa90be132c9a0c0416f57f4c2906394f0f6c627 Mon Sep 17 00:00:00 2001 From: Brandon Weeks Date: Mon, 1 Feb 2016 10:27:21 -0800 Subject: [PATCH 06/16] Allow puppetlabs-concat 2.x --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 5d9bf48222..2a0dda7aef 100644 --- a/metadata.json +++ b/metadata.json @@ -10,7 +10,7 @@ "dependencies": [ {"name":"puppetlabs/stdlib","version_requirement":"4.x"}, {"name":"puppetlabs/apt","version_requirement":">=1.8.0 <3.0.0"}, - {"name":"puppetlabs/concat","version_requirement":">= 1.1.0 <2.0.0"} + {"name":"puppetlabs/concat","version_requirement":">= 1.1.0 <3.0.0"} ], "operatingsystem_support": [ { From feb7f05271454713ae6efdbe095b0d34b6c8c2dc Mon Sep 17 00:00:00 2001 From: Shawn Sterling Date: Wed, 3 Feb 2016 16:05:56 -0800 Subject: [PATCH 07/16] amazon linux defaults to postgresql92 now, this workaround will let it install --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 667c2115d4..aa5eef74ab 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -30,7 +30,7 @@ $version_parts = split($version, '[.]') $package_version = "${version_parts[0]}${version_parts[1]}" - if $version == $postgresql::globals::default_version { + if $version == $postgresql::globals::default_version and $::operatingsystem != 'Amazon' { $client_package_name = pick($client_package_name, 'postgresql') $server_package_name = pick($server_package_name, 'postgresql-server') $contrib_package_name = pick($contrib_package_name,'postgresql-contrib') From 58f3f13762f794f731f57bdc07d4e362ef620367 Mon Sep 17 00:00:00 2001 From: Martijn Storck Date: Thu, 4 Feb 2016 11:04:14 +0100 Subject: [PATCH 08/16] Fix markdown error in README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 13c1fdc2d9..4b6eca420a 100644 --- a/README.md +++ b/README.md @@ -1094,6 +1094,7 @@ Sets the hash to use during password creation. If the password is not already pr postgresql::server::role { "myusername": password_hash => postgresql_password('myusername', 'mypassword'), } +``` ##### `replication` From dc62d48a5bcebc4b6e61d48754ed719d50827ba0 Mon Sep 17 00:00:00 2001 From: Andreas Ntaflos Date: Tue, 9 Feb 2016 17:42:53 +0100 Subject: [PATCH 09/16] Correctly set $service_provider The `$service_provider` variable in params.pp is user-definable via `postgresql::globals::service_provider`. Thus params.pp should reference that variable correctly, like other variables from globals.pp. --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 667c2115d4..66c8f11800 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -14,7 +14,7 @@ $service_enable = true $service_manage = true $service_restart_on_change = true - $service_provider = $service_provider + $service_provider = $postgresql::globals::service_provider $manage_pg_hba_conf = pick($manage_pg_hba_conf, true) $manage_pg_ident_conf = pick($manage_pg_ident_conf, true) $manage_recovery_conf = pick($manage_recovery_conf, false) From 8db810e2686ce8552beec2e49cd318dd47b3d9d8 Mon Sep 17 00:00:00 2001 From: Gerlof Fokkema Date: Sun, 7 Feb 2016 04:06:10 +0100 Subject: [PATCH 10/16] $service_provider statement doesn't seem to do anything. The cause turned out to be a misconfigured setting for OS type Archlinux. --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 667c2115d4..d54db12a79 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -112,7 +112,7 @@ $psql_path = pick($psql_path, "${bindir}/psql") $service_status = $service_status - $service_reload = "service ${service_name} reload" + $service_reload = "systemctl reload ${service_name}" $python_package_name = pick($python_package_name, 'python-psycopg2') # Archlinux does not have a perl::DBD::Pg package $perl_package_name = pick($perl_package_name, 'undef') From a690089f89de6f388162ee79ca967503679fd58e Mon Sep 17 00:00:00 2001 From: Aselinux Date: Fri, 12 Feb 2016 01:27:02 +0000 Subject: [PATCH 11/16] postgres server init script naming on amazon linux ami On current amazon linux ami (details below), and open puppet (details below), the postgres module (installed as part of puppetlabs/puppetdb) currently, tries to start postgressql server with /etc/init.d/postgresql9.4 , while the init script doesn't have the dot in the version number, so it needs to use /etc/init.d/postgresql94 From what I see in all available postgresql server rpms, currently on amazon linux ami, seems all the init scripts of postgresql doesn't have a dot in the suffix version number. Supporting info: [root@puppet ~]# yum list postgres* | grep 'server\.'; postgresql94-server.x86_64 9.4.5-1.63.amzn1 @amzn-updates postgresql8-server.x86_64 8.4.20-4.51.amzn1 amzn-updates postgresql92-server.x86_64 9.2.14-1.56.amzn1 amzn-updates postgresql93-server.x86_64 9.3.10-1.60.amzn1 amzn-updates for i in postgresql8-server.x86_64 postgresql92-server.x86_64 postgresql93-server.x86_64 postgresql94-server.x86_64; do echo $i; repoquery -l $i | grep init.d; done postgresql8-server.x86_64 /etc/rc.d/init.d/postgresql postgresql92-server.x86_64 /etc/rc.d/init.d/postgresql92 postgresql93-server.x86_64 /etc/rc.d/init.d/postgresql93 postgresql94-server.x86_64 [root@puppet ~]# puppet --version 4.3.2 [root@puppet ~]# rpm -qa | grep puppet | grep server puppetserver-2.2.1-1.el6.noarch [root@puppet ~]# [root@puppet ~]# cat /etc/os-release NAME="Amazon Linux AMI" VERSION="2015.09" ID="amzn" ID_LIKE="rhel fedora" VERSION_ID="2015.09" PRETTY_NAME="Amazon Linux AMI 2015.09" ANSI_COLOR="0;33" CPE_NAME="cpe:/o:amazon:linux:2015.09:ga" HOME_URL="http://aws.amazon.com/amazon-linux-ami/" [root@puppet ~]# [root@puppet ~]# cat /etc/system-release Amazon Linux AMI release 2015.09 --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 66c8f11800..5c549278dc 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -56,7 +56,7 @@ $plperl_package_name = pick($plperl_package_name, "postgresql${package_version}-plperl") $plpython_package_name = pick($plpython_package_name, "postgresql${package_version}-plpython") $service_name = $::operatingsystem ? { - 'Amazon' => pick($service_name, "postgresql${version}"), + 'Amazon' => pick($service_name, "postgresql${version_parts[0]}${version_parts[1]}"), default => pick($service_name, "postgresql-${version}"), } $bindir = $::operatingsystem ? { From cddfd664807314e2bc37d549860ea9d719df45c8 Mon Sep 17 00:00:00 2001 From: jbondpdx Date: Fri, 12 Feb 2016 15:44:27 -0800 Subject: [PATCH 12/16] correcting formatting error in README --- README.md | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 4b6eca420a..5f26abdf93 100644 --- a/README.md +++ b/README.md @@ -229,13 +229,14 @@ postgresql::server::pg_ident_rule{ 'Map the SSL certificate of the backup server system_username => 'repli1.example.com', database_username => 'replication', } +``` This would create a user name map in `pg_ident.conf` similar to: ``` -# Rule Name: Map the SSL certificate of the backup server as a replication user -# Description: none -# Order: 150 +#Rule Name: Map the SSL certificate of the backup server as a replication user +#Description: none +#Order: 150 sslrepli repli1.example.com replication ``` @@ -280,10 +281,9 @@ recovery_min_apply_delay = 0 Only the specified parameters are recognized in the template. The `recovery.conf` is only be created if at least one parameter is set **and** [manage_recovery_conf](#manage_recovery_conf) is set to true. - ### Validate connectivity -To validate client connections to a remote PostgreSQL database before starting dependent tasks, use the `postgresql::validate_db_connection` resource. You can use this on any node where the PostgreSQL client software is installed. It is often chained to other tasks such as starting an application server or performing a database migration. +To validate client connections to a remote PostgreSQL database before starting dependent tasks, use the `postgresql::validate_db_connection` resource. You can use this on any node where the PostgreSQL client software is installed. It is often chained to other tasks such as starting an application server or performing a database migration. Example usage: @@ -299,11 +299,11 @@ exec { 'rake db:migrate': } ``` - ## Reference +## Reference The posgresql module comes with many options for configuring the server. While you are unlikely to use all of the settings below, they provide a decent amount of control over your security settings. -Classes: +**Classes:** * [postgresql::client](#postgresqlclient) * [postgresql::globals](#postgresqlglobals) @@ -316,7 +316,7 @@ Classes: * [postgresql::server::contrib](#postgresqlservercontrib) * [postgresql::server::postgis](#postgresqlserverpostgis) -Defined Types: +**Defined Types:** * [postgresql::server::config_entry](#postgresqlserverconfig_entry) * [postgresql::server::database](#postgresqlserverdatabase) @@ -332,13 +332,13 @@ Defined Types: * [postgresql::server::tablespace](#postgresqlservertablespace) * [postgresql::validate_db_connection](#postgresqlvalidate_db_connection) -Types: +**Types:** * [postgresql_psql](#custom-resource-postgresql_psql) * [postgresql_replication_slot](#custom-resource-postgresql_replication_slot) * [postgresql_conf](#custom-resource-postgresql_conf) -Functions: +**Functions:** * [postgresql_password](#function-postgresql_password) * [postgresql_acls_to_resources_hash](#function-postgresql_acls_to_resources_hashacl_array-id-order_offset) @@ -367,7 +367,7 @@ Specifies the path to validate the connection script. Default: '/usr/local/bin/v Installs PostgreSQL bindings for Postgres-Docs. Set the following parameters if you have a custom version you would like to install. ->**Note:** Make sure to add any necessary yum or apt repositories if specifying a custom version. +**Note:** Make sure to add any necessary yum or apt repositories if specifying a custom version. ##### `package_name` @@ -379,7 +379,7 @@ Whether the PostgreSQL docs package resource should be present. Valid values: 'p #### postgresql::globals ->**Note:** Most server-specific defaults should be overriden in the `postgresql::server` class. This class should be used only if you are using a non-standard OS, or if you are changing elements that can only be changed here, such as `version` or `manage_package_repo`. +**Note:** Most server-specific defaults should be overriden in the `postgresql::server` class. This class should be used only if you are using a non-standard OS, or if you are changing elements that can only be changed here, such as `version` or `manage_package_repo`. ##### `bindir` @@ -405,7 +405,7 @@ Overrides the default PostgreSQL contrib package name. Default: OS dependent. Overrides the default PostgreSQL data directory for the target platform. Default: OS dependent. ->**Note:** Changing the datadir after installation causes the server to come to a full stop before making the change. For RedHat systems, the data directory must be labeled appropriately for SELinux. On Ubuntu, you must explicitly set `needs_initdb = true` to allow Puppet to initialize the database in the new datadir (`needs_initdb` defaults to true on other systems). +**Note:** Changing the datadir after installation causes the server to come to a full stop before making the change. For RedHat systems, the data directory must be labeled appropriately for SELinux. On Ubuntu, you must explicitly set `needs_initdb = true` to allow Puppet to initialize the database in the new datadir (`needs_initdb` defaults to true on other systems). **Warning:** If datadir is changed from the default, Puppet does not manage purging of the original data directory, which causes it to fail if the data directory is changed back to the original. @@ -545,11 +545,11 @@ Overrides the `ensure` parameter during package installation. Defaults to `prese Overrides the default package name for the distribution you are installing to. Defaults to `postgresql-devel` or `postgresql-devel` depending on your distro. -####postgresql::lib::java +#### postgresql::lib::java Installs PostgreSQL bindings for Java (JDBC). Set the following parameters if you have a custom version you would like to install. ->**Note:** Make sure to add any necessary yum or apt repositories if specifying a custom version. +**Note:** Make sure to add any necessary yum or apt repositories if specifying a custom version. ##### `package_ensure` @@ -583,7 +583,7 @@ Specifies the name of the postgresql PL/Python package. Specifies whether the package is present. Valid values: 'present', 'absent'. Default: 'present'. -####postgresql::lib::python +#### postgresql::lib::python Installs PostgreSQL Python libraries. @@ -595,7 +595,7 @@ Specifies whether the package is present. Valid values: 'present', 'absent'. Def The name of the PostgreSQL Python package. -####postgresql::server +#### postgresql::server ##### `createdb_path` @@ -1108,7 +1108,6 @@ Specifies whether to grant super user capability for the new role. Default: fals Defines the username of the role to create. Defaults to the namevar. - #### postgresql::server::schema Creates a schema. From abd6c6fe078854d8fa27e3fe0fb1c8eb4b827a41 Mon Sep 17 00:00:00 2001 From: icetrain Date: Mon, 15 Feb 2016 13:11:26 +0100 Subject: [PATCH 13/16] Add missing onlyif_function to sequence grant code --- manifests/server/grant.pp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/manifests/server/grant.pp b/manifests/server/grant.pp index 447ba186df..2227915ea6 100644 --- a/manifests/server/grant.pp +++ b/manifests/server/grant.pp @@ -96,11 +96,13 @@ validate_string($unless_privilege,'USAGE','ALL','ALL PRIVILEGES') $unless_function = 'has_sequence_privilege' $on_db = $db + $onlyif_function = undef } 'ALL SEQUENCES IN SCHEMA': { validate_string($_privilege,'USAGE','ALL','ALL PRIVILEGES') $unless_function = 'custom' $on_db = $db + $onlyif_function = undef $schema = $object_name @@ -247,4 +249,4 @@ if($db != undef and defined(Postgresql::Server::Database[$db])) { Postgresql::Server::Database[$db]->Postgresql_psql["grant:${name}"] } -} \ No newline at end of file +} From 8ce25cc6f337be42e4db23dac33b16383df39118 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Tue, 16 Feb 2016 16:01:03 +0000 Subject: [PATCH 14/16] (FM-4046) Update to current msync configs [006831f] This moves all copyright statements to the NOTICE file in accordance with the ASFs guidelines on applying the Apache-2.0 license. --- .gitattributes | 5 ++++- .gitignore | 1 + .travis.yml | 1 + Gemfile | 39 +++++++++++++++------------------------ LICENSE | 2 +- NOTICE | 23 +++++++++++++++++++---- Rakefile | 31 +++++++++++++++++++++++++++++++ spec/spec_helper.rb | 1 + 8 files changed, 73 insertions(+), 30 deletions(-) diff --git a/.gitattributes b/.gitattributes index e1fb344e08..900ea0cbb5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,5 @@ -*.sh eol=lf +#This file is generated by ModuleSync, do not edit. *.rb eol=lf +*.erb eol=lf +*.pp eol=lf +*.sh eol=lf diff --git a/.gitignore b/.gitignore index 3190277498..dd126f2fb2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +#This file is generated by ModuleSync, do not edit. pkg/ Gemfile.lock vendor/ diff --git a/.travis.yml b/.travis.yml index e6314a4700..588fb5b002 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +#This file is generated by ModuleSync, do not edit. --- sudo: false language: ruby diff --git a/Gemfile b/Gemfile index ced190e770..e490bc9b98 100644 --- a/Gemfile +++ b/Gemfile @@ -1,12 +1,14 @@ +#This file is generated by ModuleSync, do not edit. + source ENV['GEM_SOURCE'] || "https://rubygems.org" -def location_for(place, fake_version = nil) +def location_for(place, version = nil) if place =~ /^(git[:@][^#]*)#(.*)/ - [fake_version, { :git => $1, :branch => $2, :require => false }].compact + [version, { :git => $1, :branch => $2, :require => false}].compact elsif place =~ /^file:\/\/(.*)/ - ['>= 0', { :path => File.expand_path($1), :require => false }] + ['>= 0', { :path => File.expand_path($1), :require => false}] else - [place, { :require => false }] + [place, version, { :require => false}].compact end end @@ -20,29 +22,18 @@ group :development, :unit_tests do gem 'simplecov', :require => false end group :system_tests do + gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION'] || '>= 3.4') + gem 'beaker', *location_for(ENV['BEAKER_VERSION']) + gem 'serverspec', :require => false gem 'beaker-puppet_install_helper', :require => false - if beaker_version = ENV['BEAKER_VERSION'] - gem 'beaker', *location_for(beaker_version) - end - if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] - gem 'beaker-rspec', *location_for(beaker_rspec_version) - else - gem 'beaker-rspec', :require => false - end gem 'master_manipulator', :require => false - gem 'serverspec', :require => false + gem 'beaker-hostgenerator', *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION']) end -if facterversion = ENV['FACTER_GEM_VERSION'] - gem 'facter', facterversion, :require => false -else - gem 'facter', :require => false -end +gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) +gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) -if puppetversion = ENV['PUPPET_GEM_VERSION'] - gem 'puppet', puppetversion, :require => false -else - gem 'puppet', :require => false -end -# vim:ft=ruby +if File.exists? "#{__FILE__}.local" + eval(File.read("#{__FILE__}.local"), binding) +end diff --git a/LICENSE b/LICENSE index 7a29c73c87..d645695673 100644 --- a/LICENSE +++ b/LICENSE @@ -187,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2013 Puppet Labs + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/NOTICE b/NOTICE index c01b4637bc..295ce296de 100644 --- a/NOTICE +++ b/NOTICE @@ -1,8 +1,8 @@ -Puppetlabs postgresql module +postgresql puppet module -Copyright 2012 Inkling Systems Inc -Copyright 2012-2013 Puppet Labs Inc -Copyright 2012-2013 Camptocamp SA. +Copyright (C) 2012-2016 Puppet Labs, Inc. +Copyright (C) 2012 Inkling Systems Inc +Copyright (C) 2012-2013 Camptocamp SA. This product includes software developed by: The Puppet Labs Inc (http://www.puppetlabs.com/). @@ -12,3 +12,18 @@ This product includes also software developed by: This product includes also software developed by: Inkling Systems Inc (https://www.inkling.com/) + +Puppet Labs can be contacted at: info@puppetlabs.com + + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/Rakefile b/Rakefile index 35ce31140e..7e9a13d5df 100644 --- a/Rakefile +++ b/Rakefile @@ -9,3 +9,34 @@ PuppetLint.configuration.send('disable_class_inherits_from_params_class') PuppetLint.configuration.send('disable_documentation') PuppetLint.configuration.send('disable_single_quote_string_with_variables') PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] + +desc 'Generate pooler nodesets' +task :gen_nodeset do + require 'beaker-hostgenerator' + require 'securerandom' + require 'fileutils' + + agent_target = ENV['TEST_TARGET'] + if ! agent_target + STDERR.puts 'TEST_TARGET environment variable is not set' + STDERR.puts 'setting to default value of "redhat-64default."' + agent_target = 'redhat-64default.' + end + + master_target = ENV['MASTER_TEST_TARGET'] + if ! master_target + STDERR.puts 'MASTER_TEST_TARGET environment variable is not set' + STDERR.puts 'setting to default value of "redhat7-64mdcl"' + master_target = 'redhat7-64mdcl' + end + + targets = "#{master_target}-#{agent_target}" + cli = BeakerHostGenerator::CLI.new([targets]) + nodeset_dir = "tmp/nodesets" + nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml" + FileUtils.mkdir_p(nodeset_dir) + File.open(nodeset, 'w') do |fh| + fh.print(cli.execute) + end + puts nodeset +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a7f5b4ecb3..22d5d689f4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,4 @@ +#This file is generated by ModuleSync, do not edit. require 'puppetlabs_spec_helper/module_spec_helper' # put local configuration and setup into spec_helper_local From e06fc02731fc737de3b334f194798ccdf1ea554d Mon Sep 17 00:00:00 2001 From: Bryan Jen Date: Wed, 17 Feb 2016 12:54:02 -0700 Subject: [PATCH 15/16] Revert "Add postgresql_version fact" --- lib/facter/postgresql_version.rb | 8 -------- spec/unit/postgresql_version_spec.rb | 19 ------------------- 2 files changed, 27 deletions(-) delete mode 100644 lib/facter/postgresql_version.rb delete mode 100644 spec/unit/postgresql_version_spec.rb diff --git a/lib/facter/postgresql_version.rb b/lib/facter/postgresql_version.rb deleted file mode 100644 index 605479e2fd..0000000000 --- a/lib/facter/postgresql_version.rb +++ /dev/null @@ -1,8 +0,0 @@ -Facter.add(:postgresql_version) do - setcode do - if Facter::Util::Resolution.which('psql') - postgresql_version = Facter::Util::Resolution.exec('psql -V 2>&1') - %r{^psql \(PostgreSQL\) ([\w\.]+)}.match(postgresql_version)[1] - end - end -end diff --git a/spec/unit/postgresql_version_spec.rb b/spec/unit/postgresql_version_spec.rb deleted file mode 100644 index efe45096ef..0000000000 --- a/spec/unit/postgresql_version_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'spec_helper' - -describe Facter::Util::Fact do - before do - Facter.clear - end - - describe 'postgresql_version' do - context 'with value' do - before :each do - allow(Facter::Util::Resolution).to receive(:which).with('psql').and_return(true) - allow(Facter::Util::Resolution).to receive(:exec).with('psql -V 2>&1').and_return('psql (PostgreSQL) 9.4.5') - end - it do - expect(Facter.fact(:postgresql_version).value).to eq('9.4.5') - end - end - end -end From 0d4e9327f4a0109d86aef679456b2a223237439a Mon Sep 17 00:00:00 2001 From: Bryan Jen Date: Wed, 17 Feb 2016 17:53:42 -0700 Subject: [PATCH 16/16] Release prep for 4.7.1. --- CHANGELOG.md | 16 ++++++++++++++++ metadata.json | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index edd4ff25d0..4325ee2350 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +## Supported Release 4.7.1 +### Summary +This release contains some bugfixes and documentation updates. + +#### Bugfixes +- (MODULES-3024) Quote database objects when creating databases. +- Properly escape case where password ends with '$'. +- Fixes password change when postgres is configure to non-standard port. +- Unpins concat dependency to be able to use concat 2.x. +- Workaround to fix installing on Amazon Linux. +- Fixes proper defaulting of `$service_provider` parameter. +- Fixes postgres server init script naming on Amazon Linux. +- Fixes service reload parameter on Arch Linux. +- Adds missing onlyif_function to sequence grant code. +- Fixes to the markdown of the README. + ## Supported Release 4.7.0 ### Summary A release with a considerable amount of new features, including remote db support and several platform support updates. Various bugfixes including several to address warnings and a sizable README update. diff --git a/metadata.json b/metadata.json index 6ba1e2368b..f9e5ced597 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-postgresql", - "version": "4.7.0", + "version": "4.7.1", "author": "Inkling/Puppet Labs", "summary": "Offers support for basic management of PostgreSQL databases.", "license": "Apache-2.0", @@ -12,6 +12,7 @@ {"name":"puppetlabs/apt","version_requirement":">=1.8.0 <3.0.0"}, {"name":"puppetlabs/concat","version_requirement":">= 1.1.0 <3.0.0"} ], + "data_provider": null, "operatingsystem_support": [ { "operatingsystem": "RedHat",