Added puppetlabs-firewall (required by puppetlabs-postgresql), updated the other modules.

This commit is contained in:
Ciaby 2014-07-11 14:51:15 -05:00
parent 5f4b7a3b72
commit dee66abcdd
137 changed files with 11118 additions and 419 deletions

View file

@ -1,3 +1,25 @@
##2014-04-14 - Supported Release 3.4.0
###Summary
This feature rolls up several important features, the biggest being PostGIS
handling and allowing `port` to be set on postgresql::server in order to
change the port that Postgres listens on. We've added support for RHEL7
and Ubuntu 14.04, as well as allowing you to manage the service via
`service_ensure` finally.
####Features
- Added `perl_package_name` for installing bindings.
- Added `service_ensure` for allowing control of services.
- Added `postgis_version` and postgis class for installing postgis.
- Added `port` for selecting the port Postgres runs on.
- Add support for RHEL7 and Ubuntu 14.04.
- Add `default_db` to postgresql::server::database.
- Widen the selection of unquoted parameters in postgresql_conf{}
- Require the service within postgresql::server::reload for RHEL7.
- Add `inherit` to postgresql::server::role.
####Bugfixes
##2014-03-04 - Supported Release 3.3.3
###Summary

View file

@ -1,12 +1,11 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"
group :development, :test do
gem 'rake'
gem 'pry', :require => false
gem 'rake', '10.1.1'
gem 'puppetlabs_spec_helper', :require => false
gem 'rspec-puppet', '< 1.0'
gem 'rspec-puppet', '~> 1.0'
gem 'rspec', '~> 2.11', :require => false
gem 'puppet-lint', '~> 0.3.2'
gem 'beaker', :require => false
gem 'beaker-rspec', :require => false
gem 'serverspec', :require => false
end

View file

@ -1,23 +1,35 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (2.2.7)
beaker (1.7.0)
CFPropertyList (2.2.8)
addressable (2.3.6)
archive-tar-minitar (0.5.2)
autoparse (0.3.3)
addressable (>= 2.3.1)
extlib (>= 0.9.15)
multi_json (>= 1.0.0)
aws-sdk (1.42.0)
json (~> 1.4)
nokogiri (>= 1.4.4)
beaker (1.15.0)
aws-sdk (= 1.42.0)
blimpy (~> 0.6)
docker-api
fission (~> 0.4)
google-api-client (~> 0.7.1)
inifile (~> 2.0)
json (~> 1.8)
mime-types (~> 1.25)
net-scp (~> 1.1)
net-ssh (~> 2.6)
nokogiri (= 1.5.10)
nokogiri (~> 1.5.10)
rbvmomi (= 1.8.1)
unf (~> 0.1)
beaker-rspec (2.1.1)
beaker (~> 1.3)
rspec (~> 2.14)
serverspec (~> 0.14)
specinfra (~> 0.3)
beaker-rspec (2.2.6)
beaker (~> 1.10)
rspec
serverspec (~> 1.0)
specinfra (~> 1.0)
blimpy (0.6.7)
fog
minitar
@ -25,81 +37,133 @@ GEM
builder (3.2.2)
coderay (1.1.0)
diff-lcs (1.2.5)
excon (0.31.0)
facter (1.7.5)
docile (1.1.5)
docker-api (1.13.0)
archive-tar-minitar
excon (>= 0.37.0)
json
excon (0.37.0)
extlib (0.9.16)
facter (2.1.0)
CFPropertyList (~> 2.2.6)
faraday (0.9.0)
multipart-post (>= 1.2, < 3)
fission (0.5.0)
CFPropertyList (~> 2.2)
fog (1.19.0)
fog (1.22.1)
fog-brightbox
fog-core (~> 1.22)
fog-json
ipaddress (~> 0.5)
nokogiri (~> 1.5, >= 1.5.11)
fog-brightbox (0.1.1)
fog-core (~> 1.22)
fog-json
inflecto
fog-core (1.22.0)
builder
excon (~> 0.31.0)
formatador (~> 0.2.0)
excon (~> 0.33)
formatador (~> 0.2)
mime-types
multi_json (~> 1.0)
net-scp (~> 1.1)
net-ssh (>= 2.1.3)
nokogiri (~> 1.5)
ruby-hmac
formatador (0.2.4)
hiera (1.3.2)
fog-json (1.0.0)
multi_json (~> 1.0)
formatador (0.2.5)
google-api-client (0.7.1)
addressable (>= 2.3.2)
autoparse (>= 0.3.3)
extlib (>= 0.9.15)
faraday (>= 0.9.0)
jwt (>= 0.1.5)
launchy (>= 2.1.1)
multi_json (>= 1.0.0)
retriable (>= 1.4)
signet (>= 0.5.0)
uuidtools (>= 2.1.0)
hiera (1.3.4)
json_pure
highline (1.6.21)
inflecto (0.0.2)
inifile (2.0.2)
ipaddress (0.8.0)
json (1.8.1)
json_pure (1.8.1)
jwt (1.0.0)
launchy (2.4.2)
addressable (~> 2.3)
metaclass (0.0.4)
method_source (0.8.2)
mime-types (1.25.1)
minitar (0.5.4)
mocha (1.0.0)
mocha (1.1.0)
metaclass (~> 0.0.1)
multi_json (1.8.4)
net-scp (1.1.2)
multi_json (1.10.1)
multipart-post (2.0.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.8.0)
nokogiri (1.5.10)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
net-ssh (2.9.1)
nokogiri (1.5.11)
pry (0.10.0)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
puppet (3.4.3)
facter (~> 1.6)
puppet (3.6.2)
facter (> 1.6, < 3)
hiera (~> 1.0)
json_pure
rgen (~> 0.6.5)
puppet-lint (0.3.2)
puppetlabs_spec_helper (0.4.1)
mocha (>= 0.10.5)
puppetlabs_spec_helper (0.6.0)
mocha
puppet-lint
rake
rspec (>= 2.9.0)
rspec-puppet (>= 0.1.1)
rake (10.1.1)
rspec
rspec-puppet
rake (10.3.2)
rbvmomi (1.8.1)
builder
nokogiri (>= 1.4.1)
trollop
retriable (1.4.1)
rgen (0.6.6)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
rspec (2.99.0)
rspec-core (~> 2.99.0)
rspec-expectations (~> 2.99.0)
rspec-mocks (~> 2.99.0)
rspec-core (2.99.1)
rspec-expectations (2.99.1)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
rspec-puppet (0.1.6)
rspec-its (1.0.1)
rspec-core (>= 2.99.0.beta1)
rspec-expectations (>= 2.99.0.beta1)
rspec-mocks (2.99.1)
rspec-puppet (1.0.1)
rspec
ruby-hmac (0.4.0)
serverspec (0.15.3)
serverspec (1.9.1)
highline
net-ssh
rspec (>= 2.13.0)
specinfra (>= 0.5.8)
slop (3.4.7)
specinfra (0.7.0)
thor (0.18.1)
rspec (~> 2.13)
rspec-its
specinfra (~> 1.18)
signet (0.5.1)
addressable (>= 2.2.3)
faraday (>= 0.9.0.rc5)
jwt (>= 0.1.5)
multi_json (>= 1.0.0)
simplecov (0.8.2)
docile (~> 1.1.0)
multi_json
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
slop (3.5.0)
specinfra (1.20.0)
thor (0.19.1)
trollop (2.0)
unf (0.1.3)
unf (0.1.4)
unf_ext
unf_ext (0.0.6)
uuidtools (2.1.4)
PLATFORMS
ruby
@ -107,10 +171,12 @@ PLATFORMS
DEPENDENCIES
beaker
beaker-rspec
facter
pry
puppet
puppet-lint (~> 0.3.2)
puppet-lint
puppetlabs_spec_helper
rake
rspec-puppet (< 1.0)
rspec-puppet
serverspec
simplecov

View file

@ -1,13 +0,0 @@
name 'puppetlabs-postgresql'
version '3.3.3'
source 'git://github.com/puppetlabs/puppet-postgresql.git'
author 'Inkling/Puppet Labs'
description 'PostgreSQL defined resource types'
summary 'PostgreSQL defined resource types'
license 'ASL 2.0'
project_page 'https://github.com/puppetlabs/puppet-postgresql'
dependency 'puppetlabs/stdlib', '>=3.2.0 <5.0.0'
dependency 'puppetlabs/firewall', '>= 0.0.4'
dependency 'puppetlabs/apt', '>=1.1.0 <2.0.0'
dependency 'puppetlabs/concat', '>= 1.0.0 <2.0.0'

View file

@ -226,10 +226,12 @@ Classes:
* [postgresql::globals](#class-postgresqlglobals)
* [postgresql::lib::devel](#class-postgresqllibdevel)
* [postgresql::lib::java](#class-postgresqllibjava)
* [postgresql::lib::perl](#class-postgresqllibperl)
* [postgresql::lib::python](#class-postgresqllibpython)
* [postgresql::server](#class-postgresqlserver)
* [postgresql::server::plperl](#class-postgresqlserverplperl)
* [postgresql::server::contrib](#class-postgresqlservercontrib)
* [postgresql::server::postgis](#class-postgresqlserverpostgis)
Resources:
@ -288,12 +290,18 @@ This setting can be used to override the default postgresql devel package name.
####`java_package_name`
This setting can be used to override the default postgresql java package name. If not specified, the module will use whatever package name is the default for your OS distro.
####`perl_package_name`
This setting can be used to override the default postgresql Perl package name. If not specified, the module will use whatever package name is the default for your OS distro.
####`plperl_package_name`
This setting can be used to override the default postgresql PL/perl package name. If not specified, the module will use whatever package name is the default for your OS distro.
####`python_package_name`
This setting can be used to override the default postgresql Python package name. If not specified, the module will use whatever package name is the default for your OS distro.
####`service_ensure`
This setting can be used to override the default postgresql service ensure status. If not specified, the module will use `ensure` instead.
####`service_name`
This setting can be used to override the default postgresql service name. If not specified, the module will use whatever service name is the default for your OS distro.
@ -347,6 +355,9 @@ The version of PostgreSQL to install/manage. This is a simple way of providing a
Defaults to your operating system default.
####`postgis_version`
The version of PostGIS to install if you install PostGIS. Defaults to the lowest available with the version of PostgreSQL to be installed.
####`needs_initdb`
This setting can be used to explicitly call the initdb operation after server package is installed and before the postgresql service is started. If not specified, the module will decide whether to call initdb or not depending on your OS distro.
@ -372,9 +383,6 @@ The following list are options that you can set in the `config_hash` parameter o
####`ensure`
This value default to `present`. When set to `absent` it will remove all packages, configuration and data so use this with extreme caution.
####`version`
This will set the version of the PostgreSQL software to install. Defaults to your operating systems default.
####`postgres_password`
This value defaults to `undef`, meaning the super user account in the postgres database is a user called `postgres` and this account does not have a password. If you provide this setting, the module will set the password for the `postgres` user to your specified value.
@ -402,6 +410,9 @@ This setting is used to specify the name of the default database to connect with
####`listen_addresses`
This value defaults to `localhost`, meaning the postgres server will only accept connections from localhost. If you'd like to be able to connect to postgres from remote machines, you can override this setting. A value of `*` will tell postgres to accept connections from any remote machine. Alternately, you can specify a comma-separated list of hostnames or IP addresses. (For more info, have a look at the `postgresql.conf` file from your system's postgres package).
####`port`
This value defaults to `5432`, meaning the postgres server will listen on TCP port 5432. Note that the same port number is used for all IP addresses the server listens on.
####`ip_mask_deny_postgres_user`
This value defaults to `0.0.0.0/0`. Sometimes it can be useful to block the superuser account from remote connections if you are allowing other database users to connect remotely. Set this to an IP and mask for which you want to deny connections by the postgres superuser account. So, e.g., the default value of `0.0.0.0/0` will match any remote IP and deny access, so the postgres user won't be able to connect remotely at all. Conversely, a value of `0.0.0.0/32` would not match any remote IP, and thus the deny rule will not be applied and the postgres user will be allowed to connect.
@ -481,6 +492,8 @@ The name of the postgresql contrib package.
####`package_ensure`
The ensure parameter passed on to postgresql contrib package resource.
###Class: postgresql::server::postgis
Installs the postgresql postgis packages.
###Class: postgresql::lib::devel
Installs the packages containing the development libraries for PostgreSQL.
@ -502,6 +515,16 @@ The name of the postgresql java package.
The ensure parameter passed on to postgresql java package resource.
###Class: postgresql::lib::perl
This class installs the postgresql Perl libraries. For customer requirements you can customise the following parameters:
####`package_name`
The name of the postgresql perl package.
####`package_ensure`
The ensure parameter passed on to postgresql perl package resource.
###Class: postgresql::lib::python
This class installs the postgresql Python libraries. For customer requirements you can customise the following parameters:
@ -554,6 +577,9 @@ For example, to create a database called `test1` with a corresponding user of th
####`namevar`
The namevar for the resource designates the name of the database.
####`dbname`
The name of the database to be created. Defaults to `namevar`.
####`user`
User to create and assign access to the database upon creation. Mandatory.
@ -697,6 +723,9 @@ Whether to grant the ability to create new roles with this role. Defaults to `fa
####`login`
Whether to grant login capability for the new role. Defaults to `false`.
####`inherit`
Whether to grant inherit capability for the new role. Defaults to `true`.
####`superuser`
Whether to grant super user capability for the new role. Defaults to `false`.
@ -822,11 +851,24 @@ Works with versions of PostgreSQL from 8.1 through 9.2.
Current it is only actively tested with the following operating systems:
* Debian 6.x and 7.x
* Centos 5.x and 6.x
* Ubuntu 10.04 and 12.04
* Centos 5.x, 6.x, and 7.x.
* Ubuntu 10.04 and 12.04, 14.04
Although patches are welcome for making it work with other OS distros, it is considered best effort.
### Postgis support
Postgis is currently considered an unsupported feature as it doesn't work on
all platforms correctly.
### All versions of RHEL/Centos
If you have selinux enabled you must add any custom ports you use to the postgresql_port_t context. You can do this as follows:
```
# semanage port -a -t postgresql_port_t -p tcp $customport
```
Development
------------
@ -862,11 +904,11 @@ If you want to run the system tests, make sure you also have:
Then run the tests using:
bundle exec rake spec:system
bundle exec rspec spec/acceptance
To run the tests on different operating systems, see the sets available in .nodeset.yml and run the specific set with the following syntax:
RSPEC_SET=debian-607-x64 bundle exec rake spec:system
RSPEC_SET=debian-607-x64 bundle exec rspec spec/acceptance
Transfer Notice
----------------

View file

@ -0,0 +1,115 @@
{
"CHANGELOG.md": "0988b5bdb4105331ab66e5cb1903af20",
"Gemfile": "e9062e0fb5e3006b5f45f6083992cbdc",
"Gemfile.lock": "04ba92c1e89b28bb0d2b66585413a00f",
"LICENSE": "746fe83ebbf8970af0a9ea13962293e9",
"NOTICE": "d8ffc52f00e00877b45d2b77e709f69e",
"README.md": "a9ecd5d8104851cd25a93d325b2d3d4f",
"Rakefile": "c4f5c8ac6adc0eb4530c4b3d10cb7da0",
"files/RPM-GPG-KEY-PGDG": "78b5db170d33f80ad5a47863a7476b22",
"files/validate_postgresql_connection.sh": "20301932819f035492a30880f5bf335a",
"lib/puppet/parser/functions/postgresql_acls_to_resources_hash.rb": "d518a7959b950874820a3b0a7a324488",
"lib/puppet/parser/functions/postgresql_escape.rb": "2e136fcd653ab38d831c5b40806d47d1",
"lib/puppet/parser/functions/postgresql_password.rb": "820da02a888ab42357fe9bc2352b1c37",
"lib/puppet/provider/postgresql_conf/parsed.rb": "53cacac5630209bd4a4ea62433fba764",
"lib/puppet/provider/postgresql_psql/ruby.rb": "7c84a41473c41edba2c2526843c00fbf",
"lib/puppet/type/postgresql_conf.rb": "4f333138a3689f9768e7fe4bc3cde9fd",
"lib/puppet/type/postgresql_psql.rb": "9bdcc5809a2afd9c0d67d7f66f406504",
"manifests/client.pp": "f9bc3a578017fe8eb881de2255bdc023",
"manifests/globals.pp": "f4ecf66904a776116251c9c77c6582cc",
"manifests/lib/devel.pp": "94ae7eac3acf1dd3072d481eca4d2d7f",
"manifests/lib/java.pp": "6e4a2187c2b4caecad8098b46e99c8e0",
"manifests/lib/perl.pp": "5213fb4284f041fe28a22d68119f646d",
"manifests/lib/python.pp": "90736f86301c4c6401ec1180c176b616",
"manifests/params.pp": "44185cc010c3ec4c9499c5f78c214ed5",
"manifests/repo/apt_postgresql_org.pp": "5499d3c362a5297a2a63386c0157fb91",
"manifests/repo/yum_postgresql_org.pp": "e0c445f877cdb39774b735417c967d1d",
"manifests/repo.pp": "a18a5cb760dbb1e10bdd83730300c1fe",
"manifests/server/config.pp": "584bbe930bf30631bdf5c62bea2e3aea",
"manifests/server/config_entry.pp": "d7d6e532ddca64f876085721b4bf4dbb",
"manifests/server/contrib.pp": "3112bd1edbed51b68e1402027f9d53b1",
"manifests/server/database.pp": "66639c9579ae5572d1d39a03256370c1",
"manifests/server/database_grant.pp": "66e5470bb932b087b540c444ee49941b",
"manifests/server/db.pp": "796d0ca0b28c87175e42d0671f32c3ea",
"manifests/server/firewall.pp": "524f43b8d50160a6434bee347836c166",
"manifests/server/grant.pp": "b2ac20bf9fecb640c7fe6eba603d6e1b",
"manifests/server/initdb.pp": "215f84f3d9931372190d9928832e315a",
"manifests/server/install.pp": "3b67ca28ca49dc54081d859b8bad3050",
"manifests/server/passwd.pp": "197af62ecfcbd0982aa6563f2579d8bc",
"manifests/server/pg_hba_rule.pp": "f8e203ac4ea5a18ba065a47c8410f165",
"manifests/server/plperl.pp": "d6a2e2f0c93c7b543e9db64202c2e48d",
"manifests/server/postgis.pp": "4c2de08074b473a6fc6d240a3def1d03",
"manifests/server/reload.pp": "a5310d0d598c7e4c90926524bed19133",
"manifests/server/role.pp": "4e549d109b433e398a91fff402f0bff3",
"manifests/server/service.pp": "100d9026722ee7e1a1f97c3139125b6e",
"manifests/server/table_grant.pp": "7fbf5eafa4e5191b93195b07ef839bf9",
"manifests/server/tablespace.pp": "a7aca8e596fd05817957b8bb73e29336",
"manifests/server.pp": "2cbebd09a1a607fe93794534c65a49af",
"manifests/validate_db_connection.pp": "b0056a7dd2fa7a8fad3d7b7aab3a77fd",
"metadata.json": "0b22f02f59d02cb514a5222555161254",
"spec/acceptance/client_spec.rb": "5fc4174c010624f52d57ee9cefb44da7",
"spec/acceptance/common_patterns_spec.rb": "994e6117a54cbe96402a4c98686c3929",
"spec/acceptance/contrib_spec.rb": "efeaff22f5119067e0d0150edd9630e8",
"spec/acceptance/lib/devel_spec.rb": "8ff9ed46602e54b173dcd144394dddd4",
"spec/acceptance/lib/java_spec.rb": "46cec8b3fbc4a14172a4445ba351f0f8",
"spec/acceptance/lib/perl_spec.rb": "7ddfba081b4edfc68a2e72e04872578e",
"spec/acceptance/lib/python_spec.rb": "2b311428d59918c8a0bd11b0188e6af5",
"spec/acceptance/nodesets/centos-510-x64.yml": "5698f7e61292730c603e03f64fe19359",
"spec/acceptance/nodesets/centos-59-x64.yml": "57eb3e471b9042a8ea40978c467f8151",
"spec/acceptance/nodesets/centos-64-x64-pe.yml": "ec075d95760df3d4702abea1ce0a829b",
"spec/acceptance/nodesets/centos-64-x64.yml": "9cde7b5d2ab6a42366d2344c264d6bdc",
"spec/acceptance/nodesets/debian-607-x64.yml": "d566bf76f534e2af7c9a4605316d232c",
"spec/acceptance/nodesets/debian-73-x64.yml": "ba5a75e27644c48ad8f3564fb6d372a7",
"spec/acceptance/nodesets/default.yml": "9cde7b5d2ab6a42366d2344c264d6bdc",
"spec/acceptance/nodesets/ubuntu-server-10044-x64.yml": "dc0da2d2449f66c8fdae16593811504f",
"spec/acceptance/nodesets/ubuntu-server-12042-x64.yml": "78a3ee42652e26119d90aa62586565b2",
"spec/acceptance/nodesets/ubuntu-server-1404-x64.yml": "ea006afd1329a2d7a8e35d8287ec1658",
"spec/acceptance/postgresql_psql_spec.rb": "2726a4198506325845281f9540a45711",
"spec/acceptance/server/config_entry_spec.rb": "3b90a260d01ff028131d4f6eabdb354a",
"spec/acceptance/server/database_grant_spec.rb": "57fa17960e79b2d6641e148b0ad416de",
"spec/acceptance/server/database_spec.rb": "1eef2cd0b81e01b21a1cc5a715b67a14",
"spec/acceptance/server/db_spec.rb": "80b9bff843a7b5bc8b904583b6c6e99e",
"spec/acceptance/server/grant_spec.rb": "e920c215c4936f2a70ee6bcb6fed5220",
"spec/acceptance/server/pg_hba_rule_spec.rb": "12809f3d42e6c86e2de9583fab908ede",
"spec/acceptance/server/plperl_spec.rb": "c8d175b8235d0c61377866746d2d0186",
"spec/acceptance/server/role_spec.rb": "a3cd31e4245670286c1811f85ca6b266",
"spec/acceptance/server/table_grant_spec.rb": "c7f824d83745f2bcc865e69726f1db92",
"spec/acceptance/server/tablespace_spec.rb": "b367d810e2fbc219adb8bdc46dd8b99b",
"spec/acceptance/server_spec.rb": "9120d47137bccb2cd9aafa266374ed45",
"spec/acceptance/unsupported_spec.rb": "fc8f86f0843fabe29f880514db5be44d",
"spec/acceptance/validate_db_connection_spec.rb": "de172901777cb6973225348fb26a4f51",
"spec/spec_helper.rb": "6f3771a469c9ca3b050d12c19839f442",
"spec/spec_helper_acceptance.rb": "7bca3db19a6bb47a06f537914059f2ae",
"spec/unit/classes/client_spec.rb": "b26438da8906e68d17e568252c1e43b5",
"spec/unit/classes/globals_spec.rb": "acaa1c14215ce4f0b76222b9d344c379",
"spec/unit/classes/lib/devel_spec.rb": "11a2a75953d63a34b3e9ab7b6be2cc69",
"spec/unit/classes/lib/java_spec.rb": "bdb60c3b379a3788b3bf1f6c29b31c0a",
"spec/unit/classes/lib/perl_spec.rb": "efb82d3c12bbaf772a37704cb571ada5",
"spec/unit/classes/lib/python_spec.rb": "677c763c1a43a0e33ef7e6e819ec9f0a",
"spec/unit/classes/params_spec.rb": "2db946aa96446a1e38991c843b765323",
"spec/unit/classes/repo_spec.rb": "bc7e37bf56d82b0bd080391aa46c7f1d",
"spec/unit/classes/server/contrib_spec.rb": "97d0e01330e19b9657d51efb182a299f",
"spec/unit/classes/server/initdb_spec.rb": "a13e8ab43144ba4387f5fa1e14fc6552",
"spec/unit/classes/server/plperl_spec.rb": "48426f8a532690ce6ff758526b428085",
"spec/unit/classes/server/postgis_spec.rb": "b8041550a224a771c6f1c93e34f1bf87",
"spec/unit/classes/server_spec.rb": "1fef0fa2b0ee6e5b203a224dc7cc0526",
"spec/unit/defines/server/config_entry_spec.rb": "e797f48e9774031e86fdfc9687d39040",
"spec/unit/defines/server/database_grant_spec.rb": "2418cfbdb1e913f96a5ec7997526f9bf",
"spec/unit/defines/server/database_spec.rb": "cd8318b25bf775d3540fec1198efa73c",
"spec/unit/defines/server/db_spec.rb": "53ff276aca01971b0357c3cabb2e0525",
"spec/unit/defines/server/grant_spec.rb": "6d3926ed814834268defedf671d4ac96",
"spec/unit/defines/server/pg_hba_rule_spec.rb": "fd5926d6218998d96051179ae31e7d68",
"spec/unit/defines/server/role_spec.rb": "1a8d25c409b210333a50c6cedd2409c7",
"spec/unit/defines/server/table_grant_spec.rb": "ea304aedc93d7801329181f926d8106a",
"spec/unit/defines/server/tablespace_spec.rb": "e087c175bbd7ac0c2ff0ff2076db99d5",
"spec/unit/defines/validate_db_connection_spec.rb": "88e57a8f780d381d75fe062f1178e1ce",
"spec/unit/functions/postgresql_acls_to_resources_hash_spec.rb": "e7740c3cd2110e2fcebab8356012267c",
"spec/unit/functions/postgresql_escape_spec.rb": "6e52e4f3ca56491f8ba2d1490a5fd1ad",
"spec/unit/functions/postgresql_password_spec.rb": "76034569a5ff627073c5e6ff69176ac3",
"spec/unit/provider/postgresql_conf/parsed_spec.rb": "45cbf8783706d85005bd69ebfc013c09",
"spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb": "c0ef725e4e7a5def13c29fad0c42478c",
"spec/unit/puppet/type/postgresql_psql_spec.rb": "2af5b74f7f4b89ff246818cd79488b3e",
"spec/unit/type/postgresql_conf_spec.rb": "5a05106ce1fe78a40d6ff620a75c08e9",
"templates/pg_hba_rule.conf": "13b46eecdfd359eddff71fa485ef2f54",
"templates/systemd-port-override.erb": "9af958cfc89251d8b32dd27050f58826"
}

View file

@ -18,7 +18,7 @@ Puppet::Type.type(:postgresql_conf).provide(
:to_line => proc { |h|
# simple string and numeric values don't need to be enclosed in quotes
dontneedquote = h[:value].match(/^(\w+|[0-9.-]+)$/)
dontneedquote = h[:value].match(/^(\w+)$/)
dontneedequal = h[:name].match(/^(include|include_if_exists)$/i)
str = h[:name].downcase # normalize case

View file

@ -63,6 +63,7 @@ Puppet::Type.type(:postgresql_psql).provide(:ruby) do
command = [resource[:psql_path]]
command.push("-d", resource[:db]) if resource[:db]
command.push("-p", resource[:port]) if resource[:port]
command.push("-t", "-c", sql)
if resource[:cwd]

View file

@ -49,6 +49,10 @@ Puppet::Type.newtype(:postgresql_psql) do
desc "The name of the database to execute the SQL command against."
end
newparam(:port) do
desc "The port of the database server to execute the SQL command against."
end
newparam(:search_path) do
desc "The schema search path to use when executing the SQL command"
end

View file

@ -8,8 +8,10 @@ class postgresql::globals (
$contrib_package_name = undef,
$devel_package_name = undef,
$java_package_name = undef,
$perl_package_name = undef,
$plperl_package_name = undef,
$python_package_name = undef,
$postgis_package_name = undef,
$service_name = undef,
$service_provider = undef,
@ -33,6 +35,7 @@ class postgresql::globals (
$group = undef,
$version = undef,
$postgis_version = undef,
$needs_initdb = undef,
@ -56,6 +59,7 @@ class postgresql::globals (
},
'Amazon' => '9.2',
default => $::operatingsystemrelease ? {
/^7\./ => '9.2',
/^6\./ => '8.4',
/^5\./ => '8.1',
default => undef,
@ -83,12 +87,28 @@ class postgresql::globals (
default => undef,
}
$globals_version = pick($version, $default_version, 'unknown')
if($globals_version == 'unknown') {
fail('No preferred version defined or automatically detected.')
}
$default_postgis_version = $globals_version ? {
'8.1' => '1.3.6',
'8.4' => '1.5',
'9.0' => '1.5',
'9.1' => '1.5',
'9.2' => '2.0',
'9.3' => '2.1',
}
$globals_postgis_version = pick($postgis_version, $default_postgis_version)
# Setup of the repo only makes sense globally, so we are doing this here.
if($manage_package_repo) {
class { 'postgresql::repo':
ensure => $ensure,
version => $globals_version
# Workaround the lack of RHEL7 repositories for now.
if ! ($::operatingsystem == 'RedHat' and $::operatingsystemrelease =~ /^7/) {
class { 'postgresql::repo':
ensure => $ensure,
version => $globals_version
}
}
}
}

View file

@ -0,0 +1,13 @@
# This class installs the perl libs for postgresql. See README.md for more
# details.
class postgresql::lib::perl(
$package_name = $postgresql::params::perl_package_name,
$package_ensure = 'present'
) inherits postgresql::params {
package { 'perl-DBD-Pg':
ensure => $package_ensure,
name => $package_name,
}
}

View file

@ -1,16 +1,17 @@
# PRIVATE CLASS: do not use directly
class postgresql::params inherits postgresql::globals {
$ensure = true
$ensure = present
$version = $globals_version
$postgis_version = $globals_postgis_version
$listen_addresses = 'localhost'
$port = 5432
$ip_mask_deny_postgres_user = '0.0.0.0/0'
$ip_mask_allow_all_users = '127.0.0.1/32'
$ipv4acls = []
$ipv6acls = []
$user = pick($user, 'postgres')
$group = pick($group, 'postgres')
$encoding = $encoding
$locale = $locale
$service_ensure = undef
$service_provider = $service_provider
$manage_firewall = $manage_firewall
$manage_pg_hba_conf = pick($manage_pg_hba_conf, true)
@ -18,8 +19,12 @@ class postgresql::params inherits postgresql::globals {
# Amazon Linux's OS Family is 'Linux', operating system 'Amazon'.
case $::osfamily {
'RedHat', 'Linux': {
$user = pick($user, 'postgres')
$group = pick($group, 'postgres')
$needs_initdb = pick($needs_initdb, true)
$firewall_supported = pick($firewall_supported, true)
$version_parts = split($version, '[.]')
$package_version = "${version_parts[0]}${version_parts[1]}"
if $version == $default_version {
$client_package_name = pick($client_package_name, 'postgresql')
@ -36,8 +41,6 @@ class postgresql::params inherits postgresql::globals {
}
$confdir = pick($confdir, $datadir)
} else {
$version_parts = split($version, '[.]')
$package_version = "${version_parts[0]}${version_parts[1]}"
$client_package_name = pick($client_package_name, "postgresql${package_version}")
$server_package_name = pick($server_package_name, "postgresql${package_version}-server")
$contrib_package_name = pick($contrib_package_name,"postgresql${package_version}-contrib")
@ -55,7 +58,18 @@ class postgresql::params inherits postgresql::globals {
$psql_path = pick($psql_path, "${bindir}/psql")
$service_status = $service_status
$perl_package_name = pick($perl_package_name, 'perl-DBD-Pg')
$python_package_name = pick($python_package_name, 'python-psycopg2')
$postgis_package_name = pick(
$postgis_package_name,
$::operatingsystemrelease ? {
/5/ => 'postgis',
default => versioncmp($postgis_version, '2') ? {
'-1' => "postgis${package_version}",
default => "postgis2_${package_version}",}
}
)
}
'Archlinux': {
@ -64,6 +78,8 @@ class postgresql::params inherits postgresql::globals {
# so they can set it themself
$firewall_supported = pick($firewall_supported, true)
$needs_initdb = pick($needs_initdb, true)
$user = pick($user, 'postgres')
$group = pick($group, 'postgres')
# Archlinux doesn't have a client-package but has a libs package which
# pulls in postgresql server
@ -84,9 +100,13 @@ class postgresql::params inherits postgresql::globals {
$service_status = $service_status
$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')
}
'Debian': {
$user = pick($user, 'postgres')
$group = pick($group, 'postgres')
if $manage_package_repo == true {
$needs_initdb = pick($needs_initdb, true)
@ -106,8 +126,16 @@ class postgresql::params inherits postgresql::globals {
$client_package_name = pick($client_package_name, "postgresql-client-${version}")
$server_package_name = pick($server_package_name, "postgresql-${version}")
$contrib_package_name = pick($contrib_package_name, "postgresql-contrib-${version}")
$postgis_package_name = pick(
$postgis_package_name,
versioncmp($postgis_version, '2') ? {
'-1' => "postgresql-${version}-postgis",
default => "postgresql-${version}-postgis-${postgis_version}",
}
)
$devel_package_name = pick($devel_package_name, 'libpq-dev')
$java_package_name = pick($java_package_name, 'libpostgresql-jdbc-java')
$perl_package_name = pick($perl_package_name, 'libdbd-pg-perl')
$plperl_package_name = pick($plperl_package_name, "postgresql-plperl-${version}")
$python_package_name = pick($python_package_name, 'python-psycopg2')
@ -121,19 +149,22 @@ class postgresql::params inherits postgresql::globals {
}
'FreeBSD': {
$user = pick($user, 'pgsql')
$group = pick($group, 'pgsql')
$client_package_name = pick($client_package_name, "databases/postgresql${version}-client")
$server_package_name = pick($server_package_name, "databases/postgresql${version}-server")
$contrib_package_name = pick($contrib_package_name, "databases/postgresql${version}-contrib")
$devel_package_name = pick($devel_package_name, 'databases/postgresql-libpqxx3')
$java_package_name = pick($java_package_name, 'databases/postgresql-jdbc')
$perl_package_name = pick($plperl_package_name, 'databases/p5-DBD-Pg')
$plperl_package_name = pick($plperl_package_name, "databases/postgresql${version}-plperl")
$python_package_name = pick($python_package_name, 'databases/py-psycopg2')
$service_name = pick($service_name, 'postgresql')
$bindir = pick($bindir, '/usr/local/bin')
$datadir = pick($datadir, '/usr/local/pgsql/data')
$confdir = pick($confdir, '/usr/local/share/postgresql')
$confdir = pick($confdir, $datadir)
$service_status = pick($service_status, "/usr/local/etc/rc.d/${service_name} status")
$psql_path = pick($psql_path, "${bindir}/psql")
@ -168,8 +199,4 @@ class postgresql::params inherits postgresql::globals {
$pg_hba_conf_defaults = pick($pg_hba_conf_defaults, true)
$postgresql_conf_path = pick($postgresql_conf_path, "${confdir}/postgresql.conf")
$default_database = pick($default_database, 'postgres')
if($version == 'unknown') {
fail('No preferred version defined or automatically detected.')
}
}

View file

@ -1,5 +1,6 @@
# PRIVATE CLASS: do not use directly
class postgresql::repo::apt_postgresql_org inherits postgresql::repo {
include ::apt
if($ensure == 'present' or $ensure == true) {
# Here we have tried to replicate the instructions on the PostgreSQL site:
#

View file

@ -2,8 +2,6 @@
class postgresql::server (
$ensure = $postgresql::params::ensure,
$version = $postgresql::params::version,
$postgres_password = undef,
$package_name = $postgresql::params::server_package_name,
@ -12,12 +10,14 @@ class postgresql::server (
$plperl_package_name = $postgresql::params::plperl_package_name,
$service_ensure = $postgresql::params::service_ensure,
$service_name = $postgresql::params::service_name,
$service_provider = $postgresql::params::service_provider,
$service_status = $postgresql::params::service_status,
$default_database = $postgresql::params::default_database,
$listen_addresses = $postgresql::params::listen_addresses,
$port = $postgresql::params::port,
$ip_mask_deny_postgres_user = $postgresql::params::ip_mask_deny_postgres_user,
$ip_mask_allow_all_users = $postgresql::params::ip_mask_allow_all_users,
$ipv4acls = $postgresql::params::ipv4acls,
@ -44,10 +44,20 @@ class postgresql::server (
$manage_firewall = $postgresql::params::manage_firewall,
$manage_pg_hba_conf = $postgresql::params::manage_pg_hba_conf,
$firewall_supported = $postgresql::params::firewall_supported
$firewall_supported = $postgresql::params::firewall_supported,
#Deprecated
$version = $postgresql::params::version,
) inherits postgresql::params {
$pg = 'postgresql::server'
if $version != undef {
warning('Passing "version" to postgresql::server is deprecated; please use postgresql::globals instead.')
$_version = $postgresql::params::version
} else {
$_version = $version
}
if ($ensure == 'present' or $ensure == true) {
# Reload has its own ordering, specified by other defines
class { "${pg}::reload": require => Class["${pg}::install"] }

View file

@ -4,6 +4,7 @@ class postgresql::server::config {
$ip_mask_deny_postgres_user = $postgresql::server::ip_mask_deny_postgres_user
$ip_mask_allow_all_users = $postgresql::server::ip_mask_allow_all_users
$listen_addresses = $postgresql::server::listen_addresses
$port = $postgresql::server::port
$ipv4acls = $postgresql::server::ipv4acls
$ipv6acls = $postgresql::server::ipv6acls
$pg_hba_conf_path = $postgresql::server::pg_hba_conf_path
@ -19,7 +20,7 @@ class postgresql::server::config {
if ($manage_pg_hba_conf == true) {
# Prepare the main pg_hba file
concat { $pg_hba_conf_path:
owner => 0,
owner => $user,
group => $group,
mode => '0640',
warn => true,
@ -97,6 +98,18 @@ class postgresql::server::config {
postgresql::server::config_entry { 'listen_addresses':
value => $listen_addresses,
}
postgresql::server::config_entry { 'port':
value => "${port}",
}
# RedHat-based systems hardcode some PG* variables in the init script, and need to be overriden
# in /etc/sysconfig/pgsql/postgresql. Create a blank file so we can manage it with augeas later.
if ($::osfamily == 'RedHat') and ($::operatingsystemrelease !~ /^7/) {
file { '/etc/sysconfig/pgsql/postgresql':
ensure => present,
replace => false,
}
}
} else {
file { $pg_hba_conf_path:
ensure => absent,

View file

@ -11,6 +11,10 @@ define postgresql::server::config_entry (
default => $path,
}
Exec {
logoutput => 'on_failure',
}
case $name {
/data_directory|hba_file|ident_file|include|listen_addresses|port|max_connections|superuser_reserved_connections|unix_socket_directory|unix_socket_group|unix_socket_permissions|bonjour|bonjour_name|ssl|ssl_ciphers|shared_buffers|max_prepared_transactions|max_files_per_process|shared_preload_libraries|wal_level|wal_buffers|archive_mode|max_wal_senders|hot_standby|logging_collector|silent_mode|track_activity_query_size|autovacuum_max_workers|autovacuum_freeze_max_age|max_locks_per_transaction|max_pred_locks_per_transaction|restart_after_crash|lc_messages|lc_monetary|lc_numeric|lc_time/: {
Postgresql_conf {
@ -26,6 +30,52 @@ define postgresql::server::config_entry (
}
}
# We have to handle ports in a weird and special way. On Redhat we either
# have to create a systemd override for the port or update the sysconfig
# file.
if $::osfamily == 'RedHat' {
if $::operatingsystemrelease =~ /^7/ {
if $name == 'port' {
file { 'systemd-port-override':
ensure => present,
path => '/etc/systemd/system/postgresql.service',
owner => root,
group => root,
content => template('postgresql/systemd-port-override.erb'),
notify => [ Exec['restart-systemd'], Class['postgresql::server::service'] ],
before => Class['postgresql::server::reload'],
}
exec { 'restart-systemd':
command => 'systemctl daemon-reload',
refreshonly => true,
path => '/bin:/usr/bin:/usr/local/bin'
}
}
} else {
if $name == 'port' {
# We need to force postgresql to stop before updating the port
# because puppet becomes confused and is unable to manage the
# service appropriately.
exec { 'postgresql_stop':
command => "service ${::postgresql::server::service_name} stop",
onlyif => "service ${::postgresql::server::service_name} status",
unless => "grep 'PGPORT=${value}' /etc/sysconfig/pgsql/postgresql",
path => '/sbin:/bin:/usr/bin:/usr/local/bin',
require => File['/etc/sysconfig/pgsql/postgresql'],
} ->
augeas { 'override PGPORT in /etc/sysconfig/pgsql/postgresql':
lens => 'Shellvars.lns',
incl => '/etc/sysconfig/pgsql/*',
context => '/files/etc/sysconfig/pgsql/postgresql',
changes => "set PGPORT ${value}",
require => File['/etc/sysconfig/pgsql/postgresql'],
notify => Class['postgresql::server::service'],
before => Class['postgresql::server::reload'],
}
}
}
}
case $ensure {
/present|absent/: {
postgresql_conf { $name:

View file

@ -12,13 +12,16 @@ define postgresql::server::database(
$user = $postgresql::server::user
$group = $postgresql::server::group
$psql_path = $postgresql::server::psql_path
$port = $postgresql::server::port
$version = $postgresql::server::version
$default_db = $postgresql::server::default_database
# Set the defaults for the postgresql_psql resource
Postgresql_psql {
psql_user => $user,
psql_group => $group,
psql_path => $psql_path,
port => $port,
}
# Optionally set the locale switch. Older versions of createdb may not accept
@ -44,11 +47,13 @@ define postgresql::server::database(
default => "--tablespace='${tablespace}' ",
}
$createdb_command = "${createdb_path} --owner='${owner}' --template=${template} ${encoding_option}${locale_option}${tablespace_option} '${dbname}'"
$createdb_command = "${createdb_path} --port='${port}' --owner='${owner}' --template=${template} ${encoding_option}${locale_option}${tablespace_option} '${dbname}'"
postgresql_psql { "Check for existence of db '${dbname}'":
command => 'SELECT 1',
unless => "SELECT datname FROM pg_database WHERE datname='${dbname}'",
db => $default_db,
port => $port,
require => Class['postgresql::server::service']
}~>
exec { $createdb_command :
@ -60,13 +65,15 @@ define postgresql::server::database(
# This will prevent users from connecting to the database unless they've been
# granted privileges.
postgresql_psql {"REVOKE ${public_revoke_privilege} ON DATABASE \"${dbname}\" FROM public":
db => $user,
db => $default_db,
port => $port,
refreshonly => true,
}
Exec [ $createdb_command ]->
postgresql_psql {"UPDATE pg_database SET datistemplate = ${istemplate} WHERE datname = '${dbname}'":
unless => "SELECT datname FROM pg_database WHERE datname = '${dbname}' AND datistemplate = ${istemplate}",
db => $default_db,
}
# Build up dependencies on tablespace

View file

@ -3,6 +3,7 @@
define postgresql::server::db (
$user,
$password,
$dbname = $title,
$encoding = $postgresql::server::encoding,
$locale = $postgresql::server::locale,
$grant = 'ALL',
@ -11,13 +12,16 @@ define postgresql::server::db (
$istemplate = false,
$owner = undef
) {
postgresql::server::database { $name:
encoding => $encoding,
tablespace => $tablespace,
template => $template,
locale => $locale,
istemplate => $istemplate,
owner => $owner,
if ! defined(Postgresql::Server::Database[$dbname]) {
postgresql::server::database { $dbname:
encoding => $encoding,
tablespace => $tablespace,
template => $template,
locale => $locale,
istemplate => $istemplate,
owner => $owner,
}
}
if ! defined(Postgresql::Server::Role[$user]) {
@ -26,10 +30,12 @@ define postgresql::server::db (
}
}
postgresql::server::database_grant { "GRANT ${user} - ${grant} - ${name}":
privilege => $grant,
db => $name,
role => $user,
if ! defined(Postgresql::Server::Database_grant["GRANT ${user} - ${grant} - ${dbname}"]) {
postgresql::server::database_grant { "GRANT ${user} - ${grant} - ${dbname}":
privilege => $grant,
db => $dbname,
role => $user,
}
}
if($tablespace != undef and defined(Postgresql::Server::Tablespace[$tablespace])) {

View file

@ -3,17 +3,17 @@ class postgresql::server::firewall {
$ensure = $postgresql::server::ensure
$manage_firewall = $postgresql::server::manage_firewall
$firewall_supported = $postgresql::server::firewall_supported
$port = $postgresql::server::port
if ($manage_firewall and $firewall_supported) {
if ($ensure == 'present' or $ensure == true) {
# TODO: get rid of hard-coded port
firewall { '5432 accept - postgres':
port => '5432',
firewall { "$port accept - postgres":
port => $port,
proto => 'tcp',
action => 'accept',
}
} else {
firewall { '5432 accept - postgres':
firewall { "$port accept - postgres":
ensure => absent,
}
}

View file

@ -5,8 +5,9 @@ define postgresql::server::grant (
$privilege = undef,
$object_type = 'database',
$object_name = $db,
$psql_db = $postgresql::server::user,
$psql_user = $postgresql::server::user
$psql_db = $postgresql::server::default_database,
$psql_user = $postgresql::server::user,
$port = $postgresql::server::port
) {
$group = $postgresql::server::group
$psql_path = $postgresql::server::psql_path
@ -68,6 +69,7 @@ define postgresql::server::grant (
$grant_cmd = "GRANT ${_privilege} ON ${_object_type} \"${object_name}\" TO \"${role}\""
postgresql_psql { $grant_cmd:
db => $on_db,
port => $port,
psql_user => $psql_user,
psql_group => $group,
psql_path => $psql_path,

View file

@ -23,7 +23,7 @@ class postgresql::server::install {
# This will clean up anything we miss
exec { 'apt-get-autoremove-postgresql-client-brute':
command => "dpkg -P postgresql*",
command => 'dpkg -P postgresql*',
onlyif => "dpkg -l postgresql* | grep -e '^ii'",
logoutput => on_failure,
path => '/usr/bin:/bin:/usr/sbin/:/sbin',

View file

@ -0,0 +1,32 @@
# Install the postgis postgresql packaging. See README.md for more details.
class postgresql::server::postgis (
$package_name = $postgresql::params::postgis_package_name,
$package_ensure = 'present'
) inherits postgresql::params {
validate_string($package_name)
package { 'postgresql-postgis':
ensure => $package_ensure,
name => $package_name,
tag => 'postgresql',
}
if($package_ensure == 'present' or $package_ensure == true) {
anchor { 'postgresql::server::postgis::start': }->
Class['postgresql::server::install']->
Package['postgresql-postgis']->
Class['postgresql::server::service']->
anchor { 'postgresql::server::postgis::end': }
if $postgresql::globals::manage_package_repo {
Class['postgresql::repo'] ->
Package['postgresql-postgis']
}
} else {
anchor { 'postgresql::server::postgis::start': }->
Class['postgresql::server::service']->
Package['postgresql-postgis']->
Class['postgresql::server::install']->
anchor { 'postgresql::server::postgis::end': }
}
}

View file

@ -10,6 +10,7 @@ class postgresql::server::reload {
command => "service ${service_name} reload",
onlyif => $service_status,
refreshonly => true,
require => Class['postgresql::server::service'],
}
}
}

View file

@ -3,8 +3,10 @@ define postgresql::server::role(
$password_hash = false,
$createdb = false,
$createrole = false,
$db = $postgresql::server::user,
$db = $postgresql::server::default_database,
$port = $postgresql::server::port,
$login = true,
$inherit = true,
$superuser = false,
$replication = false,
$connection_limit = '-1',
@ -16,6 +18,7 @@ define postgresql::server::role(
$version = $postgresql::server::version
$login_sql = $login ? { true => 'LOGIN', default => 'NOLOGIN' }
$inherit_sql = $inherit ? { true => 'INHERIT', default => 'NOINHERIT' }
$createrole_sql = $createrole ? { true => 'CREATEROLE', default => 'NOCREATEROLE' }
$createdb_sql = $createdb ? { true => 'CREATEDB', default => 'NOCREATEDB' }
$superuser_sql = $superuser ? { true => 'SUPERUSER', default => 'NOSUPERUSER' }
@ -28,6 +31,7 @@ define postgresql::server::role(
Postgresql_psql {
db => $db,
port => $port,
psql_user => $psql_user,
psql_group => $psql_group,
psql_path => $psql_path,
@ -55,6 +59,10 @@ define postgresql::server::role(
unless => "SELECT rolname FROM pg_roles WHERE rolname='${username}' and rolcanlogin=${login}",
}
postgresql_psql {"ALTER ROLE \"${username}\" ${inherit_sql}":
unless => "SELECT rolname FROM pg_roles WHERE rolname='${username}' and rolinherit=${inherit}",
}
if(versioncmp($version, '9.1') >= 0) {
if $replication_sql == '' {
postgresql_psql {"ALTER ROLE \"${username}\" NOREPLICATION":

View file

@ -1,13 +1,25 @@
# PRIVATE CLASS: do not call directly
class postgresql::server::service {
$ensure = $postgresql::server::ensure
$service_ensure = $postgresql::server::service_ensure
$service_name = $postgresql::server::service_name
$service_provider = $postgresql::server::service_provider
$service_status = $postgresql::server::service_status
$user = $postgresql::server::user
$port = $postgresql::server::port
$default_database = $postgresql::server::default_database
$service_ensure = $ensure ? {
if $service_ensure {
$real_service_ensure = $service_ensure
} else {
$real_service_ensure = $ensure ? {
present => 'running',
absent => 'stopped',
default => $ensure
}
}
$service_enable = $ensure ? {
present => true,
absent => false,
default => $ensure
@ -16,15 +28,15 @@ class postgresql::server::service {
anchor { 'postgresql::server::service::begin': }
service { 'postgresqld':
ensure => $service_ensure,
ensure => $real_service_ensure,
name => $service_name,
enable => $service_ensure,
enable => $service_enable,
provider => $service_provider,
hasstatus => true,
status => $service_status,
}
if($service_ensure) {
if $real_service_ensure == 'running' {
# This blocks the class before continuing if chained correctly, making
# sure the service really is 'up' before continuing.
#
@ -33,6 +45,7 @@ class postgresql::server::service {
postgresql::validate_db_connection { 'validate_service_is_running':
run_as => $user,
database_name => $default_database,
database_port => $port,
sleep => 1,
tries => 60,
create_db_first => false,

View file

@ -5,12 +5,14 @@ define postgresql::server::table_grant(
$table,
$db,
$role,
$port = $postgresql::server::port,
$psql_db = undef,
$psql_user = undef
) {
postgresql::server::grant { "table:${name}":
role => $role,
db => $db,
port => $port,
privilege => $privilege,
object_type => 'TABLE',
object_name => $table,

View file

@ -6,12 +6,14 @@ define postgresql::server::tablespace(
) {
$user = $postgresql::server::user
$group = $postgresql::server::group
$port = $postgresql::server::port
$psql_path = $postgresql::server::psql_path
Postgresql_psql {
psql_user => $user,
psql_group => $group,
psql_path => $psql_path,
port => $port,
}
if ($owner == undef) {

View file

@ -55,7 +55,7 @@ define postgresql::validate_db_connection(
environment => $env,
logoutput => 'on_failure',
user => $run_as,
path => '/bin',
path => '/bin:/usr/bin:/usr/local/bin',
timeout => $timeout,
require => Package['postgresql-client'],
}

View file

@ -1,31 +1,43 @@
{
"name": "puppetlabs-postgresql",
"version": "3.4.0",
"author": "Inkling/Puppet Labs",
"summary": "PostgreSQL defined resource types",
"license": "ASL 2.0",
"source": "git://github.com/puppetlabs/puppet-postgresql.git",
"project_page": "https://github.com/puppetlabs/puppet-postgresql",
"issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues",
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6"
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6"
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6"
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6"
"6",
"7"
]
},
{
@ -39,28 +51,22 @@
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"10.04",
"12.04"
"12.04",
"14.04"
]
}
],
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
"version_requirement": ">= 3.2.0 < 3.4.0"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"name": "puppetlabs-postgresql",
"version": "3.3.3",
"source": "git://github.com/puppetlabs/puppet-postgresql.git",
"author": "Inkling/Puppet Labs",
"license": "ASL 2.0",
"summary": "PostgreSQL defined resource types",
"description": "PostgreSQL defined resource types",
"project_page": "https://github.com/puppetlabs/puppet-postgresql",
"dependencies": [
{
"name": "puppetlabs/stdlib",
@ -78,199 +84,5 @@
"name": "puppetlabs/concat",
"version_requirement": ">= 1.0.0 <2.0.0"
}
],
"types": [
{
"name": "postgresql_conf",
"doc": "This type allows puppet to manage postgresql.conf parameters.",
"properties": [
{
"name": "ensure",
"doc": "The basic property that the resource should be in.\n\nValid values are `present`, `absent`. "
},
{
"name": "value",
"doc": "The value to set for this parameter.\n\n"
},
{
"name": "target",
"doc": "The path to postgresql.conf\n\n"
}
],
"parameters": [
{
"name": "name",
"doc": "The postgresql parameter name to manage.\n\nValues can match `/^[\\w\\.]+$/`."
}
],
"providers": [
{
"name": "parsed",
"doc": "Set key/values in postgresql.conf."
}
]
},
{
"name": "postgresql_psql",
"doc": "",
"properties": [
{
"name": "command",
"doc": "The SQL command to execute via psql.\n\n"
}
],
"parameters": [
{
"name": "name",
"doc": "An arbitrary tag for your own reference; the name of the message.\n\n"
},
{
"name": "unless",
"doc": "An optional SQL command to execute prior to the main :command; this is generally intended to be used for idempotency, to check for the existence of an object in the database to determine whether or not the main SQL command needs to be executed at all.\n\n"
},
{
"name": "db",
"doc": "The name of the database to execute the SQL command against.\n\n"
},
{
"name": "search_path",
"doc": "The schema search path to use when executing the SQL command\n\n"
},
{
"name": "psql_path",
"doc": "The path to psql executable.\n\n"
},
{
"name": "psql_user",
"doc": "The system user account under which the psql command should be executed.\n\n"
},
{
"name": "psql_group",
"doc": "The system user group account under which the psql command should be executed.\n\n"
},
{
"name": "cwd",
"doc": "The working directory under which the psql command should be executed.\n\n"
},
{
"name": "refreshonly",
"doc": "If 'true', then the SQL will only be executed via a notify/subscribe event.\n\nValid values are `true`, `false`. "
}
],
"providers": [
{
"name": "ruby",
"doc": ""
}
]
}
],
"checksums": {
"CHANGELOG.md": "a6b64297ce9a85952614f7bdb57578fd",
"Gemfile": "1ef583c607af3c85f8a230989b1c41d9",
"Gemfile.lock": "cb6ae23a3082f56401a05db733102ef6",
"LICENSE": "746fe83ebbf8970af0a9ea13962293e9",
"Modulefile": "886e51cf26f9cd2e252b60772effff81",
"NOTICE": "d8ffc52f00e00877b45d2b77e709f69e",
"README.md": "1d43f087642b1b5252602fe73e10dc66",
"Rakefile": "c4f5c8ac6adc0eb4530c4b3d10cb7da0",
"files/RPM-GPG-KEY-PGDG": "78b5db170d33f80ad5a47863a7476b22",
"files/validate_postgresql_connection.sh": "20301932819f035492a30880f5bf335a",
"lib/puppet/parser/functions/postgresql_acls_to_resources_hash.rb": "d518a7959b950874820a3b0a7a324488",
"lib/puppet/parser/functions/postgresql_escape.rb": "2e136fcd653ab38d831c5b40806d47d1",
"lib/puppet/parser/functions/postgresql_password.rb": "820da02a888ab42357fe9bc2352b1c37",
"lib/puppet/provider/postgresql_conf/parsed.rb": "9c198422c0558faab1bedc00b68cfe45",
"lib/puppet/provider/postgresql_psql/ruby.rb": "8b651764452d8f410f72bd4bbc37d27d",
"lib/puppet/type/postgresql_conf.rb": "4f333138a3689f9768e7fe4bc3cde9fd",
"lib/puppet/type/postgresql_psql.rb": "2c1270cfed4ffb2971059846a57cf983",
"manifests/client.pp": "f9bc3a578017fe8eb881de2255bdc023",
"manifests/globals.pp": "f6840d296342f17b9e4717a8391d79f6",
"manifests/lib/devel.pp": "94ae7eac3acf1dd3072d481eca4d2d7f",
"manifests/lib/java.pp": "6e4a2187c2b4caecad8098b46e99c8e0",
"manifests/lib/python.pp": "90736f86301c4c6401ec1180c176b616",
"manifests/params.pp": "8a34fe2ef5cca6d0684bb304fa52776b",
"manifests/repo/apt_postgresql_org.pp": "ef7012ea3c5429bea11b1114183d32c3",
"manifests/repo/yum_postgresql_org.pp": "e0c445f877cdb39774b735417c967d1d",
"manifests/repo.pp": "a18a5cb760dbb1e10bdd83730300c1fe",
"manifests/server/config.pp": "ad4e6a3b034bf2975e47ac8df156eab4",
"manifests/server/config_entry.pp": "81ddbb8fe161d94394c7277a92cc6c1c",
"manifests/server/contrib.pp": "3112bd1edbed51b68e1402027f9d53b1",
"manifests/server/database.pp": "a6eacc4bf05c8ac12047dbf8aace7bc4",
"manifests/server/database_grant.pp": "66e5470bb932b087b540c444ee49941b",
"manifests/server/db.pp": "368ce3c55cb1685a7e9598a4760f0d1f",
"manifests/server/firewall.pp": "98632b073511a00926908c6951851052",
"manifests/server/grant.pp": "7f7fdf96611bfdd599dc382755c61c00",
"manifests/server/initdb.pp": "215f84f3d9931372190d9928832e315a",
"manifests/server/install.pp": "8520e3a86c74e0587a46c4548097bab3",
"manifests/server/passwd.pp": "197af62ecfcbd0982aa6563f2579d8bc",
"manifests/server/pg_hba_rule.pp": "f8e203ac4ea5a18ba065a47c8410f165",
"manifests/server/plperl.pp": "d6a2e2f0c93c7b543e9db64202c2e48d",
"manifests/server/reload.pp": "d62c048c8f25c167d266e99e36c0f227",
"manifests/server/role.pp": "a99508ee4e84034064c2cb1a121bdc62",
"manifests/server/service.pp": "8db858d1ea5b778cfef00e6ade81abb8",
"manifests/server/table_grant.pp": "bbc864f0ad8545837cf7782d1f7a1755",
"manifests/server/tablespace.pp": "beda12859757f7f677a711304dfd5185",
"manifests/server.pp": "aef6102d75512fab876195b4601e6fb3",
"manifests/validate_db_connection.pp": "be61434836f7d25cc184126a91b2e3e6",
"spec/acceptance/client_spec.rb": "5fc4174c010624f52d57ee9cefb44da7",
"spec/acceptance/common_patterns_spec.rb": "994e6117a54cbe96402a4c98686c3929",
"spec/acceptance/contrib_spec.rb": "efeaff22f5119067e0d0150edd9630e8",
"spec/acceptance/lib/devel_spec.rb": "8ff9ed46602e54b173dcd144394dddd4",
"spec/acceptance/lib/java_spec.rb": "46cec8b3fbc4a14172a4445ba351f0f8",
"spec/acceptance/lib/python_spec.rb": "2b311428d59918c8a0bd11b0188e6af5",
"spec/acceptance/nodesets/centos-510-x64.yml": "5698f7e61292730c603e03f64fe19359",
"spec/acceptance/nodesets/centos-59-x64.yml": "57eb3e471b9042a8ea40978c467f8151",
"spec/acceptance/nodesets/centos-64-x64-pe.yml": "ec075d95760df3d4702abea1ce0a829b",
"spec/acceptance/nodesets/centos-64-x64.yml": "9cde7b5d2ab6a42366d2344c264d6bdc",
"spec/acceptance/nodesets/debian-607-x64.yml": "d566bf76f534e2af7c9a4605316d232c",
"spec/acceptance/nodesets/debian-73-x64.yml": "ba5a75e27644c48ad8f3564fb6d372a7",
"spec/acceptance/nodesets/default.yml": "9cde7b5d2ab6a42366d2344c264d6bdc",
"spec/acceptance/nodesets/ubuntu-server-10044-x64.yml": "dc0da2d2449f66c8fdae16593811504f",
"spec/acceptance/nodesets/ubuntu-server-12042-x64.yml": "78a3ee42652e26119d90aa62586565b2",
"spec/acceptance/postgresql_psql_spec.rb": "2726a4198506325845281f9540a45711",
"spec/acceptance/server/config_entry_spec.rb": "acde0cb5edfb56b276273fd7b8c9e54c",
"spec/acceptance/server/database_grant_spec.rb": "57fa17960e79b2d6641e148b0ad416de",
"spec/acceptance/server/database_spec.rb": "d52e1743f93933e2b3ccb0536fa06ae3",
"spec/acceptance/server/db_spec.rb": "9389f1688296d38b2be1b3f82f3c47ef",
"spec/acceptance/server/grant_spec.rb": "e920c215c4936f2a70ee6bcb6fed5220",
"spec/acceptance/server/pg_hba_rule_spec.rb": "12809f3d42e6c86e2de9583fab908ede",
"spec/acceptance/server/plperl_spec.rb": "c8d175b8235d0c61377866746d2d0186",
"spec/acceptance/server/role_spec.rb": "a24f1c009013b55a1994eb713526f845",
"spec/acceptance/server/table_grant_spec.rb": "c7f824d83745f2bcc865e69726f1db92",
"spec/acceptance/server/tablespace_spec.rb": "b367d810e2fbc219adb8bdc46dd8b99b",
"spec/acceptance/server_spec.rb": "b49f58a9bce516f93479b5cd59fdf755",
"spec/acceptance/unsupported_spec.rb": "dc8c697053f34c0d1f33e31fb66adf5d",
"spec/acceptance/validate_db_connection_spec.rb": "19e271901a3d782e851805cee03b2b15",
"spec/spec_helper.rb": "d4e4a9a154ada34e7f13b0d8ece0f5db",
"spec/spec_helper_acceptance.rb": "a913cd3be2a7616f42b10eb403aee79b",
"spec/unit/classes/client_spec.rb": "b26438da8906e68d17e568252c1e43b5",
"spec/unit/classes/globals_spec.rb": "ca7fab47214c69fcf4fdbb1320cc4abf",
"spec/unit/classes/lib/devel_spec.rb": "11a2a75953d63a34b3e9ab7b6be2cc69",
"spec/unit/classes/lib/java_spec.rb": "bdb60c3b379a3788b3bf1f6c29b31c0a",
"spec/unit/classes/lib/python_spec.rb": "677c763c1a43a0e33ef7e6e819ec9f0a",
"spec/unit/classes/params_spec.rb": "2db946aa96446a1e38991c843b765323",
"spec/unit/classes/repo_spec.rb": "437ec024ca8d8cbd344671ccbb879a98",
"spec/unit/classes/server/contrib_spec.rb": "16528171ee3e058c06c5fea454dc9dbc",
"spec/unit/classes/server/initdb_spec.rb": "ece63fe900c3bcdb746e03a234b550c2",
"spec/unit/classes/server/plperl_spec.rb": "d00b94c70241848babaeee45143870ae",
"spec/unit/classes/server_spec.rb": "babaac49a4e5ae918f17328d86b72249",
"spec/unit/defines/server/config_entry_spec.rb": "cc2d9d0e4508d745f85c3446ccf76eb4",
"spec/unit/defines/server/database_grant_spec.rb": "e09254037c042efa5a29ba8d777c882f",
"spec/unit/defines/server/database_spec.rb": "090e9cf334843a4dc8b3f4eadce0109b",
"spec/unit/defines/server/db_spec.rb": "9f2181b0df771f4c6adf089b788adf42",
"spec/unit/defines/server/grant_spec.rb": "b8d8f46c7c4539747ee0b797a3a1834f",
"spec/unit/defines/server/pg_hba_rule_spec.rb": "3ed69d689bf28b56a030c543e7ce6775",
"spec/unit/defines/server/role_spec.rb": "fdb53fa637ccd79f8231e15383099137",
"spec/unit/defines/server/table_grant_spec.rb": "bb794a0b15dc74e8c8fa5d4878fd3c79",
"spec/unit/defines/server/tablespace_spec.rb": "68e7b9a193475491c58485debf1be220",
"spec/unit/defines/validate_db_connection_spec.rb": "88e57a8f780d381d75fe062f1178e1ce",
"spec/unit/functions/postgresql_acls_to_resources_hash_spec.rb": "e7740c3cd2110e2fcebab8356012267c",
"spec/unit/functions/postgresql_escape_spec.rb": "6e52e4f3ca56491f8ba2d1490a5fd1ad",
"spec/unit/functions/postgresql_password_spec.rb": "76034569a5ff627073c5e6ff69176ac3",
"spec/unit/provider/postgresql_conf/parsed_spec.rb": "7295501a413d8cf99df6f40ea50a36fc",
"spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb": "c0ef725e4e7a5def13c29fad0c42478c",
"spec/unit/puppet/type/postgresql_psql_spec.rb": "2af5b74f7f4b89ff246818cd79488b3e",
"spec/unit/type/postgresql_conf_spec.rb": "76f460e0dfc90a1f38c407e5a0d4f463",
"templates/pg_hba_rule.conf": "13b46eecdfd359eddff71fa485ef2f54"
}
}
]
}

View file

@ -0,0 +1,17 @@
require 'spec_helper_acceptance'
describe 'postgresql::lib::perl:', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
after :all do
# Cleanup after tests have ran
apply_manifest("class { 'postgresql::lib::perl': package_ensure => purged }", :catch_failures => true)
end
it 'test loading class with no parameters' do
pp = <<-EOS.unindent
class { 'postgresql::lib::perl': }
EOS
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
end

View file

@ -0,0 +1,9 @@
HOSTS:
ubuntu-server-1404-x64:
roles:
- master
platform: ubuntu-14.04-64
box: puppetlabs/ubuntu-14.04-64-nocm
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -23,4 +23,22 @@ describe 'postgresql::server::config_entry:', :unless => UNSUPPORTED_PLATFORMS.i
expect(r.stderr).to eq('')
end
end
it 'should correctly set a quotes-required string' do
pp = <<-EOS.unindent
class { 'postgresql::server': }
postgresql::server::config_entry { 'log_directory':
value => '/tmp/testfile',
}
EOS
apply_manifest(pp, :catch_failures => true)
psql('--command="show all" postgres') do |r|
r.stdout.should =~ /log_directory.+\/tmp\/testfile/
r.stderr.should be_empty
r.exit_code.should == 0
end
end
end

View file

@ -27,3 +27,28 @@ describe 'postgresql::server::database:', :unless => UNSUPPORTED_PLATFORMS.inclu
end
end
end
describe 'postgresql::server::database: alternate port', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
it 'should idempotently create a db on a non-default port that we can connect to' do
begin
pp = <<-EOS.unindent
$db = 'postgresql_test_db'
class { 'postgresql::server':
port => 5433,
}
postgresql::server::database { $db: }
EOS
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
psql('--command="select datname from pg_database" --port=5433 postgresql_test_db') do |r|
expect(r.stdout).to match(/postgresql_test_db/)
expect(r.stderr).to eq('')
end
ensure
psql('--command="drop database postgresql_test_db" --port=5433 postgres')
end
end
end

View file

@ -135,4 +135,30 @@ describe 'postgresql::server::db', :unless => UNSUPPORTED_PLATFORMS.include?(fac
psql('--command="drop database postgresql_test_db" postgres')
end
end
it 'should take a dbname parameter' do
begin
pp = <<-EOS.unindent
$db = 'postgresql_test_db'
$dbname = 'postgresql_testtest_db'
class { 'postgresql::server': }
postgresql::server::db { $db:
dbname => $dbname,
user => $db,
password => postgresql_password($db, $db),
}
EOS
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
psql('--command="select datname from pg_database" postgresql_testtest_db') do |r|
expect(r.stdout).to match(/postgresql_testtest_db/)
expect(r.stderr).to eq('')
end
ensure
psql('--command="drop database postgresql_testtest_db" postgres')
end
end
end

View file

@ -85,4 +85,32 @@ describe 'postgresql::server::role:', :unless => UNSUPPORTED_PLATFORMS.include?(
expect(r.stderr).to eq('')
end
end
it 'should idempotently create a user with noinherit' do
pp = <<-EOS.unindent
$user = "postgresql_test_noinherit"
$password = "postgresql_test_noinherit"
class { 'postgresql::server': }
# Since we are not testing pg_hba or any of that, make a local user for ident auth
user { $user:
ensure => present,
}
postgresql::server::role { $user:
password_hash => $password,
inherit => false,
}
EOS
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
# Check that the user has noinherit set
psql('--command="select rolname from pg_roles where not rolinherit" postgres', 'postgresql_test_noinherit') do |r|
expect(r.stdout).to match(/postgresql_test_noinherit/)
expect(r.stderr).to eq('')
end
end
end

View file

@ -1,9 +1,38 @@
require 'spec_helper_acceptance'
# Hack around the fact that so far only Ubuntu 14.04 seems to have moved this
# file. Can revisit if everyone else gets clever.
case fact('operatingsystem')
when 'Ubuntu'
case fact('operatingsystemrelease')
when '14.04'
pghba_file = '/etc/postgresql/9.3/main/pg_hba.conf'
when '12.04'
pghba_file = '/etc/postgresql/9.1/main/pg_hba.conf'
end
when 'Debian'
case fact('operatingsystemmajrelease')
when '7'
pghba_file = '/etc/postgresql/9.1/main/pg_hba.conf'
when '6'
pghba_file = '/etc/postgresql/8.4/main/pg_hba.conf'
end
else
pghba_file = '/var/lib/pgsql/data/pg_hba.conf'
end
describe 'server:', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
after :all do
# Cleanup after tests have ran
apply_manifest("class { 'postgresql::server': ensure => absent }", :catch_failures => true)
pp = <<-EOS.unindent
class { 'postgresql::server': ensure => absent } ->
class { 'postgresql::client': package_ensure => absent }
EOS
apply_manifest(pp, :catch_failures => true)
if fact('osfamily') == 'RedHat'
shell('rpm -qa | grep postgres | xargs rpm -e')
end
end
it 'test loading class with no parameters' do
@ -19,6 +48,13 @@ describe 'server:', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily'))
it { should be_listening }
end
describe file(pghba_file) do
it { should be_file }
it { should be_owned_by 'postgres' }
it { should be_grouped_into 'postgres' }
it { should be_mode 640 }
end
describe 'setting postgres password' do
it 'should install and successfully adjust the password' do
pp = <<-EOS.unindent
@ -64,15 +100,20 @@ describe 'server without defaults:', :unless => UNSUPPORTED_PLATFORMS.include?(f
}
}
class { 'postgresql::globals':
ensure => absent,
manage_package_repo => true,
version => '9.3',
}
class { 'postgresql::server':
ensure => absent,
} ->
class { 'postgresql::client':
package_ensure => absent,
}
EOS
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq('')
apply_manifest(pp, :catch_failures => true)
if fact('osfamily') == 'RedHat'
shell('rpm -qa | grep postgres | xargs rpm -e')
end
end
it 'perform installation and create a db' do
@ -92,12 +133,11 @@ describe 'server without defaults:', :unless => UNSUPPORTED_PLATFORMS.include?(f
user => "foo1",
password => postgresql_password('foo1', 'foo1'),
}
postgresql::server::config_entry { 'port':
value => '5432',
}
EOS
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq('')
# Yum cache for yum.postgresql.org is outdated
shell('yum clean all') if fact('osfamily') == 'RedHat'
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
shell('test -d /tmp/pg_xlogs') do |r|
@ -113,11 +153,38 @@ describe 'server without defaults:', :unless => UNSUPPORTED_PLATFORMS.include?(f
end
end
context 'test deprecating non-default version of postgresql to postgresql::server' do
after :all do
pp = <<-EOS.unindent
class { 'postgresql::globals':
version => '9.3',
}
class { 'postgresql::server':
ensure => absent,
} ->
class { 'postgresql::client':
package_ensure => absent,
}
EOS
apply_manifest(pp, :catch_failures => true)
end
it 'raises a warning' do
pp = <<-EOS.unindent
class { 'postgresql::server':
ensure => absent,
version => '9.3',
}
EOS
expect(apply_manifest(pp, :catch_failures => false).stderr).to match(/Passing "version" to postgresql::server is deprecated/i)
end
end
unless ((fact('osfamily') == 'RedHat' and fact('lsbmajdistrelease') == '5') ||
fact('osfamily') == 'Debian')
context 'override locale and encoding' do
after :each do
before :each do
apply_manifest("class { 'postgresql::server': ensure => absent }", :catch_failures => true)
end
@ -162,6 +229,9 @@ describe 'server with firewall:', :unless => UNSUPPORTED_PLATFORMS.include?(fact
}
EOS
if fact('osfamily') == 'RedHat' and fact('operatingsystemmajrelease') == '5'
shell('iptables -F')
end
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
@ -186,3 +256,48 @@ describe 'server without pg_hba.conf:', :unless => UNSUPPORTED_PLATFORMS.include
end
end
end
describe 'server on alternate port:', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
after :all do
apply_manifest("class { 'postgresql::server': ensure => absent }", :catch_failures => true)
end
it 'sets up selinux' do
pp = <<-EOS
if $::osfamily == 'RedHat' and $::selinux == 'true' {
$semanage_package = $::operatingsystemmajrelease ? {
'5' => 'policycoreutils',
default => 'policycoreutils-python',
}
package { $semanage_package: ensure => installed }
exec { 'set_postgres':
command => 'semanage port -a -t postgresql_port_t -p tcp 5433',
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
subscribe => Package[$semanage_package],
refreshonly => true,
}
}
EOS
apply_manifest(pp, :catch_failures => true)
end
context 'test installing postgresql with alternate port' do
it 'perform installation and make sure it is idempotent' do
pp = <<-EOS.unindent
class { "postgresql::server":
port => 5433,
}
EOS
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe port(5433) do
it { should be_listening }
end
end
end

View file

@ -5,12 +5,12 @@ describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.incl
pp = <<-EOS
class { 'postgresql::client': }
EOS
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/does not provide defaults for osfamily/i)
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/No preferred version defined or automatically detected/i)
end
it 'should fail for server' do
pp = <<-EOS
class { 'postgresql::server': }
EOS
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/does not provide defaults for osfamily/i)
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/No preferred version defined or automatically detected/i)
end
end

View file

@ -32,12 +32,22 @@ describe 'postgresql::validate_db_connection:', :unless => UNSUPPORTED_PLATFORMS
apply_manifest(pp, :catch_failures => true)
end
it 'stops postgresql' do
# First we stop postgresql.
pp = <<-EOS
class { 'postgresql::server':
service_ensure => 'stopped',
}
EOS
apply_manifest(pp, :catch_failures => true)
end
it 'should keep retrying if database is down' do
# So first we shut the db down, then background a startup routine with a
# sleep 10 in front of it. That way the tests should continue while
# the pause and db startup happens in the background.
shell("/etc/init.d/postgresql* stop")
shell('nohup bash -c "sleep 10; /etc/init.d/postgresql* start" > /dev/null 2>&1 &')
if fact('operatingsystem') == 'RedHat' && fact('operatingsystemrelease') =~ /^7/
shell('nohup bash -c "sleep 10; systemctl start `basename /usr/lib/systemd/system/postgres*`" > /dev/null 2>&1 &')
else
shell('nohup bash -c "sleep 10; /etc/init.d/postgresql* start" > /dev/null 2>&1 &')
end
pp = <<-EOS.unindent
postgresql::validate_db_connection { 'foo':
@ -47,7 +57,6 @@ describe 'postgresql::validate_db_connection:', :unless => UNSUPPORTED_PLATFORMS
run_as => 'postgres',
}
EOS
apply_manifest(pp, :catch_failures => true)
end
@ -76,4 +85,13 @@ describe 'postgresql::validate_db_connection:', :unless => UNSUPPORTED_PLATFORMS
apply_manifest(pp, :expect_failures => true)
end
it 'starts postgresql' do
pp = <<-EOS
class { 'postgresql::server':
service_ensure => 'running',
}
EOS
apply_manifest(pp, :catch_failures => true)
end
end

View file

@ -7,15 +7,13 @@ 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]}
if ENV['STRICT_VARIABLES'] == 'yes'
Puppet.settings[:strict_variables]=true
end
end
c.after :each do

View file

@ -29,18 +29,26 @@ def shellescape(str)
return str
end
def psql(psql_cmd, user = 'postgres', exit_codes = [0], &block)
def psql(psql_cmd, user = 'postgres', exit_codes = [0,1], &block)
psql = "psql #{psql_cmd}"
shell("su #{shellescape(user)} -c #{shellescape(psql)}", :acceptable_exit_codes => exit_codes, &block)
end
unless ENV['RS_PROVISION'] == 'no'
unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no'
if hosts.first.is_pe?
install_pe
else
install_puppet
end
hosts.each do |host|
if host.is_pe?
install_pe
else
install_puppet
on host, "mkdir -p #{host['distmoduledir']}"
shell("mkdir -p #{host['distmoduledir']}")
if ! host.is_pe?
# Augeas is only used in one place, for Redhat.
if fact('osfamily') == 'RedHat'
install_package host, 'ruby-devel'
install_package host, 'augeas-devel'
install_package host, 'ruby-augeas'
end
end
end
end
@ -66,6 +74,10 @@ RSpec.configure do |c|
on host, '/usr/sbin/locale-gen'
on host, '/usr/sbin/update-locale'
end
if fact('osfamily') == 'RedHat'
shell('yum -y install policycoreutils-python')
shell('semanage port -a -t postgresql_port_t -p tcp 5433')
end
on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] }
on host, puppet('module','install','puppetlabs-firewall'), { :acceptable_exit_codes => [0,1] }
on host, puppet('module','install','puppetlabs-apt'), { :acceptable_exit_codes => [0,1] }

View file

@ -7,6 +7,7 @@ describe 'postgresql::globals', :type => :class do
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:lsbdistid => 'Debian',
:lsbdistcodename => 'squeeze',
}
end

View file

@ -0,0 +1,31 @@
require 'spec_helper'
describe 'postgresql::lib::perl', :type => :class do
describe 'on a redhat based os' do
let :facts do {
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6.4',
}
end
it { should contain_package('perl-DBD-Pg').with(
:name => 'perl-DBD-Pg',
:ensure => 'present'
)}
end
describe 'on a debian based os' do
let :facts do {
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
}
end
it { should contain_package('perl-DBD-Pg').with(
:name => 'libdbd-pg-perl',
:ensure => 'present'
)}
end
end

View file

@ -7,6 +7,7 @@ describe 'postgresql::repo', :type => :class do
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:lsbdistid => 'Debian',
:lsbdistcodename => 'squeeze',
}
end

View file

@ -12,6 +12,8 @@ describe 'postgresql::server::contrib', :type => :class do
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('contrib'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end

View file

@ -11,6 +11,9 @@ describe 'postgresql::server::initdb', :type => :class do
:operatingsystem => 'CentOS',
:operatingsystemrelease => '6.0',
:concat_basedir => tmpfilename('server'),
:kernel => 'Linux',
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
it { should contain_file('/var/lib/pgsql/data').with_ensure('directory') }
@ -20,7 +23,11 @@ describe 'postgresql::server::initdb', :type => :class do
{
:osfamily => 'RedHat',
:operatingsystem => 'Amazon',
:operatingsystemrelease => '1.0',
:concat_basedir => tmpfilename('server'),
:kernel => 'Linux',
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
it { should contain_file('/var/lib/pgsql9/data').with_ensure('directory') }

View file

@ -8,6 +8,8 @@ describe 'postgresql::server::plperl', :type => :class do
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('plperl'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end

View file

@ -0,0 +1,44 @@
require 'spec_helper'
describe 'postgresql::server::postgis', :type => :class do
let :pre_condition do
"class { 'postgresql::server': }"
end
let :facts do
{
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('postgis'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
describe 'with parameters' do
let(:params) do
{
:package_name => 'mypackage',
:package_ensure => 'absent',
}
end
it 'should create package with correct params' do
should contain_package('postgresql-postgis').with({
:ensure => 'absent',
:name => 'mypackage',
:tag => 'postgresql',
})
end
end
describe 'with no parameters' do
it 'should create package with postgresql tag' do
should contain_package('postgresql-postgis').with({
:tag => 'postgresql',
})
end
end
end

View file

@ -8,6 +8,8 @@ describe 'postgresql::server', :type => :class do
:operatingsystemrelease => '6.0',
:concat_basedir => tmpfilename('server'),
:kernel => 'Linux',
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
@ -19,6 +21,24 @@ describe 'postgresql::server', :type => :class do
end
end
describe 'service_ensure => running' do
let(:params) {{ :service_ensure => 'running' }}
it { should contain_class("postgresql::params") }
it { should contain_class("postgresql::server") }
it 'should validate connection' do
should contain_postgresql__validate_db_connection('validate_service_is_running')
end
end
describe 'service_ensure => stopped' do
let(:params) {{ :service_ensure => 'stopped' }}
it { should contain_class("postgresql::params") }
it { should contain_class("postgresql::server") }
it 'shouldnt validate connection' do
should_not contain_postgresql__validate_db_connection('validate_service_is_running')
end
end
describe 'manage_firewall => true' do
let(:params) do
{
@ -49,7 +69,7 @@ describe 'postgresql::server', :type => :class do
it 'stop the service' do
should contain_service('postgresqld').with({
:ensure => false,
:ensure => 'stopped',
})
end
@ -81,7 +101,7 @@ describe 'postgresql::server', :type => :class do
it 'should still enable the service' do
should contain_service('postgresqld').with({
:ensure => true,
:ensure => 'running',
})
end
end

View file

@ -6,6 +6,10 @@ describe 'postgresql::server::config_entry', :type => :define do
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6.4',
:kernel => 'Linux',
:concat_basedir => tmpfilename('contrib'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
@ -16,6 +20,10 @@ describe 'postgresql::server::config_entry', :type => :define do
end
context "syntax check" do
let :pre_condition do
"class {'postgresql::server':}"
end
let(:params) { { :ensure => 'present'} }
it { should contain_postgresql__server__config_entry('config_entry') }
end

View file

@ -6,6 +6,10 @@ describe 'postgresql::server::database_grant', :type => :define do
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('contrib'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
@ -21,6 +25,10 @@ describe 'postgresql::server::database_grant', :type => :define do
}
end
let :pre_condition do
"class {'postgresql::server':}"
end
it { should contain_postgresql__server__database_grant('test') }
it { should contain_postgresql__server__grant('database:test') }
end

View file

@ -6,11 +6,20 @@ describe 'postgresql::server::database', :type => :define do
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('contrib'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
let :title do
'test'
end
let :pre_condition do
"class {'postgresql::server':}"
end
it { should contain_postgresql__server__database('test') }
it { should contain_postgresql_psql("Check for existence of db 'test'") }
end

View file

@ -6,6 +6,10 @@ describe 'postgresql::server::db', :type => :define do
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('contrib'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
@ -13,16 +17,42 @@ describe 'postgresql::server::db', :type => :define do
'test'
end
let :params do
{
:user => 'test',
:password => 'test',
:owner => 'tester',
}
context 'without dbname param' do
let :params do
{
:user => 'test',
:password => 'test',
:owner => 'tester',
}
end
let :pre_condition do
"class {'postgresql::server':}"
end
it { should contain_postgresql__server__db('test') }
it { should contain_postgresql__server__database('test').with_owner('tester') }
it { should contain_postgresql__server__role('test') }
it { should contain_postgresql__server__database_grant('GRANT test - ALL - test') }
end
it { should contain_postgresql__server__db('test') }
it { should contain_postgresql__server__database('test').with_owner('tester') }
it { should contain_postgresql__server__role('test') }
it { should contain_postgresql__server__database_grant('GRANT test - ALL - test') }
context 'dbname' do
let :params do
{
:dbname => 'testtest',
:user => 'test',
:password => 'test',
:owner => 'tester',
}
end
let :pre_condition do
"class {'postgresql::server':}"
end
it { should contain_postgresql__server__database('testtest') }
end
end

View file

@ -6,6 +6,10 @@ describe 'postgresql::server::grant', :type => :define do
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('contrib'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
@ -20,5 +24,9 @@ describe 'postgresql::server::grant', :type => :define do
}
end
let :pre_condition do
"class {'postgresql::server':}"
end
it { should contain_postgresql__server__grant('test') }
end

View file

@ -6,7 +6,10 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('pg_hba'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
let :title do
@ -17,6 +20,12 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
end
context 'test template 1' do
let :pre_condition do
<<-EOS
class { 'postgresql::server': }
EOS
end
let :params do
{
:type => 'host',
@ -28,12 +37,19 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
}
end
it do
content = param('concat::fragment', 'pg_hba_rule_test', 'content')
content.should =~ /host\s+all\s+all\s+1\.1\.1\.1\/24\s+md5/
should contain_concat__fragment('pg_hba_rule_test').with({
:content => /host\s+all\s+all\s+1\.1\.1\.1\/24\s+md5/
})
end
end
context 'test template 2' do
let :pre_condition do
<<-EOS
class { 'postgresql::server': }
EOS
end
let :params do
{
:type => 'local',
@ -44,12 +60,19 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
}
end
it do
content = param('concat::fragment', 'pg_hba_rule_test', 'content')
content.should =~ /local\s+all\s+all\s+ident/
should contain_concat__fragment('pg_hba_rule_test').with({
:content => /local\s+all\s+all\s+ident/
})
end
end
context 'test template 3' do
let :pre_condition do
<<-EOS
class { 'postgresql::server': }
EOS
end
let :params do
{
:type => 'host',
@ -62,13 +85,20 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
}
end
it do
content = param('concat::fragment', 'pg_hba_rule_test', 'content')
content.should =~ /host\s+all\s+all\s+0\.0\.0\.0\/0\s+ldap\s+foo=bar/
should contain_concat__fragment('pg_hba_rule_test').with({
:content => /host\s+all\s+all\s+0\.0\.0\.0\/0\s+ldap\s+foo=bar/
})
end
end
context 'validation' do
context 'validate type test 1' do
let :pre_condition do
<<-EOS
class { 'postgresql::server': }
EOS
end
let :params do
{
:type => 'invalid',
@ -86,6 +116,12 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
end
context 'validate auth_method' do
let :pre_condition do
<<-EOS
class { 'postgresql::server': }
EOS
end
let :params do
{
:type => 'local',
@ -152,8 +188,9 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
end
it do
content = param('concat::fragment', 'pg_hba_rule_test', 'content')
content.should =~ /local\s+all\s+all\s+0\.0\.0\.0\/0\s+peer/
should contain_concat__fragment('pg_hba_rule_test').with({
:content => /local\s+all\s+all\s+0\.0\.0\.0\/0\s+peer/
})
end
end

View file

@ -6,6 +6,10 @@ describe 'postgresql::server::role', :type => :define do
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('contrib'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
@ -19,5 +23,9 @@ describe 'postgresql::server::role', :type => :define do
}
end
let :pre_condition do
"class {'postgresql::server':}"
end
it { should contain_postgresql__server__role('test') }
end

View file

@ -6,6 +6,10 @@ describe 'postgresql::server::table_grant', :type => :define do
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('table_grant'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
@ -22,6 +26,10 @@ describe 'postgresql::server::table_grant', :type => :define do
}
end
let :pre_condition do
"class {'postgresql::server':}"
end
it { should contain_postgresql__server__table_grant('test') }
it { should contain_postgresql__server__grant('table:test') }
end

View file

@ -6,6 +6,10 @@ describe 'postgresql::server::tablespace', :type => :define do
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('tablespace'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
@ -19,5 +23,9 @@ describe 'postgresql::server::tablespace', :type => :define do
}
end
let :pre_condition do
"class {'postgresql::server':}"
end
it { should contain_postgresql__server__tablespace('test') }
end

View file

@ -9,7 +9,7 @@ describe provider_class do
conf_class = Puppet::Type.type(:postgresql_conf)
provider = conf_class.provider(:parsed)
conffile = tmpfilename('postgresql.conf')
provider.any_instance.stubs(:target).returns conffile
provider.any_instance.stub(:target).and_return conffile
provider
}

View file

@ -4,8 +4,8 @@ require 'spec_helper'
describe Puppet::Type.type(:postgresql_conf) do
before do
@provider_class = described_class.provide(:simple) { mk_resource_methods }
@provider_class.stubs(:suitable?).returns true
described_class.stubs(:defaultprovider).returns @provider_class
@provider_class.stub(:suitable?).and_return true
described_class.stub(:defaultprovider).and_return @provider_class
end
describe "namevar validation" do

View file

@ -0,0 +1,3 @@
.include /lib/systemd/system/postgresql.service
[Service]
Environment=PGPORT=<%= @value %>