Set up an instance of Mastodon for Kosmos
Refs #19 Use new application cookbook, update our cookbooks
This commit is contained in:
2
cookbooks/postgresql/.foodcritic
Normal file
2
cookbooks/postgresql/.foodcritic
Normal file
@@ -0,0 +1,2 @@
|
||||
~FC037
|
||||
~FC016
|
||||
@@ -1,44 +1,197 @@
|
||||
postgresql Cookbook CHANGELOG
|
||||
=============================
|
||||
# postgresql Cookbook CHANGELOG
|
||||
|
||||
This file is used to list changes made in each version of the postgresql cookbook.
|
||||
|
||||
v4.0.0
|
||||
-----
|
||||
* Potential breaking change: Restructured default attributes to avoid compile time deriving other attribute values from value of the `node[‘postgresql’][‘version’]`
|
||||
(#313, #302, #295, #288, #280, #261, #260, #254, #248, #217, #214, #167, #143)
|
||||
* Correct issues which caused the inability to override installation version defaults
|
||||
* Correct issues which caused configuration file entries with miss matching version numbers and incorrect file system paths being defined
|
||||
* Remove method pgdgrepo_rpm_info compile time use of derived attributes case many issues
|
||||
* Use correct directory path and check for the correct not_if condition to determine if the database has been initialized
|
||||
* Ensure that correct packages are installed in all scenarios where pg gem is compiled
|
||||
* Fix errors in configuration files for unix_socket_directory and unix_socket_directories
|
||||
* Updates to test-kitchen suite configuration
|
||||
* Added more grey hair to my beard
|
||||
## v6.1.1 (2017-03-08)
|
||||
|
||||
v3.4.24
|
||||
-------
|
||||
* Corrections to address repositories signed with newer certificates that some distributions have in their default ca-certificates package
|
||||
* Updates to more accurately determine distributions service init systems adds better support for systemd systems
|
||||
* Correct how version attribute is evaluated in certain places
|
||||
* test-kitchen suite configuration corrections
|
||||
* Opensuse support
|
||||
- Fix pg gem installation on non-omnibus chef runs
|
||||
- Resolve resource cloning deprecation warnings in the ruby recipe
|
||||
- Fix issues resolving the timezone on CentOS 7 and probably other distros
|
||||
- Test with Delivery local instead of Rake
|
||||
|
||||
## v6.1.0 (2017-02-18)
|
||||
|
||||
- Fix a method name conflict that caused errors if Chef Sugar was also being used on the run list
|
||||
- Revert a previous PR that added support for Postgresql 9.6 as it introduced incorrect configuration values
|
||||
- Added Fedora 25 support for pgdg packages
|
||||
- Added RHEL 5 support for Postgresql 9.4 pgdg packages
|
||||
- Removed testing for RHEL 5 and Ubuntu 12.04 as they are scheduled for EoL in the near future
|
||||
- Improvements to Test Kitchen testing to allow more extensive testing in Travis CI
|
||||
- Fixed the client recipe on Fedora
|
||||
- Added Inspec tests for client installs
|
||||
|
||||
## v6.0.1 (2017-01-04
|
||||
|
||||
- Fix systemd unit file template
|
||||
|
||||
## v6.0.0 (2017-01-03)
|
||||
|
||||
- This cookbook now requires Chef 12.1 or later
|
||||
- Removed the dependency on the apt cookbook as this functionality is built into modern chef client releases
|
||||
- Added a new custom resource for installing extensions. This acts as a replacement for the contrib recipe with minimal backwards compatibility. You can now install / remove extensions into any database. This adds the compat_resource cookbook dependency so we can continue to support Chef 12.1-12.4, which lack custom resource support.
|
||||
- The unused get_result_orig helper has been removed. If you utilized this you'll want to move it to your own wrapper cookbook
|
||||
- Updates for compatibility with Postgresql 9.5 and 9.6
|
||||
- Fixed client package installation on openSUSE Leap 42.2
|
||||
- ca-certificates recipe has been deprecated. If ca-certificates package needs to be upgraded the user should do so prior to including this recipe. Package upgrades in community cookbooks are generally a bad idea as this bring in updated packages to production systems. The recipe currently warns if used and will be removed with the next major cookbook release.
|
||||
- Fixed RHEL platform detection in the Ruby recipe
|
||||
- systemd fixes for RHEL systems
|
||||
- Fix systemd service file include when using pgdg packages
|
||||
- Package installation now uses multi-package installs to speed up converge times
|
||||
- Added integration testing in Travis of the client recipe using a new test cookbook. This will be expanded in the future to cover server installation as well
|
||||
- Expanded the specs to test converges on multiple platforms
|
||||
|
||||
## v5.2.0 (2016-12-30)
|
||||
|
||||
- Updated contacts and links to point to Sous Chefs now
|
||||
- Added a Code of Conduct (the Chef CoC)
|
||||
- Removed duplicate platforms in the metadata
|
||||
- Fix Chef runs with local mode in the server recipe
|
||||
- Fix the ruby recipe to not fail when you specify enabling both the apt and yum repos for mixed distro environments
|
||||
- Set the postgresql data directory to 700 permissions
|
||||
- Added node['postgresql']['pg_gem']['version'] to specify the version of the pg gem to install
|
||||
- Cookstyle fixes for the latest cookstyle release
|
||||
- Removed test deps from the Gemfile. Rely on ChefDK for base testing deps instead
|
||||
|
||||
## v5.1.0 (2016-11-01)
|
||||
|
||||
- Maintenance of this cookbook has been migrated from Heavy Water to Sous Chefs - <https://sous-chefs.org/>
|
||||
- Add support for Chef-Zero (local mode)
|
||||
- Don't hardcode the UID / GID on RHEL/Amazon/Suse platforms
|
||||
- Add PGDG yum RPMs for 9.5 / 9.6
|
||||
|
||||
## v5.0.0 (2016-10-25)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
- Switched from Librarian to Berkshelf
|
||||
- Remove support for the following platforms
|
||||
|
||||
- SLES < 12
|
||||
- openSUSE < 13
|
||||
- Debian < 7
|
||||
- Ubuntu < 12.04
|
||||
- RHEL < 6
|
||||
- Amazon < 2013
|
||||
- Unsupported (EOL) Fedora releases
|
||||
|
||||
### Other changes
|
||||
|
||||
- Added support for Ubuntu 16.04
|
||||
- Loosened cookbook dependencies to not prevent pulling in the latest community cookbooks
|
||||
- Added chef_version metadata
|
||||
- Switched from rubocop to cookstyle and fix all warnings
|
||||
- Removed minitests and the minitest handler
|
||||
- Added support for opensuse / opensuseleap
|
||||
- Added support for Fedora 23/24
|
||||
- Added a chefignore file to limit the files uploaded to the chef server
|
||||
- Updated Test Kitchen config to test on modern platform releases
|
||||
- Added a Rakefile and updated Travis to test with ChefDK and that rakefile
|
||||
- Avoid installing packages included in build-essential twice in the ruby recipe
|
||||
- Require at least build-essential 2.0
|
||||
- Don't cleanup the old PPA files in the apt_pgdg_postgresql recipe anymore. These should be long gone everywhere
|
||||
- Remove logic in the apt_pgdg_postgresql recipe that made Chef fail when new distro releases came out
|
||||
- Avoid node.set deprecation warnings
|
||||
- Avoid managed_home deprecation warnings in server_redhat recipe
|
||||
|
||||
## v4.0.6
|
||||
|
||||
- Add 16.04 Xenial to the allowed list
|
||||
|
||||
## v4.0.4
|
||||
|
||||
- Add leading pound symbol on pg_hba.conf template comment line
|
||||
- Update gem install for compile_time to correct deprication warning
|
||||
- Add support Ubuntu Wily Werewolf pgdg apt repository
|
||||
- test-kitchen platforms for Centos 7.2 and Ubuntu 15.04
|
||||
- Fixes PostgreSQL version & package name defaults for EL7 distros
|
||||
- Add appropriate systemd unit file overrides for EL7 distros
|
||||
|
||||
## v4.0.2
|
||||
|
||||
- Add Code of Conduct
|
||||
- Add Rubocop
|
||||
- Clean up of syntax in many places as result of adding and evaluating Rubocop
|
||||
- Updates to test-kitchen.yml
|
||||
- added additional attribute for people who are importing pgdg packages for internal repositories
|
||||
|
||||
- `default['postgresql']['use_pgdg_packages'] = false`
|
||||
|
||||
## v4.0.0
|
||||
|
||||
**WARNING: Please read carefully through the stated changes, as they probably will break your current setup and can result in duplicate postgresql versions being installed, configuration corruption and data loss! This list might not be complete, so be careful when using the 4.x version and make sure to test it extensively before production use!**
|
||||
|
||||
When in doubt, put the following in your `Berksfile` until you are ready to upgrade:
|
||||
|
||||
```ruby
|
||||
cookbook 'postgresql', '~> 3.4.0'
|
||||
```
|
||||
|
||||
- Potential breaking change: Restructured default attributes to avoid compile time deriving other attribute values from value of the `node[‘postgresql’][‘version’]` (#313, #302, #295, #288, #280, #261, #260, #254, #248, #217, #214, #167, #143). If you specify a custom postgresql version, make sure to adapt the following attributes as well:
|
||||
|
||||
```ruby
|
||||
default['postgresql']['dir'] = "/etc/postgresql/#{node['postgresql']['version']}/main"
|
||||
default['postgresql']['client']['packages'] = [ "postgresql-client-#{node['postgresql']['version']}", 'libpq-dev' ]
|
||||
default['postgresql']['server']['packages'] = [ "postgresql-#{node['postgresql']['version']}" ]
|
||||
default['postgresql']['contrib']['packages'] = [ "postgresql-contrib-#{node['postgresql']['version']}" ]
|
||||
```
|
||||
|
||||
- Potential breaking change: SSL configuration parameters. Due to the new structuring, make sure you set all SSL attributes to `override` when specifying them in a cookbook:
|
||||
|
||||
```ruby
|
||||
override['postgresql']['config']['ssl'] = true
|
||||
override['postgresql']['config']['ssl_cert_file'] = "/path/to/cert.crt"
|
||||
override['postgresql']['config']['ssl_key_file'] = "/path/to/cert.key"
|
||||
override['postgresql']['config']['ssl_ciphers'] = "<my cipher suite>"
|
||||
```
|
||||
|
||||
- Potential breaking change: Some node attributes are now persistet in your node configuration. This affects the following attributes:
|
||||
|
||||
```json
|
||||
"config": {
|
||||
"data_directory": "/var/lib/postgresql/9.4/main",
|
||||
"hba_file": "/etc/postgresql/9.4/main/pg_hba.conf",
|
||||
"ident_file": "/etc/postgresql/9.4/main/pg_ident.conf",
|
||||
"external_pid_file": "/var/run/postgresql/9.4-main.pid",
|
||||
"unix_socket_directories": "/var/run/postgresql",
|
||||
"ssl_cert_file": "/etc/ssl/certs/ssl-cert-snakeoil.pem",
|
||||
"ssl_key_file": "/etc/ssl/private/ssl-cert-snakeoil.key"
|
||||
}
|
||||
```
|
||||
|
||||
- Potential breaking change: Parsing of attributes from node/ environment configuration. It has been reported that setting the `node['postgresql']['client']['packages']` attribute in a cookbook might result in the default version of the postgresql client package being installed alongside the required version. This might affect the server packages as well.
|
||||
- Correct issues which caused the inability to override installation version defaults
|
||||
- Correct issues which caused configuration file entries with miss matching version numbers and incorrect file system paths being defined
|
||||
- Remove method pgdgrepo_rpm_info compile time use of derived attributes case many issues
|
||||
- Use correct directory path and check for the correct not_if condition to determine if the database has been initialized
|
||||
- Ensure that correct packages are installed in all scenarios where pg gem is compiled
|
||||
- Fix errors in configuration files for unix_socket_directory and unix_socket_directories
|
||||
- Updates to test-kitchen suite configuration
|
||||
- Added more grey hair to my beard
|
||||
|
||||
## v3.4.24
|
||||
|
||||
- Corrections to address repositories signed with newer certificates that some distributions have in their default ca-certificates package
|
||||
- Updates to more accurately determine distributions service init systems adds better support for systemd systems
|
||||
- Correct how version attribute is evaluated in certain places
|
||||
- test-kitchen suite configuration corrections
|
||||
- Opensuse support
|
||||
|
||||
## v3.4.23
|
||||
|
||||
v3.4.23
|
||||
-------
|
||||
- Skipping 3.4.22 with Develop branch 3.4.23 to return to releasing cookbook from master on even numbers and develop on odd numbers.
|
||||
|
||||
v3.4.21
|
||||
-------
|
||||
## v3.4.21
|
||||
|
||||
- Use more optimistic openssl version constraint
|
||||
- Add Postgresql 9.4 package sources for RHEL platforms
|
||||
- Update testing infrastructure to address bit rot
|
||||
|
||||
v3.4.20
|
||||
-------
|
||||
- Revert [#251](https://github.com/hw-cookbooks/postgresql/pull/251), a change which caused the postgresql service to restart every Chef run.
|
||||
## v3.4.20
|
||||
|
||||
- Revert [#251](https://github.com/sous-chefs/postgresql/pull/251), a change which caused the postgresql service to restart every Chef run.
|
||||
|
||||
## v3.4.19
|
||||
|
||||
v3.4.19
|
||||
-------
|
||||
- node.save could better not be run on every chef run since it causes node.default attributes stored to the node objects to differ during a chef run and when
|
||||
- Missing attribute in docs for yum_pgdg_postgresql
|
||||
- restart postgres service immediately on config change
|
||||
@@ -50,46 +203,46 @@ v3.4.19
|
||||
- add amazon 2015
|
||||
- add rhel7 support
|
||||
|
||||
v3.4.18
|
||||
------
|
||||
## v3.4.18
|
||||
|
||||
- Revert changes from #201 with the intention of revisiting these changes as part of the next major version release.
|
||||
- Specify version constraint on openssl cookbook due to an upstream release mishap
|
||||
|
||||
v3.4.16
|
||||
------
|
||||
## v3.4.16
|
||||
|
||||
- Changed hard coded value to attribute #219
|
||||
- Correction for directory creation under debian, etc. #222
|
||||
- Fedora 20 yum support #223
|
||||
- Define version-sensitive attributes in a recipe #201
|
||||
|
||||
v3.4.14
|
||||
------
|
||||
## v3.4.14
|
||||
|
||||
- Support apt repository for Ubuntu Utopic 14.10
|
||||
- Do not try and set password on standby hosts
|
||||
|
||||
v3.4.12
|
||||
------
|
||||
## v3.4.12
|
||||
|
||||
- Create configuration templates at the appropriate time
|
||||
- If template is updated restart service changed to default of :delayed
|
||||
- Fix SSL for PostgreSQL versions < 9.2
|
||||
|
||||
v3.4.10
|
||||
-------
|
||||
## v3.4.10
|
||||
|
||||
- correct conditional error created in 3.4.8.
|
||||
|
||||
v3.4.8
|
||||
------
|
||||
## v3.4.8
|
||||
|
||||
- Correct scenario where work_mem could be set to 0 if con is greater than mem Issue #185
|
||||
- Add Centos7 suites to kitchen configuration
|
||||
|
||||
v3.4.6
|
||||
------
|
||||
## v3.4.6
|
||||
|
||||
- Don't include the pgdg recipes on the wrong machine types
|
||||
- Add missing dir /etc/sysconfig/pgsl for centos7
|
||||
- CentOS 7 package support
|
||||
|
||||
v3.4.4
|
||||
------
|
||||
## v3.4.4
|
||||
|
||||
- fix packages on SLES11SP2 and higher
|
||||
- [COOK-4737] Add flag to control database user password behavior
|
||||
- add amazon platform rpm info
|
||||
@@ -97,117 +250,117 @@ v3.4.4
|
||||
- attribute typo correction
|
||||
- correctly check and set max_connections to an integer
|
||||
|
||||
v3.4.2
|
||||
------
|
||||
## v3.4.2
|
||||
|
||||
- Changed the Gem::Installer::ExtensionBuildError to a Mixlib::ShellOut::ShellCommandFailed
|
||||
|
||||
v3.4.1
|
||||
------
|
||||
## v3.4.1
|
||||
|
||||
- Added support for Ubuntu 14.04 and Postgresql 9.3
|
||||
- Fix [COOK-3490] https://tickets.opscode.com/browse/COOK-3490
|
||||
- Fix [COOK-3490] <https://tickets.opscode.com/browse/COOK-3490>
|
||||
|
||||
v3.4.0
|
||||
------
|
||||
Updated CONTRIBUTING document.
|
||||
Refreshed test kitchen configuration.
|
||||
Merged Pull Requests: 122, 116, 104, 102, 99, 96, 93, 90.
|
||||
## v3.4.0
|
||||
|
||||
Updated CONTRIBUTING document. Refreshed test kitchen configuration. Merged Pull Requests: 122, 116, 104, 102, 99, 96, 93, 90.
|
||||
|
||||
## v3.3.4
|
||||
|
||||
v3.3.4
|
||||
------
|
||||
Testing
|
||||
|
||||
## v3.3.2
|
||||
|
||||
v3.3.2
|
||||
------
|
||||
- Testing maintainer transfer to Heavywater with Opscode as collaborator
|
||||
|
||||
## v3.3.0
|
||||
|
||||
v3.3.0
|
||||
------
|
||||
### Bug
|
||||
|
||||
- **[COOK-3851](https://tickets.opscode.com/browse/COOK-3851)** - Postgresql: reload after config change does not pick up certain configuration changes
|
||||
- **[COOK-3611](https://tickets.opscode.com/browse/COOK-3611)** - unix_socket_directory does not exists in 9.3
|
||||
- **[COOK-2954](https://tickets.opscode.com/browse/COOK-2954)** - PostgreSQL installation ignores version attribute on CentOS >= 6
|
||||
|
||||
## v3.2.0
|
||||
|
||||
v3.2.0
|
||||
------
|
||||
- [COOK-3717] Pgdg repositories improvements
|
||||
- [COOK-3756] Change postgresql.conf mode from 0600 to 0644
|
||||
|
||||
## v3.1.0
|
||||
|
||||
v3.1.0
|
||||
------
|
||||
### Improvement
|
||||
|
||||
- **[COOK-3685](https://tickets.opscode.com/browse/COOK-3685)** - Upgrade Repo Attributes for Postgresql 9.3
|
||||
- **[COOK-3597](https://tickets.opscode.com/browse/COOK-3597)** - Fix implementation of `initdb_locale` attribute for RHEL
|
||||
- **[COOK-3566](https://tickets.opscode.com/browse/COOK-3566)** - Give the user's rules more priority than the default ones in pg_hba
|
||||
- **[COOK-3553](https://tickets.opscode.com/browse/COOK-3553)** - Remove automatic `apt-get update`
|
||||
|
||||
### Bug
|
||||
|
||||
- **[COOK-3611](https://tickets.opscode.com/browse/COOK-3611)** - Remove `unix_socket_directory` (it does not exists in 9.3)
|
||||
- **[COOK-3599](https://tickets.opscode.com/browse/COOK-3599)** - Automatically add PGDG apt repo dependency on PostgreSQL version
|
||||
- **[COOK-3555](https://tickets.opscode.com/browse/COOK-3555)** - Documentation Fix
|
||||
- **[COOK-2383](https://tickets.opscode.com/browse/COOK-2383)** - Update Postgres version in attributes
|
||||
|
||||
## v3.0.4
|
||||
|
||||
v3.0.4
|
||||
------
|
||||
### Bug
|
||||
|
||||
- **[COOK-3173](https://tickets.opscode.com/browse/COOK-3173)** - Use :reload instead of :restart on conf changes
|
||||
- **[COOK-2939](https://tickets.opscode.com/browse/COOK-2939)** - Fix RedHat support
|
||||
|
||||
v3.0.2
|
||||
------
|
||||
## v3.0.2
|
||||
|
||||
### Bug
|
||||
|
||||
- [COOK-3076]: postgresql::ruby recipe error when using pgdg repositories
|
||||
|
||||
v3.0.0
|
||||
------
|
||||
## v3.0.0
|
||||
|
||||
This is a backwards-incompatible release because the Pitti PPA is deprecated and the recipe removed, replaced with the PGDG apt repository.
|
||||
|
||||
### Bug
|
||||
|
||||
- [COOK-2571]: Create helper library for pg extension detection
|
||||
- [COOK-2797]: Contrib extension contianing '-' fails to load.
|
||||
|
||||
### Improvement
|
||||
|
||||
- [COOK-2387]: Pitti Postgresql PPA is deprecated
|
||||
|
||||
### Task
|
||||
|
||||
- [COOK-3022]: update baseboxes in .kitchen.yml
|
||||
|
||||
v2.4.0
|
||||
------
|
||||
## v2.4.0
|
||||
|
||||
- [COOK-2163] - Dangerous "assign-postgres-password" in "recipes/server.rb" -- Can lock out dbadmin access
|
||||
- [COOK-2390] - Recipes to auto-generate many postgresql.conf settings, following "initdb" and "pgtune"
|
||||
- [COOK-2435] - Foodcritic fixes for postgresql cookbook
|
||||
- [COOK-2476] - Installation into database of any contrib module extensions listed in a node attribute
|
||||
|
||||
v2.2.2
|
||||
------
|
||||
- [COOK-2232] -Provide PGDG yum repo to install postgresql 9.x on
|
||||
redhat-derived distributions
|
||||
## v2.2.2
|
||||
|
||||
- [COOK-2232] -Provide PGDG yum repo to install postgresql 9.x on redhat-derived distributions
|
||||
|
||||
## v2.2.0
|
||||
|
||||
v2.2.0
|
||||
------
|
||||
- [COOK-2230] - Careful about Debian minor version numbers
|
||||
- [COOK-2231] - Fix support for postgresql 9.x in server_redhat recipe
|
||||
- [COOK-2238] - Postgresql recipe error in password check
|
||||
- [COOK-2176] - PostgreSQL cookbook in Solo mode can cause "NoMethodError: undefined method `[]' for nil:NilClass"
|
||||
- [COOK-2233] - Provide postgresql::contrib recipe to install useful server administration tools
|
||||
|
||||
v2.1.0
|
||||
------
|
||||
## v2.1.0
|
||||
|
||||
- [COOK-1872] - Allow latest PostgreSQL deb packages to be installed
|
||||
- [COOK-1961] - Postgresql config file changes with every Chef run
|
||||
- [COOK-2041] - Postgres cookbook no longer installs on OpenSuSE 11.4
|
||||
|
||||
v2.0.2
|
||||
------
|
||||
## v2.0.2
|
||||
|
||||
- [COOK-1406] - pg gem compile is unable to find libpq under Chef full stack (omnibus) installation
|
||||
|
||||
v2.0.0
|
||||
------
|
||||
## v2.0.0
|
||||
|
||||
This version is backwards incompatible with previous versions of the cookbook due to use of `platform_family`, and the refactored configuration files using node attributes. See README.md for details on how to modify configuration of PostgreSQL.
|
||||
|
||||
- [COOK-1508] - fix mixlib shellout error on SUSE
|
||||
@@ -215,11 +368,10 @@ This version is backwards incompatible with previous versions of the cookbook du
|
||||
- [COOK-1779] - Don't run apt-get update and others in ruby recipe if pg is installed
|
||||
- [COOK-1871] - Attribute driven configuration files for PostgreSQL
|
||||
- [COOK-1900] - don't assume ssl on all postgresql 8.4+ installs
|
||||
- [COOK-1901] - fail a chef-solo run when the postgres password
|
||||
attribute is not set
|
||||
- [COOK-1901] - fail a chef-solo run when the postgres password attribute is not set
|
||||
|
||||
## v1.0.0
|
||||
|
||||
v1.0.0
|
||||
------
|
||||
**Important note for this release**
|
||||
|
||||
This version no longer installs Ruby bindings in the client recipe by default. Use the ruby recipe if you'd like the RubyGem. If you'd like packages for your distribution, use them in your application's specific cookbook/recipe, or modify the client packages attribute.
|
||||
@@ -235,17 +387,17 @@ The following issues are also resolved with this release.
|
||||
- [COOK-1224] - fix undefined variable on Debian
|
||||
- [COOK-1462] - Add attribute for specifying listen address
|
||||
|
||||
v0.99.4
|
||||
------
|
||||
## v0.99.4
|
||||
|
||||
- [COOK-421] - config template is malformed
|
||||
- [COOK-956] - add make package on ubuntu/debian
|
||||
|
||||
v0.99.2
|
||||
------
|
||||
## v0.99.2
|
||||
|
||||
- [COOK-916] - use < (with float) for version comparison.
|
||||
|
||||
v0.99.0
|
||||
------
|
||||
## v0.99.0
|
||||
|
||||
- Better support for Red Hat-family platforms
|
||||
- Integration with database cookbook
|
||||
- Make sure the postgres role is updated with a (secure) password
|
||||
|
||||
22
cookbooks/postgresql/CONTRIBUTING.md
Normal file
22
cookbooks/postgresql/CONTRIBUTING.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Contributing
|
||||
|
||||
## Branches
|
||||
|
||||
### `master` branch
|
||||
|
||||
The master branch is the current comitted changes. These changes may not yet be released although we try to release often.
|
||||
|
||||
## Tags
|
||||
|
||||
All releases are tagged in git. To see the releases available to you see the changelog or the tags directly.
|
||||
|
||||
|
||||
## Pull requests
|
||||
|
||||
- <https://github.com/sous-chefs/postgresql/pulls>
|
||||
|
||||
## Issues
|
||||
|
||||
Need to report an issue? Use the github issues:
|
||||
|
||||
- <https://github.com/sous-chefs/postgresql/issues>
|
||||
@@ -1,443 +1,275 @@
|
||||
Description
|
||||
===========
|
||||
# postgresql cookbook
|
||||
|
||||
[](https://travis-ci.org/sous-chefs/postgresql) [](https://supermarket.chef.io/cookbooks/postgresql)
|
||||
|
||||
Installs and configures PostgreSQL as a client or a server.
|
||||
|
||||
Requirements
|
||||
============
|
||||
## Requirements
|
||||
|
||||
## Platforms
|
||||
### Platforms
|
||||
|
||||
* Debian, Ubuntu
|
||||
* Red Hat/CentOS/Scientific (6.0+ required) - "EL6-family"
|
||||
* Fedora
|
||||
* SUSE
|
||||
- Debian 7+
|
||||
- Ubuntu 12.04+
|
||||
- Red Hat/CentOS/Scientific (6.0+ required) - "EL6-family"
|
||||
- Fedora
|
||||
- SLES 12+
|
||||
- openSUSE 13+ / openSUSE Leap
|
||||
|
||||
Tested on:
|
||||
### Chef
|
||||
|
||||
* Ubuntu 12.04, 14.04, 14.10
|
||||
* Red Hat 6.1, Scientific 6.1, CentOS 6.3, 7.0, OpenSuse
|
||||
- Chef 12.1+
|
||||
|
||||
## Cookbooks
|
||||
### Cookbooks
|
||||
|
||||
Requires Opscode's `openssl` cookbook for secure password generation.
|
||||
- `compat_resource`
|
||||
- `openssl`
|
||||
- `build-essential`
|
||||
|
||||
Requires a C compiler and development headers in order to build the
|
||||
`pg` RubyGem to provide Ruby bindings in the `ruby` recipe.
|
||||
## Attributes
|
||||
|
||||
Opscode's `build-essential` cookbook provides this functionality on
|
||||
Debian, Ubuntu, and EL6-family.
|
||||
The following attributes are set based on the platform, see the `attributes/default.rb` file for default values.
|
||||
|
||||
While not required, Opscode's `database` cookbook contains resources
|
||||
and providers that can interact with a PostgreSQL database. This
|
||||
cookbook is a dependency of database.
|
||||
- `node['postgresql']['version']` - version of postgresql to manage
|
||||
- `node['postgresql']['dir']` - home directory of where postgresql data and configuration lives.
|
||||
- `node['postgresql']['client']['packages']` - An array of package names that should be installed on "client" systems.
|
||||
- `node['postgresql']['server']['packages']` - An array of package names that should be installed on "server" systems.
|
||||
- `node['postgresql']['server']['config_change_notify']` - Type of notification triggered when a config file changes.
|
||||
- `node['postgresql']['contrib']['packages']` - An array of package names that could be installed on "server" systems for useful sysadmin tools.
|
||||
- `node['postgresql']['enable_pgdg_apt']` - Whether to enable the apt repo by the PostgreSQL Global Development Group, which contains newer versions of PostgreSQL.
|
||||
- `node['postgresql']['enable_pgdg_yum']` - Whether to enable the yum repo by the PostgreSQL Global Development Group, which contains newer versions of PostgreSQL.
|
||||
- `node['postgresql']['initdb_locale']` - Sets the default locale for the database cluster. If this attribute is not specified, the locale is inherited from the environment that initdb runs in. Sometimes you must have a system locale that is not what you want for your database cluster, and this attribute addresses that scenario. Valid only for EL-family distros (RedHat/Centos/etc.).
|
||||
|
||||
Attributes
|
||||
==========
|
||||
The following attributes are generated in `recipe[postgresql::server]`.
|
||||
|
||||
The following attributes are set based on the platform, see the
|
||||
`attributes/default.rb` file for default values.
|
||||
## Configuration
|
||||
|
||||
* `node['postgresql']['version']` - version of postgresql to manage
|
||||
* `node['postgresql']['dir']` - home directory of where postgresql
|
||||
data and configuration lives.
|
||||
The `postgresql.conf` and `pg_hba.conf` files are dynamically generated from attributes. Each key in `node['postgresql']['config']` is a postgresql configuration directive, and will be rendered in the config file. For example, the attribute:
|
||||
|
||||
* `node['postgresql']['client']['packages']` - An array of package names
|
||||
that should be installed on "client" systems.
|
||||
* `node['postgresql']['server']['packages']` - An array of package names
|
||||
that should be installed on "server" systems.
|
||||
* `node['postgresql']['server']['config_change_notify']` - Type of
|
||||
notification triggered when a config file changes.
|
||||
* `node['postgresql']['contrib']['packages']` - An array of package names
|
||||
that could be installed on "server" systems for useful sysadmin tools.
|
||||
|
||||
* `node['postgresql']['enable_pgdg_apt']` - Whether to enable the apt repo
|
||||
by the PostgreSQL Global Development Group, which contains newer versions
|
||||
of PostgreSQL.
|
||||
|
||||
* `node['postgresql']['enable_pgdg_yum']` - Whether to enable the yum repo
|
||||
by the PostgreSQL Global Development Group, which contains newer versions
|
||||
of PostgreSQL.
|
||||
|
||||
* `node['postgresql']['initdb_locale']` - Sets the default locale for the
|
||||
database cluster. If this attribute is not specified, the locale is
|
||||
inherited from the environment that initdb runs in. Sometimes you must
|
||||
have a system locale that is not what you want for your database cluster,
|
||||
and this attribute addresses that scenario. Valid only for EL-family
|
||||
distros (RedHat/Centos/etc.).
|
||||
|
||||
The following attributes are generated in
|
||||
`recipe[postgresql::server]`.
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
The `postgresql.conf` and `pg_hba.conf` files are dynamically
|
||||
generated from attributes. Each key in `node['postgresql']['config']`
|
||||
is a postgresql configuration directive, and will be rendered in the
|
||||
config file. For example, the attribute:
|
||||
|
||||
node['postgresql']['config']['listen_addresses'] = 'localhost'
|
||||
```ruby
|
||||
node['postgresql']['config']['listen_addresses'] = 'localhost'
|
||||
```
|
||||
|
||||
Will result in the following line in the `postgresql.conf` file:
|
||||
|
||||
listen_addresses = 'localhost'
|
||||
```ruby
|
||||
listen_addresses = 'localhost'
|
||||
```
|
||||
|
||||
The attributes file contains default values for Debian and RHEL
|
||||
platform families (per the `node['platform_family']`). These defaults
|
||||
have disparity between the platforms because they were originally
|
||||
extracted from the postgresql.conf files in the previous version of
|
||||
this cookbook, which differed in their default config. The resulting
|
||||
configuration files will be the same as before, but the content will
|
||||
be dynamically rendered from the attributes. The helpful commentary
|
||||
will no longer be present. You should consult the PostgreSQL
|
||||
documentation for specific configuration details.
|
||||
The attributes file contains default values for Debian and RHEL platform families (per the `node['platform_family']`). These defaults have disparity between the platforms because they were originally extracted from the postgresql.conf files in the previous version of this cookbook, which differed in their default config. The resulting configuration files will be the same as before, but the content will be dynamically rendered from the attributes. The helpful commentary will no longer be present. You should consult the PostgreSQL documentation for specific configuration details.
|
||||
|
||||
See __Recipes__ `config_initdb` and `config_pgtune` below to
|
||||
auto-generate many postgresql.conf settings.
|
||||
See **Recipes** `config_initdb` and `config_pgtune` below to auto-generate many postgresql.conf settings.
|
||||
|
||||
For values that are "on" or "off", they should be specified as literal
|
||||
`true` or `false`. String values will be used with single quotes. Any
|
||||
configuration option set to the literal `nil` will be skipped
|
||||
entirely. All other values (e.g., numeric literals) will be used as
|
||||
is. So for example:
|
||||
For values that are "on" or "off", they should be specified as literal `true` or `false`. String values will be used with single quotes. Any configuration option set to the literal `nil` will be skipped entirely. All other values (e.g., numeric literals) will be used as is. So for example:
|
||||
|
||||
node.default['postgresql']['config']['logging_collector'] = true
|
||||
node.default['postgresql']['config']['datestyle'] = 'iso, mdy'
|
||||
node.default['postgresql']['config']['ident_file'] = nil
|
||||
node.default['postgresql']['config']['port'] = 5432
|
||||
```ruby
|
||||
node.default['postgresql']['config']['logging_collector'] = true
|
||||
node.default['postgresql']['config']['datestyle'] = 'iso, mdy'
|
||||
node.default['postgresql']['config']['ident_file'] = nil
|
||||
node.default['postgresql']['config']['port'] = 5432
|
||||
```
|
||||
|
||||
Will result in the following config lines:
|
||||
|
||||
logging_collector = 'on'
|
||||
datestyle = 'iso,mdy'
|
||||
port = 5432
|
||||
```ruby
|
||||
logging_collector = 'on'
|
||||
datestyle = 'iso,mdy'
|
||||
port = 5432
|
||||
```
|
||||
|
||||
(no line printed for `ident_file` as it is `nil`)
|
||||
|
||||
Note that the `unix_socket_directory` configuration was renamed to
|
||||
`unix_socket_directories` in Postgres 9.3 so make sure to use the
|
||||
`node['postgresql']['unix_socket_directories']` attribute instead of
|
||||
`node['postgresql']['unix_socket_directory']`.
|
||||
Note that the `unix_socket_directory` configuration was renamed to `unix_socket_directories` in Postgres 9.3 so make sure to use the `node['postgresql']['unix_socket_directories']` attribute instead of `node['postgresql']['unix_socket_directory']`.
|
||||
|
||||
The `pg_hba.conf` file is dynamically generated from the
|
||||
`node['postgresql']['pg_hba']` attribute. This attribute must be an
|
||||
array of hashes, each hash containing the authorization data. As it is
|
||||
an array, you can append to it in your own recipes. The hash keys in
|
||||
the array must be symbols. Each hash will be written as a line in
|
||||
`pg_hba.conf`. For example, this entry from
|
||||
`node['postgresql']['pg_hba']`:
|
||||
The `pg_hba.conf` file is dynamically generated from the `node['postgresql']['pg_hba']` attribute. This attribute must be an array of hashes, each hash containing the authorization data. As it is an array, you can append to it in your own recipes. The hash keys in the array must be symbols. Each hash will be written as a line in `pg_hba.conf`. For example, this entry from `node['postgresql']['pg_hba']`:
|
||||
|
||||
[{:comment => '# Optional comment',
|
||||
:type => 'local', :db => 'all', :user => 'postgres', :addr => nil, :method => 'md5'}]
|
||||
```
|
||||
[{:comment => '# Optional comment',
|
||||
:type => 'local', :db => 'all', :user => 'postgres', :addr => nil, :method => 'md5'}]
|
||||
```
|
||||
|
||||
Will result in the following line in `pg_hba.conf`:
|
||||
|
||||
# Optional comment
|
||||
local all postgres md5
|
||||
```
|
||||
# Optional comment
|
||||
local all postgres md5
|
||||
```
|
||||
|
||||
Use `nil` if the CIDR-ADDRESS should be empty (as above).
|
||||
Don't provide a comment if none is desired in the `pg_hba.conf` file.
|
||||
Use `nil` if the CIDR-ADDRESS should be empty (as above). Don't provide a comment if none is desired in the `pg_hba.conf` file.
|
||||
|
||||
Note that the following authorization rule is supplied automatically by
|
||||
the cookbook template. The cookbook needs this to execute SQL in the
|
||||
PostgreSQL server without supplying the clear-text password (which isn't
|
||||
known by the cookbook). Therefore, your `node['postgresql']['pg_hba']`
|
||||
attributes don't need to specify this authorization rule:
|
||||
Note that the following authorization rule is supplied automatically by the cookbook template. The cookbook needs this to execute SQL in the PostgreSQL server without supplying the clear-text password (which isn't known by the cookbook). Therefore, your `node['postgresql']['pg_hba']` attributes don't need to specify this authorization rule:
|
||||
|
||||
# "local" is for Unix domain socket connections only
|
||||
local all all ident
|
||||
```
|
||||
# "local" is for Unix domain socket connections only
|
||||
local all all ident
|
||||
```
|
||||
|
||||
(By the way, the template uses `peer` instead of `ident` for PostgreSQL-9.1
|
||||
and above, which has the same effect.)
|
||||
(By the way, the template uses `peer` instead of `ident` for PostgreSQL-9.1 and above, which has the same effect.)
|
||||
|
||||
Recipes
|
||||
=======
|
||||
## Recipes
|
||||
|
||||
default
|
||||
-------
|
||||
### default
|
||||
|
||||
Includes the client recipe.
|
||||
|
||||
client
|
||||
------
|
||||
### client
|
||||
|
||||
Installs the packages defined in the
|
||||
`node['postgresql']['client']['packages']` attribute.
|
||||
Installs the packages defined in the `node['postgresql']['client']['packages']` attribute.
|
||||
|
||||
ruby
|
||||
----
|
||||
### ruby
|
||||
|
||||
Install the `pg` gem under Chef's Ruby environment so it can be used
|
||||
in other recipes. The build-essential packages and postgresql client
|
||||
packages will be installed during the compile phase, so that the
|
||||
native extensions of `pg` can be compiled.
|
||||
Install the `pg` gem under Chef's Ruby environment so it can be used in other recipes. The build-essential packages and postgresql client packages will be installed during the compile phase, so that the native extensions of `pg` can be compiled.
|
||||
|
||||
server
|
||||
------
|
||||
### server
|
||||
|
||||
Includes the `server_debian` or `server_redhat` recipe to get the
|
||||
appropriate server packages installed and service managed. Also
|
||||
manages the configuration for the server:
|
||||
Includes the `server_debian` or `server_redhat` recipe to get the appropriate server packages installed and service managed. Also manages the configuration for the server:
|
||||
|
||||
* generates a strong default password (via `openssl`) for `postgres`
|
||||
* sets the password for postgres
|
||||
* manages the `postgresql.conf` file.
|
||||
* manages the `pg_hba.conf` file.
|
||||
- generates a strong default password (via `openssl`) for `postgres`
|
||||
- sets the password for postgres
|
||||
- manages the `postgresql.conf` file.
|
||||
- manages the `pg_hba.conf` file.
|
||||
|
||||
server\_debian
|
||||
--------------
|
||||
### config_initdb
|
||||
|
||||
Installs the postgresql server packages and sets up the service. You
|
||||
should include the `postgresql::server` recipe, which will include
|
||||
this on Debian platforms.
|
||||
Takes locale and timezone settings from the system configuration. This recipe creates `node.default['postgresql']['config']` attributes that conform to the system's locale and timezone. In addition, this recipe creates the same error reporting and logging settings that `initdb` provided: a rotation of 7 days of log files named postgresql-Mon.log, etc.
|
||||
|
||||
server\_redhat
|
||||
--------------
|
||||
The default attributes created by this recipe are easy to override with normal attributes because of Chef attribute precedence. For example, suppose a DBA wanted to keep log files indefinitely, rolling over daily or when growing to 10MB. The Chef installation could include the `postgresql::config_initdb` recipe for the locale and timezone settings, but customize the logging settings with these node JSON attributes:
|
||||
|
||||
Manages the postgres user and group (with UID/GID 26, per RHEL package
|
||||
conventions), installs the postgresql server packages, initializes the
|
||||
database, and manages the postgresql service. You should include the
|
||||
`postgresql::server` recipe, which will include this on RHEL/Fedora
|
||||
platforms.
|
||||
```javascript
|
||||
"postgresql": {
|
||||
"config": {
|
||||
"log_rotation_age": "1d",
|
||||
"log_rotation_size": "10MB",
|
||||
"log_filename": "postgresql-%Y-%m-%d_%H%M%S.log"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
config\_initdb
|
||||
--------------
|
||||
Credits: This `postgresql::config_initdb` recipe is based on algorithms in the [source code](http://doxygen.postgresql.org/initdb_8c_source.html) for the PostgreSQL `initdb` utility.
|
||||
|
||||
Takes locale and timezone settings from the system configuration.
|
||||
This recipe creates `node.default['postgresql']['config']` attributes
|
||||
that conform to the system's locale and timezone. In addition, this
|
||||
recipe creates the same error reporting and logging settings that
|
||||
`initdb` provided: a rotation of 7 days of log files named
|
||||
postgresql-Mon.log, etc.
|
||||
### config_pgtune
|
||||
|
||||
The default attributes created by this recipe are easy to override with
|
||||
normal attributes because of Chef attribute precedence. For example,
|
||||
suppose a DBA wanted to keep log files indefinitely, rolling over daily
|
||||
or when growing to 10MB. The Chef installation could include the
|
||||
`postgresql::config_initdb` recipe for the locale and timezone settings,
|
||||
but customize the logging settings with these node JSON attributes:
|
||||
Performance tuning. Takes the wimpy default postgresql.conf and expands the database server to be as powerful as the hardware it's being deployed on. This recipe creates a baseline configuration of `node.default['postgresql']['config']` attributes in the right general range for a dedicated Postgresql system. Most installations won't need additional performance tuning.
|
||||
|
||||
"postgresql": {
|
||||
"config": {
|
||||
"log_rotation_age": "1d",
|
||||
"log_rotation_size": "10MB",
|
||||
"log_filename": "postgresql-%Y-%m-%d_%H%M%S.log"
|
||||
}
|
||||
The only decision you need to make is to choose a `db_type` from the following database workloads. (See the recipe code comments for more detailed descriptions.)
|
||||
|
||||
- "dw" -- Data Warehouse
|
||||
- "oltp" -- Online Transaction Processing
|
||||
- "web" -- Web Application
|
||||
- "mixed" -- Mixed DW and OLTP characteristics
|
||||
- "desktop" -- Not a dedicated database
|
||||
|
||||
This recipe uses a performance model with three input parameters. These node attributes are completely optional, but it is obviously important to choose the `db_type` correctly:
|
||||
|
||||
- `node['postgresql']['config_pgtune']['db_type']` -- Specifies database type from the list of five choices above. If not specified, the default is "mixed".
|
||||
|
||||
- `node['postgresql']['config_pgtune']['max_connections']` -- Specifies maximum number of connections expected. If not specified, it depends on database type: "web":200, "oltp":300, "dw":20, "mixed":80, "desktop":5
|
||||
|
||||
- `node['postgresql']['config_pgtune']['total_memory']` -- Specifies total system memory in kB. (E.g., "49416564kB".) If not specified, it will be taken from Ohai automatic attributes. This could be used to tune a system that isn't a dedicated database.
|
||||
|
||||
The default attributes created by this recipe are easy to override with normal attributes because of Chef attribute precedence. For example, if you are running application benchmarks to try different buffer cache sizes, you would experiment with this node JSON attribute:
|
||||
|
||||
```javascript
|
||||
"postgresql": {
|
||||
"config": {
|
||||
"shared_buffers": "3GB"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Note that the recipe uses `max_connections` in its computations. If you want to override that setting, you should specify `node['postgresql']['config_pgtune']['max_connections']` instead of `node['postgresql']['config']['max_connections']`.
|
||||
|
||||
Credits: This `postgresql::config_pgtune` recipe is based on the [pgtune python script](https://github.com/gregs1104/pgtune) developed by [Greg Smith](http://notemagnet.blogspot.com/2008/11/automating-initial-postgresqlconf.html) and [other pgsql-hackers](http://www.postgresql.org/message-id/491C6CDC.8090506@agliodbs.com).
|
||||
|
||||
### contrib
|
||||
|
||||
Installs the packages defined in the `node['postgresql']['contrib']['packages']` attribute. The contrib directory of the PostgreSQL distribution includes porting tools, analysis utilities, and plug-in features that database engineers often require. Some (like `pgbench`) are executable. Others (like `pg_buffercache`) would need to be installed into the database.
|
||||
|
||||
Also installs any contrib module extensions defined in the `node['postgresql']['contrib']['extensions']` attribute. These will be available in any subsequently created databases in the cluster, because they will be installed into the `template1` database using the `CREATE EXTENSION` command. For example, it is often necessary/helpful for problem troubleshooting and maintenance planning to install the views and functions in these [standard instrumentation extensions] ([http://www.postgresql.org/message-id/flat/4DC32600.6080900@pgexperts.com#4DD3D6C6.5060006@2ndquadrant.com](mailto:http://www.postgresql.org/message-id/flat/4DC32600.6080900@pgexperts.com#4DD3D6C6.5060006@2ndquadrant.com)):
|
||||
|
||||
```ruby
|
||||
node['postgresql']['contrib']['extensions'] = [
|
||||
"pageinspect",
|
||||
"pg_buffercache",
|
||||
"pg_freespacemap",
|
||||
"pgrowlocks",
|
||||
"pg_stat_statements",
|
||||
"pgstattuple"
|
||||
]
|
||||
```
|
||||
|
||||
Note that the `pg_stat_statements` view only works if `postgresql.conf` loads its shared library, which can be done with this node attribute:
|
||||
|
||||
```ruby
|
||||
node['postgresql']['config']['shared_preload_libraries'] = 'pg_stat_statements'
|
||||
```
|
||||
|
||||
If using `shared_preload_libraries` in combination with the `contrib` recipe, make sure that the `contrib` recipe is called before the `server` recipe (to ensure the dependencies are installed and setup in order).
|
||||
|
||||
### apt_pgdg_postgresql
|
||||
|
||||
Enables the PostgreSQL Global Development Group yum repository maintained by Devrim Gündüz for updated PostgreSQL packages. (The PGDG is the groups that develops PostgreSQL.) Automatically included if the `node['postgresql']['enable_pgdg_apt']` attribute is true. Also set the `node['postgresql']['client']['packages']` and `node['postgresql']['server]['packages']` to the list of packages to use from this repository, and set the `node['postgresql']['version']` attribute to the version to use (e.g., "9.2").
|
||||
|
||||
### yum_pgdg_postgresql
|
||||
|
||||
Enables the PostgreSQL Global Development Group yum repository maintained by Devrim Gündüz for updated PostgreSQL packages. (The PGDG is the groups that develops PostgreSQL.) Automatically included if the `node['postgresql']['enable_pgdg_yum']` attribute is true. Also use `override_attributes` to set a number of values that will need to have embedded version numbers. For example:
|
||||
|
||||
```ruby
|
||||
node['postgresql']['enable_pgdg_yum'] = true
|
||||
node['postgresql']['version'] = "9.4"
|
||||
node['postgresql']['dir'] = "/var/lib/pgsql/9.4/data"
|
||||
node['postgresql']['config']['data_directory'] = node['postgresql']['dir']
|
||||
node['postgresql']['client']['packages'] = ["postgresql94", "postgresql94-devel"]
|
||||
node['postgresql']['server']['packages'] = ["postgresql94-server"]
|
||||
node['postgresql']['server']['service_name'] = "postgresql-9.4"
|
||||
node['postgresql']['contrib']['packages'] = ["postgresql94-contrib"]
|
||||
node['postgresql']['setup_script'] = "postgresql94-setup"
|
||||
```
|
||||
|
||||
You may set `node['postgresql']['pgdg']['repo_rpm_url']` attributes to pick up recent [PGDG repo packages](http://yum.postgresql.org/repopackages.php).
|
||||
|
||||
## Usage
|
||||
|
||||
On systems that need to connect to a PostgreSQL database, add to a run list `recipe[postgresql]` or `recipe[postgresql::client]`.
|
||||
|
||||
On systems that should be PostgreSQL servers, use `recipe[postgresql::server]` on a run list. This recipe does set a password for the `postgres` user. If you're using `chef server`, if the attribute `node['postgresql']['password']['postgres']` is not found, the recipe generates a random password and performs a node.save. (TODO: This is broken, as it disables the password.) If you're using `chef-solo`, you'll need to set the attribute `node['postgresql']['password']['postgres']` in your node's `json_attribs` file or in a role.
|
||||
|
||||
On Debian family systems, SSL will be enabled, as the packages on Debian/Ubuntu also generate the SSL certificates. If you use another platform and wish to use SSL in postgresql, then generate your SSL certificates and distribute them in your own cookbook, and set the `node['postgresql']['config']['ssl']` attribute to true in your role/cookboook/node.
|
||||
|
||||
On server systems, the postgres server is restarted when a configuration file changes. This can be changed to reload only by setting the following attribute:
|
||||
|
||||
```ruby
|
||||
node['postgresql']['server']['config_change_notify'] = :reload
|
||||
```
|
||||
|
||||
## Chef Solo Note
|
||||
|
||||
The following node attribute is stored on the Chef Server when using `chef-client`. Because `chef-solo` does not connect to a server or save the node object at all, to have the password persist across `chef-solo` runs, you must specify them in the `json_attribs` file used. For Example:
|
||||
|
||||
```
|
||||
{
|
||||
"postgresql": {
|
||||
"password": {
|
||||
"postgres": "iloverandompasswordsbutthiswilldo"
|
||||
}
|
||||
},
|
||||
"run_list": ["recipe[postgresql::server]"]
|
||||
}
|
||||
```
|
||||
|
||||
Credits: This `postgresql::config_initdb` recipe is based on algorithms
|
||||
in the [source code](http://doxygen.postgresql.org/initdb_8c_source.html)
|
||||
for the PostgreSQL `initdb` utility.
|
||||
That should actually be the "encrypted password" instead of cleartext, so you should generate it as an md5 hash using the PostgreSQL algorithm.
|
||||
|
||||
config\_pgtune
|
||||
--------------
|
||||
- You could copy the md5-hashed password from an existing postgres database if you have `postgres` access and want to use the same password:<br>
|
||||
`select * from pg_shadow where usename='postgres';`
|
||||
- You can run this from any postgres database session to use a new password:<br>
|
||||
`select 'md5'||md5('iloverandompasswordsbutthiswilldo'||'postgres');`
|
||||
- You can run this from a linux commandline:<br>
|
||||
`echo -n 'iloverandompasswordsbutthiswilldo''postgres' | openssl md5 | sed -e 's/.* /md5/'`
|
||||
|
||||
Performance tuning.
|
||||
Takes the wimpy default postgresql.conf and expands the database server
|
||||
to be as powerful as the hardware it's being deployed on. This recipe
|
||||
creates a baseline configuration of `node.default['postgresql']['config']`
|
||||
attributes in the right general range for a dedicated Postgresql system.
|
||||
Most installations won't need additional performance tuning.
|
||||
## License
|
||||
|
||||
The only decision you need to make is to choose a `db_type` from the
|
||||
following database workloads. (See the recipe code comments for more
|
||||
detailed descriptions.)
|
||||
|
||||
* "dw" -- Data Warehouse
|
||||
* "oltp" -- Online Transaction Processing
|
||||
* "web" -- Web Application
|
||||
* "mixed" -- Mixed DW and OLTP characteristics
|
||||
* "desktop" -- Not a dedicated database
|
||||
|
||||
This recipe uses a performance model with three input parameters.
|
||||
These node attributes are completely optional, but it is obviously
|
||||
important to choose the `db_type` correctly:
|
||||
|
||||
* `node['postgresql']['config_pgtune']['db_type']` --
|
||||
Specifies database type from the list of five choices above.
|
||||
If not specified, the default is "mixed".
|
||||
|
||||
* `node['postgresql']['config_pgtune']['max_connections']` --
|
||||
Specifies maximum number of connections expected.
|
||||
If not specified, it depends on database type:
|
||||
"web":200, "oltp":300, "dw":20, "mixed":80, "desktop":5
|
||||
|
||||
* `node['postgresql']['config_pgtune']['total_memory']` --
|
||||
Specifies total system memory in kB. (E.g., "49416564kB".)
|
||||
If not specified, it will be taken from Ohai automatic attributes.
|
||||
This could be used to tune a system that isn't a dedicated database.
|
||||
|
||||
The default attributes created by this recipe are easy to override with
|
||||
normal attributes because of Chef attribute precedence. For example, if
|
||||
you are running application benchmarks to try different buffer cache
|
||||
sizes, you would experiment with this node JSON attribute:
|
||||
|
||||
"postgresql": {
|
||||
"config": {
|
||||
"shared_buffers": "3GB"
|
||||
}
|
||||
}
|
||||
|
||||
Note that the recipe uses `max_connections` in its computations. If
|
||||
you want to override that setting, you should specify
|
||||
`node['postgresql']['config_pgtune']['max_connections']` instead of
|
||||
`node['postgresql']['config']['max_connections']`.
|
||||
|
||||
Credits: This `postgresql::config_pgtune` recipe is based on the
|
||||
[pgtune python script](https://github.com/gregs1104/pgtune)
|
||||
developed by
|
||||
[Greg Smith](http://notemagnet.blogspot.com/2008/11/automating-initial-postgresqlconf.html)
|
||||
and
|
||||
[other pgsql-hackers](http://www.postgresql.org/message-id/491C6CDC.8090506@agliodbs.com).
|
||||
|
||||
contrib
|
||||
-------
|
||||
|
||||
Installs the packages defined in the
|
||||
`node['postgresql']['contrib']['packages']` attribute. The contrib
|
||||
directory of the PostgreSQL distribution includes porting tools,
|
||||
analysis utilities, and plug-in features that database engineers often
|
||||
require. Some (like `pgbench`) are executable. Others (like
|
||||
`pg_buffercache`) would need to be installed into the database.
|
||||
|
||||
Also installs any contrib module extensions defined in the
|
||||
`node['postgresql']['contrib']['extensions']` attribute. These will be
|
||||
available in any subsequently created databases in the cluster, because
|
||||
they will be installed into the `template1` database using the
|
||||
`CREATE EXTENSION` command. For example, it is often necessary/helpful
|
||||
for problem troubleshooting and maintenance planning to install the
|
||||
views and functions in these [standard instrumentation extensions]
|
||||
(http://www.postgresql.org/message-id/flat/4DC32600.6080900@pgexperts.com#4DD3D6C6.5060006@2ndquadrant.com):
|
||||
|
||||
node['postgresql']['contrib']['extensions'] = [
|
||||
"pageinspect",
|
||||
"pg_buffercache",
|
||||
"pg_freespacemap",
|
||||
"pgrowlocks",
|
||||
"pg_stat_statements",
|
||||
"pgstattuple"
|
||||
]
|
||||
|
||||
Note that the `pg_stat_statements` view only works if `postgresql.conf`
|
||||
loads its shared library, which can be done with this node attribute:
|
||||
|
||||
node['postgresql']['config']['shared_preload_libraries'] = 'pg_stat_statements'
|
||||
|
||||
If using `shared_preload_libraries` in combination with the `contrib` recipe,
|
||||
make sure that the `contrib` recipe is called before the `server` recipe (to
|
||||
ensure the dependencies are installed and setup in order).
|
||||
|
||||
apt\_pgdg\_postgresql
|
||||
----------------------
|
||||
|
||||
Enables the PostgreSQL Global Development Group yum repository
|
||||
maintained by Devrim Gündüz for updated PostgreSQL packages.
|
||||
(The PGDG is the groups that develops PostgreSQL.)
|
||||
Automatically included if the `node['postgresql']['enable_pgdg_apt']`
|
||||
attribute is true. Also set the
|
||||
`node['postgresql']['client']['packages']` and
|
||||
`node['postgresql']['server]['packages']` to the list of packages to
|
||||
use from this repository, and set the `node['postgresql']['version']`
|
||||
attribute to the version to use (e.g., "9.2").
|
||||
|
||||
yum\_pgdg\_postgresql
|
||||
---------------------
|
||||
|
||||
Enables the PostgreSQL Global Development Group yum repository
|
||||
maintained by Devrim Gündüz for updated PostgreSQL packages.
|
||||
(The PGDG is the groups that develops PostgreSQL.)
|
||||
Automatically included if the `node['postgresql']['enable_pgdg_yum']`
|
||||
attribute is true. Also use `override_attributes` to set a number of
|
||||
values that will need to have embedded version numbers. For example:
|
||||
|
||||
node['postgresql']['enable_pgdg_yum'] = true
|
||||
node['postgresql']['version'] = "9.2"
|
||||
node['postgresql']['dir'] = "/var/lib/pgsql/9.2/data"
|
||||
node['postgresql']['config']['data_directory'] = node['postgresql']['dir']
|
||||
node['postgresql']['client']['packages'] = ["postgresql92", "postgresql92-devel"]
|
||||
node['postgresql']['server']['packages'] = ["postgresql92-server"]
|
||||
node['postgresql']['server']['service_name'] = "postgresql-9.2"
|
||||
node['postgresql']['contrib']['packages'] = ["postgresql92-contrib"]
|
||||
|
||||
You may set `node['postgresql']['pgdg']['repo_rpm_url']` attributes
|
||||
to pick up recent [PGDG repo packages](http://yum.postgresql.org/repopackages.php).
|
||||
|
||||
Resources/Providers
|
||||
===================
|
||||
|
||||
See the [database](http://community.opscode.com/cookbooks/database)
|
||||
for resources and providers that can be used for managing PostgreSQL
|
||||
users and databases.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
On systems that need to connect to a PostgreSQL database, add to a run
|
||||
list `recipe[postgresql]` or `recipe[postgresql::client]`.
|
||||
|
||||
On systems that should be PostgreSQL servers, use
|
||||
`recipe[postgresql::server]` on a run list. This recipe does set a
|
||||
password for the `postgres` user.
|
||||
If you're using `chef server`, if the attribute
|
||||
`node['postgresql']['password']['postgres']` is not found,
|
||||
the recipe generates a random password and performs a node.save.
|
||||
(TODO: This is broken, as it disables the password.)
|
||||
If you're using `chef-solo`, you'll need
|
||||
to set the attribute `node['postgresql']['password']['postgres']` in
|
||||
your node's `json_attribs` file or in a role.
|
||||
|
||||
On Debian family systems, SSL will be enabled, as the packages on
|
||||
Debian/Ubuntu also generate the SSL certificates. If you use another
|
||||
platform and wish to use SSL in postgresql, then generate your SSL
|
||||
certificates and distribute them in your own cookbook, and set the
|
||||
`node['postgresql']['config']['ssl']` attribute to true in your
|
||||
role/cookboook/node.
|
||||
|
||||
On server systems, the postgres server is restarted when a configuration
|
||||
file changes. This can be changed to reload only by setting the
|
||||
following attribute:
|
||||
|
||||
node['postgresql']['server']['config_change_notify'] = :reload
|
||||
|
||||
Chef Solo Note
|
||||
==============
|
||||
|
||||
The following node attribute is stored on the Chef Server when using
|
||||
`chef-client`. Because `chef-solo` does not connect to a server or
|
||||
save the node object at all, to have the password persist across
|
||||
`chef-solo` runs, you must specify them in the `json_attribs` file
|
||||
used. For Example:
|
||||
|
||||
{
|
||||
"postgresql": {
|
||||
"password": {
|
||||
"postgres": "iloverandompasswordsbutthiswilldo"
|
||||
}
|
||||
},
|
||||
"run_list": ["recipe[postgresql::server]"]
|
||||
}
|
||||
|
||||
That should actually be the "encrypted password" instead of cleartext,
|
||||
so you should generate it as an md5 hash using the PostgreSQL algorithm.
|
||||
|
||||
* You could copy the md5-hashed password from an existing postgres
|
||||
database if you have `postgres` access and want to use the same password:<br>
|
||||
`select * from pg_shadow where usename='postgres';`
|
||||
* You can run this from any postgres database session to use a new password:<br>
|
||||
`select 'md5'||md5('iloverandompasswordsbutthiswilldo'||'postgres');`
|
||||
* You can run this from a linux commandline:<br>
|
||||
`echo -n 'iloverandompasswordsbutthiswilldo''postgres' | openssl md5 | sed -e 's/.* /md5/'`
|
||||
|
||||
License and Author
|
||||
==================
|
||||
|
||||
- Author:: Joshua Timberman (<joshua@opscode.com>)
|
||||
- Author:: Lamont Granquist (<lamont@opscode.com>)
|
||||
- Author:: Chris Roberts (<chrisroberts.code@gmail.com>)
|
||||
- Author:: David Crane (<davidc@donorschoose.org>)
|
||||
- Author:: Aaron Baer (<aaron@heavywater.io>)
|
||||
Copyright 2010-2016, Chef Software, Inc.
|
||||
|
||||
```text
|
||||
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
|
||||
@@ -449,3 +281,4 @@ 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.
|
||||
```
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Cookbook Name:: postgresql
|
||||
# Cookbook:: postgresql
|
||||
# Attributes:: postgresql
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -17,6 +18,7 @@
|
||||
|
||||
default['postgresql']['enable_pgdg_apt'] = false
|
||||
default['postgresql']['enable_pgdg_yum'] = false
|
||||
default['postgresql']['use_pgdg_packages'] = false
|
||||
|
||||
default['postgresql']['server']['config_change_notify'] = :restart
|
||||
default['postgresql']['assign_postgres_password'] = true
|
||||
@@ -25,17 +27,16 @@ default['postgresql']['assign_postgres_password'] = true
|
||||
default['postgresql']['database_name'] = 'template1'
|
||||
|
||||
# Sets OS init system (upstart, systemd, ...), instead of relying on Ohai
|
||||
default['postgresql']['server']['init_package'] = case node['platform']
|
||||
default['postgresql']['server']['init_package'] =
|
||||
case node['platform']
|
||||
when 'debian'
|
||||
case
|
||||
when node['platform_version'].to_f < 7.0
|
||||
if node['platform_version'].to_f < 7.0
|
||||
'sysv'
|
||||
else
|
||||
'systemd'
|
||||
end
|
||||
when 'ubuntu'
|
||||
case
|
||||
when node['platform_version'].to_f < 15.04
|
||||
if node['platform_version'].to_f < 15.04
|
||||
'upstart'
|
||||
else
|
||||
'systemd'
|
||||
@@ -43,195 +44,154 @@ default['postgresql']['server']['init_package'] = case node['platform']
|
||||
when 'amazon'
|
||||
'upstart'
|
||||
when 'redhat', 'centos', 'scientific', 'oracle'
|
||||
case
|
||||
when node['platform_version'].to_f < 6.0
|
||||
if node['platform_version'].to_i < 7
|
||||
'sysv'
|
||||
when node['platform_version'].to_f < 7.0
|
||||
'upstart'
|
||||
else
|
||||
'systemd'
|
||||
end
|
||||
when 'fedora'
|
||||
case
|
||||
when node['platform_version'].to_f < 15
|
||||
'upstart'
|
||||
else
|
||||
'systemd'
|
||||
end
|
||||
when 'opensuse'
|
||||
case
|
||||
when node['platform_version'].to_f < 13
|
||||
'sysv'
|
||||
else
|
||||
'systemd'
|
||||
end
|
||||
'systemd'
|
||||
when 'opensuse', 'opensuseleap'
|
||||
'systemd'
|
||||
else
|
||||
'upstart'
|
||||
end
|
||||
|
||||
case node['platform']
|
||||
when "debian"
|
||||
|
||||
case
|
||||
when node['platform_version'].to_f < 6.0 # All 5.X
|
||||
default['postgresql']['version'] = "8.3"
|
||||
default['postgresql']['dir'] = "/etc/postgresql/8.3/main"
|
||||
default['postgresql']['client']['packages'] = ["postgresql-client-8.3","libpq-dev"]
|
||||
default['postgresql']['server']['packages'] = ["postgresql-8.3"]
|
||||
default['postgresql']['contrib']['packages'] = ["postgresql-contrib-8.3"]
|
||||
when node['platform_version'].to_f < 7.0 # All 6.X
|
||||
default['postgresql']['version'] = "8.4"
|
||||
default['postgresql']['dir'] = "/etc/postgresql/8.4/main"
|
||||
default['postgresql']['client']['packages'] = ["postgresql-client-8.4","libpq-dev"]
|
||||
default['postgresql']['server']['packages'] = ["postgresql-8.4"]
|
||||
default['postgresql']['contrib']['packages'] = ["postgresql-contrib-8.4"]
|
||||
when node['platform_version'].to_f < 8.0 # All 7.X
|
||||
default['postgresql']['version'] = "9.1"
|
||||
default['postgresql']['dir'] = "/etc/postgresql/9.1/main"
|
||||
default['postgresql']['client']['packages'] = ["postgresql-client-9.1","libpq-dev"]
|
||||
default['postgresql']['server']['packages'] = ["postgresql-9.1"]
|
||||
default['postgresql']['contrib']['packages'] = ["postgresql-contrib-9.1"]
|
||||
else
|
||||
default['postgresql']['version'] = "9.4"
|
||||
default['postgresql']['dir'] = "/etc/postgresql/9.4/main"
|
||||
default['postgresql']['client']['packages'] = ["postgresql-client-9.4","libpq-dev"]
|
||||
default['postgresql']['server']['packages'] = ["postgresql-9.4"]
|
||||
default['postgresql']['contrib']['packages'] = ["postgresql-contrib-9.4"]
|
||||
when 'debian'
|
||||
if node['platform_version'].to_i == 7
|
||||
default['postgresql']['version'] = '9.1'
|
||||
default['postgresql']['dir'] = '/etc/postgresql/9.1/main'
|
||||
default['postgresql']['client']['packages'] = ['postgresql-client-9.1', 'libpq-dev']
|
||||
default['postgresql']['server']['packages'] = ['postgresql-9.1']
|
||||
default['postgresql']['contrib']['packages'] = ['postgresql-contrib-9.1']
|
||||
else # 8+
|
||||
default['postgresql']['version'] = '9.4'
|
||||
default['postgresql']['dir'] = '/etc/postgresql/9.4/main'
|
||||
default['postgresql']['client']['packages'] = ['postgresql-client-9.4', 'libpq-dev']
|
||||
default['postgresql']['server']['packages'] = ['postgresql-9.4']
|
||||
default['postgresql']['contrib']['packages'] = ['postgresql-contrib-9.4']
|
||||
end
|
||||
|
||||
case
|
||||
when node['platform_version'].to_f < 6.0 # All 5.X
|
||||
default['postgresql']['server']['service_name'] = "postgresql-8.3"
|
||||
default['postgresql']['server']['service_name'] = 'postgresql'
|
||||
|
||||
when 'ubuntu'
|
||||
|
||||
if node['platform_version'].to_f <= 13.10
|
||||
default['postgresql']['version'] = '9.1'
|
||||
default['postgresql']['dir'] = '/etc/postgresql/9.1/main'
|
||||
default['postgresql']['server']['service_name'] = 'postgresql'
|
||||
default['postgresql']['client']['packages'] = ['postgresql-client-9.1', 'libpq-dev']
|
||||
default['postgresql']['server']['packages'] = ['postgresql-9.1']
|
||||
default['postgresql']['contrib']['packages'] = ['postgresql-contrib-9.1']
|
||||
elsif node['platform_version'].to_f <= 14.04
|
||||
default['postgresql']['version'] = '9.3'
|
||||
default['postgresql']['dir'] = '/etc/postgresql/9.3/main'
|
||||
default['postgresql']['server']['service_name'] = 'postgresql'
|
||||
default['postgresql']['client']['packages'] = ['postgresql-client-9.3', 'libpq-dev']
|
||||
default['postgresql']['server']['packages'] = ['postgresql-9.3']
|
||||
default['postgresql']['contrib']['packages'] = ['postgresql-contrib-9.3']
|
||||
elsif node['platform_version'].to_f <= 15.10
|
||||
default['postgresql']['version'] = '9.4'
|
||||
default['postgresql']['dir'] = '/etc/postgresql/9.4/main'
|
||||
default['postgresql']['server']['service_name'] = 'postgresql'
|
||||
default['postgresql']['client']['packages'] = ['postgresql-client-9.4', 'libpq-dev']
|
||||
default['postgresql']['server']['packages'] = ['postgresql-9.4']
|
||||
default['postgresql']['contrib']['packages'] = ['postgresql-contrib-9.4']
|
||||
else
|
||||
default['postgresql']['server']['service_name'] = "postgresql"
|
||||
default['postgresql']['version'] = '9.5'
|
||||
default['postgresql']['dir'] = '/etc/postgresql/9.5/main'
|
||||
default['postgresql']['server']['service_name'] = 'postgresql'
|
||||
default['postgresql']['client']['packages'] = ['postgresql-client-9.5', 'libpq-dev']
|
||||
default['postgresql']['server']['packages'] = ['postgresql-9.5']
|
||||
default['postgresql']['contrib']['packages'] = ['postgresql-contrib-9.5']
|
||||
end
|
||||
|
||||
when 'fedora'
|
||||
|
||||
when "ubuntu"
|
||||
default['postgresql']['version'] = '9.5'
|
||||
default['postgresql']['setup_script'] = 'postgresql-setup'
|
||||
default['postgresql']['dir'] = '/var/lib/pgsql/data'
|
||||
default['postgresql']['client']['packages'] = %w(postgresql-devel postgresql-contrib)
|
||||
default['postgresql']['server']['packages'] = %w(postgresql-server)
|
||||
default['postgresql']['contrib']['packages'] = %w(postgresql-contrib)
|
||||
default['postgresql']['server']['service_name'] = 'postgresql'
|
||||
default['postgresql']['uid'] = '26'
|
||||
default['postgresql']['gid'] = '26'
|
||||
|
||||
case
|
||||
when node['platform_version'].to_f <= 9.04
|
||||
default['postgresql']['version'] = "8.3"
|
||||
default['postgresql']['dir'] = "/etc/postgresql/8.3/main"
|
||||
default['postgresql']['server']['service_name'] = "postgresql-8.3"
|
||||
default['postgresql']['client']['packages'] = ["postgresql-client-8.3","libpq-dev"]
|
||||
default['postgresql']['server']['packages'] = ["postgresql-8.3"]
|
||||
default['postgresql']['contrib']['packages'] = ["postgresql-contrib-8.3"]
|
||||
when node['platform_version'].to_f <= 11.04
|
||||
default['postgresql']['version'] = "8.4"
|
||||
default['postgresql']['dir'] = "/etc/postgresql/8.4/main"
|
||||
default['postgresql']['server']['service_name'] = "postgresql"
|
||||
default['postgresql']['client']['packages'] = ["postgresql-client-8.4","libpq-dev"]
|
||||
default['postgresql']['server']['packages'] = ["postgresql-8.4"]
|
||||
default['postgresql']['contrib']['packages'] = ["postgresql-contrib-8.4"]
|
||||
when node['platform_version'].to_f <= 13.10
|
||||
default['postgresql']['version'] = "9.1"
|
||||
default['postgresql']['dir'] = "/etc/postgresql/9.1/main"
|
||||
default['postgresql']['server']['service_name'] = "postgresql"
|
||||
default['postgresql']['client']['packages'] = ["postgresql-client-9.1","libpq-dev"]
|
||||
default['postgresql']['server']['packages'] = ["postgresql-9.1"]
|
||||
default['postgresql']['contrib']['packages'] = ["postgresql-contrib-9.1"]
|
||||
else
|
||||
default['postgresql']['version'] = "9.3"
|
||||
default['postgresql']['dir'] = "/etc/postgresql/9.3/main"
|
||||
default['postgresql']['server']['service_name'] = "postgresql"
|
||||
default['postgresql']['client']['packages'] = ["postgresql-client-9.3","libpq-dev"]
|
||||
default['postgresql']['server']['packages'] = ["postgresql-9.3"]
|
||||
default['postgresql']['contrib']['packages'] = ["postgresql-contrib-9.3"]
|
||||
when 'amazon'
|
||||
|
||||
if node['platform_version'].to_f >= 2015.03
|
||||
default['postgresql']['version'] = '9.2'
|
||||
default['postgresql']['dir'] = '/var/lib/pgsql9/data'
|
||||
end
|
||||
|
||||
when "fedora"
|
||||
default['postgresql']['client']['packages'] = %w(postgresql-devel)
|
||||
default['postgresql']['server']['packages'] = %w(postgresql-server)
|
||||
default['postgresql']['contrib']['packages'] = %w(postgresql-contrib)
|
||||
default['postgresql']['server']['service_name'] = 'postgresql'
|
||||
default['postgresql']['uid'] = '26'
|
||||
default['postgresql']['gid'] = '26'
|
||||
|
||||
if node['platform_version'].to_f <= 12
|
||||
default['postgresql']['version'] = "8.3"
|
||||
else
|
||||
default['postgresql']['version'] = "8.4"
|
||||
end
|
||||
when 'redhat', 'centos', 'scientific', 'oracle'
|
||||
|
||||
default['postgresql']['setup_script'] = "postgresql-setup"
|
||||
default['postgresql']['version'] = '8.4'
|
||||
|
||||
default['postgresql']['dir'] = "/var/lib/pgsql/data"
|
||||
default['postgresql']['client']['packages'] = %w{postgresql-devel}
|
||||
default['postgresql']['server']['packages'] = %w{postgresql-server}
|
||||
default['postgresql']['contrib']['packages'] = %w{postgresql-contrib}
|
||||
default['postgresql']['server']['service_name'] = "postgresql"
|
||||
default['postgresql']['client']['packages'] = 'postgresql84-devel'
|
||||
default['postgresql']['server']['packages'] = ['postgresql84-server']
|
||||
default['postgresql']['contrib']['packages'] = ['postgresql84-contrib']
|
||||
|
||||
when "amazon"
|
||||
|
||||
if node['platform_version'].to_f == 2012.03
|
||||
default['postgresql']['version'] = "9.0"
|
||||
default['postgresql']['dir'] = "/var/lib/pgsql9/data"
|
||||
elsif node['platform_version'].to_f >= 2015.03
|
||||
default['postgresql']['version'] = "9.2"
|
||||
default['postgresql']['dir'] = "/var/lib/pgsql9/data"
|
||||
else
|
||||
default['postgresql']['version'] = "8.4"
|
||||
default['postgresql']['dir'] = "/var/lib/pgsql/data"
|
||||
end
|
||||
|
||||
default['postgresql']['client']['packages'] = %w{postgresql-devel}
|
||||
default['postgresql']['server']['packages'] = %w{postgresql-server}
|
||||
default['postgresql']['contrib']['packages'] = %w{postgresql-contrib}
|
||||
default['postgresql']['server']['service_name'] = "postgresql"
|
||||
|
||||
when "redhat", "centos", "scientific", "oracle"
|
||||
|
||||
default['postgresql']['version'] = "8.4"
|
||||
|
||||
default['postgresql']['client']['packages'] = ["postgresql84-devel"]
|
||||
default['postgresql']['server']['packages'] = ["postgresql84-server"]
|
||||
default['postgresql']['contrib']['packages'] = ["postgresql84-contrib"]
|
||||
|
||||
default['postgresql']['setup_script'] = "postgresql-setup"
|
||||
default['postgresql']['server']['service_name'] = "postgresql"
|
||||
default['postgresql']['setup_script'] = 'postgresql-setup'
|
||||
default['postgresql']['server']['service_name'] = 'postgresql'
|
||||
default['postgresql']['uid'] = '26'
|
||||
default['postgresql']['gid'] = '26'
|
||||
|
||||
if node['platform_version'].to_f >= 6.0 && node['postgresql']['version'].to_f == 8.4
|
||||
default['postgresql']['client']['packages'] = ['postgresql-devel']
|
||||
default['postgresql']['client']['packages'] = 'postgresql-devel'
|
||||
default['postgresql']['server']['packages'] = ['postgresql-server']
|
||||
default['postgresql']['contrib']['packages'] = ['postgresql-contrib']
|
||||
end
|
||||
|
||||
when "opensuse"
|
||||
if node['platform_version'].to_f >= 7.0
|
||||
default['postgresql']['version'] = '9.2'
|
||||
default['postgresql']['client']['packages'] = 'postgresql-devel'
|
||||
default['postgresql']['server']['packages'] = ['postgresql-server']
|
||||
default['postgresql']['contrib']['packages'] = ['postgresql-contrib']
|
||||
end
|
||||
|
||||
default['postgresql']['dir'] = "/var/lib/pgsql/data"
|
||||
when 'opensuse', 'opensuseleap'
|
||||
|
||||
if node['platform_version'].to_f == 13.2
|
||||
default['postgresql']['version'] = '9.3'
|
||||
default['postgresql']['client']['packages'] = ['postgresql93', 'postgresql93-devel']
|
||||
default['postgresql']['server']['packages'] = ['postgresql93-server']
|
||||
default['postgresql']['contrib']['packages'] = ['postgresql93-contrib']
|
||||
elsif node['platform_version'].to_f == 13.1
|
||||
default['postgresql']['dir'] = '/var/lib/pgsql/data'
|
||||
default['postgresql']['uid'] = '26'
|
||||
default['postgresql']['gid'] = '26'
|
||||
|
||||
case node['platform_version'].to_f
|
||||
when 13.1
|
||||
default['postgresql']['version'] = '9.2'
|
||||
default['postgresql']['client']['packages'] = ['postgresql92', 'postgresql92-devel']
|
||||
default['postgresql']['server']['packages'] = ['postgresql92-server']
|
||||
default['postgresql']['contrib']['packages'] = ['postgresql92-contrib']
|
||||
when 13.2
|
||||
default['postgresql']['version'] = '9.3'
|
||||
default['postgresql']['client']['packages'] = ['postgresql93', 'postgresql93-devel']
|
||||
default['postgresql']['server']['packages'] = ['postgresql93-server']
|
||||
default['postgresql']['contrib']['packages'] = ['postgresql93-contrib']
|
||||
else # opensuseleap
|
||||
default['postgresql']['version'] = '9.4'
|
||||
default['postgresql']['client']['packages'] = ['postgresql94', 'postgresql94-devel']
|
||||
default['postgresql']['server']['packages'] = ['postgresql94-server']
|
||||
default['postgresql']['contrib']['packages'] = ['postgresql94-contrib']
|
||||
end
|
||||
|
||||
default['postgresql']['server']['service_name'] = "postgresql"
|
||||
default['postgresql']['server']['service_name'] = 'postgresql'
|
||||
|
||||
when "suse"
|
||||
if node['platform_version'].to_f <= 11.1
|
||||
default['postgresql']['version'] = "8.3"
|
||||
default['postgresql']['client']['packages'] = ['postgresql', 'rubygem-pg']
|
||||
default['postgresql']['server']['packages'] = ['postgresql-server']
|
||||
default['postgresql']['contrib']['packages'] = ['postgresql-contrib']
|
||||
else
|
||||
default['postgresql']['version'] = "9.1"
|
||||
default['postgresql']['client']['packages'] = ['postgresql91', 'rubygem-pg']
|
||||
default['postgresql']['server']['packages'] = ['postgresql91-server']
|
||||
default['postgresql']['contrib']['packages'] = ['postgresql91-contrib']
|
||||
end
|
||||
|
||||
default['postgresql']['dir'] = "/var/lib/pgsql/data"
|
||||
default['postgresql']['server']['service_name'] = "postgresql"
|
||||
|
||||
else
|
||||
default['postgresql']['version'] = "8.4"
|
||||
default['postgresql']['dir'] = "/etc/postgresql/8.4/main"
|
||||
default['postgresql']['client']['packages'] = ["postgresql"]
|
||||
default['postgresql']['server']['packages'] = ["postgresql"]
|
||||
default['postgresql']['contrib']['packages'] = ["postgresql"]
|
||||
default['postgresql']['server']['service_name'] = "postgresql"
|
||||
when 'suse' # sles 12+
|
||||
default['postgresql']['version'] = '9.1'
|
||||
default['postgresql']['client']['packages'] = ['postgresql91', 'rubygem-pg']
|
||||
default['postgresql']['server']['packages'] = ['postgresql91-server']
|
||||
default['postgresql']['contrib']['packages'] = ['postgresql91-contrib']
|
||||
default['postgresql']['dir'] = '/var/lib/pgsql/data'
|
||||
default['postgresql']['server']['service_name'] = 'postgresql'
|
||||
end
|
||||
|
||||
case node['platform_family']
|
||||
@@ -264,13 +224,17 @@ when 'rhel', 'fedora', 'suse'
|
||||
end
|
||||
|
||||
default['postgresql']['pg_hba'] = [
|
||||
{:type => 'local', :db => 'all', :user => 'postgres', :addr => nil, :method => 'ident'},
|
||||
{:type => 'local', :db => 'all', :user => 'all', :addr => nil, :method => 'ident'},
|
||||
{:type => 'host', :db => 'all', :user => 'all', :addr => '127.0.0.1/32', :method => 'md5'},
|
||||
{:type => 'host', :db => 'all', :user => 'all', :addr => '::1/128', :method => 'md5'}
|
||||
{ type: 'local', db: 'all', user: 'postgres', addr: nil, method: 'ident' },
|
||||
{ type: 'local', db: 'all', user: 'all', addr: nil, method: 'ident' },
|
||||
{ type: 'host', db: 'all', user: 'all', addr: '127.0.0.1/32', method: 'md5' },
|
||||
{ type: 'host', db: 'all', user: 'all', addr: '::1/128', method: 'md5' },
|
||||
]
|
||||
|
||||
default['postgresql']['password'] = Hash.new
|
||||
default['postgresql']['password'] = {}
|
||||
|
||||
# set to install a specific version of the ruby gem pg
|
||||
# if attribute is not defined, install will pick the latest available pg gem
|
||||
default['postgresql']['pg_gem']['version'] = nil
|
||||
|
||||
case node['platform_family']
|
||||
when 'debian'
|
||||
@@ -278,4 +242,3 @@ when 'debian'
|
||||
end
|
||||
|
||||
default['postgresql']['initdb_locale'] = 'UTF-8'
|
||||
|
||||
|
||||
@@ -1,452 +1,507 @@
|
||||
# frozen_string_literal: true
|
||||
# The PostgreSQL RPM Building Project built repository RPMs for easy
|
||||
# access to the PGDG yum repositories. Links to RPMs for installation
|
||||
# on the supported version/platform combinations are listed at
|
||||
# http://yum.postgresql.org/repopackages.php, and the links for
|
||||
# PostgreSQL 9.2, 9.3 and 9.4 are captured below.
|
||||
# PostgreSQL 9.2, 9.3, 9.4, 9.5 and 9.6 are captured below.
|
||||
#
|
||||
default['postgresql']['pgdg']['repo_rpm_url'] = {
|
||||
"9.4" => {
|
||||
"redhat" => {
|
||||
"7" => {
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/",
|
||||
"package" => "pgdg-redhat94-9.4-1.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"6" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-6-i386/",
|
||||
"package" => "pgdg-redhat94-9.4-1.noarch.rpm"
|
||||
'9.6' => {
|
||||
'amazon' => {
|
||||
'2015' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.6/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-ami201503-96-9.6-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/",
|
||||
"package" => "pgdg-redhat94-9.4-1.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"5" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-5-i386/",
|
||||
"package" => "pgdg-redhat94-9.4-1.noarch.rpm"
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.6/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-ami201503-96-9.6-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/",
|
||||
"package" => "pgdg-redhat94-9.4-1.noarch.rpm"
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
"centos" => {
|
||||
"7" => {
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/",
|
||||
"package" => "pgdg-centos94-9.4-1.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"6" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-6-i386/",
|
||||
"package" => "pgdg-centos94-9.4-1.noarch.rpm"
|
||||
'centos' => {
|
||||
'7' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/',
|
||||
'package' => 'pgdg-centos96-9.6-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/",
|
||||
"package" => "pgdg-centos94-9.4-1.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"5" => {
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/",
|
||||
"package" => "pgdg-centos94-9.4-1.noarch.rpm"
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.6/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-centos96-9.6-3.noarch.rpm',
|
||||
},
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-5-i386/",
|
||||
"package" => "pgdg-centos94-9.4-1.noarch.rpm"
|
||||
}
|
||||
}
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.6/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-centos96-9.6-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
"fedora" => {
|
||||
"22" => {
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/fedora/fedora-22-x86_64/",
|
||||
"package" => "pgdg-fedora94-9.4-3.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"21" => {
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/fedora/fedora-21-x86_64/",
|
||||
"package" => "pgdg-fedora94-9.4-2.noarch.rpm"
|
||||
},
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/fedora/fedora-21-i686/",
|
||||
"package" => "pgdg-fedora94-9.4-2.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"20" => {
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/fedora/fedora-20-x86_64/",
|
||||
"package" => "pgdg-fedora94-9.4-1.noarch.rpm"
|
||||
'redhat' => {
|
||||
'7' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/',
|
||||
'package' => 'pgdg-redhat96-9.6-3.noarch.rpm',
|
||||
},
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/fedora/fedora-20-i686/",
|
||||
"package" => "pgdg-fedora94-9.4-1.noarch.rpm"
|
||||
}
|
||||
}
|
||||
},
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.6/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-redhat96-9.6-3.noarch.rpm',
|
||||
},
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.6/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-redhat96-9.6-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
"amazon" => {
|
||||
"2015" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-6-i386/",
|
||||
"package" => "pgdg-ami201503-94-9.4-1.noarch.rpm"
|
||||
'oracle' => {
|
||||
'7' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/',
|
||||
'package' => 'pgdg-oraclelinux96-9.6-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/",
|
||||
"package" => "pgdg-ami201503-94-9.4-1.noarch.rpm"
|
||||
}
|
||||
}
|
||||
},
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.6/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-oraclelinux96-9.6-3.noarch.rpm',
|
||||
},
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.6/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-oraclelinux96-9.6-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
"scientific" => {
|
||||
"7" => {
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/",
|
||||
"package" => "pgdg-sl94-9.4-1.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"6" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-6-i386/",
|
||||
"package" => "pgdg-sl94-9.4-1.noarch.rpm"
|
||||
'scientific' => {
|
||||
'7' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/',
|
||||
'package' => 'pgdg-sl96-9.6-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/",
|
||||
"package" => "pgdg-sl94-9.4-1.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"5" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-5-i386/",
|
||||
"package" => "pgdg-sl94-9.4-1.noarch.rpm"
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.6/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-sl96-9.6-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/",
|
||||
"package" => "pgdg-sl94-9.4-1.noarch.rpm"
|
||||
}
|
||||
}
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.6/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-sl96-9.6-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
"oracle" => {
|
||||
"7" => {
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/",
|
||||
"package" => "pgdg-oraclelinux94-9.4-1.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"6" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-6-i386/",
|
||||
"package" => "pgdg-oraclelinux94-9.4-1.noarch.rpm"
|
||||
'fedora' => {
|
||||
'22' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.6/fedora/fedora-22-x86_64/',
|
||||
'package' => 'pgdg-fedora96-9.6-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/",
|
||||
"package" => "pgdg-oraclelinux94-9.4-1.noarch.rpm"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'23' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.6/fedora/fedora-23-x86_64/',
|
||||
'package' => 'pgdg-fedora96-9.6-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
'24' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.6/fedora/fedora-24-x86_64/',
|
||||
'package' => 'pgdg-fedora96-9.6-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
'25' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.6/fedora/fedora-25-x86_64/',
|
||||
'package' => 'pgdg-fedora96-9.6-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"9.3" => {
|
||||
"amazon" => {
|
||||
"2015" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-6-i386/",
|
||||
"package" => "pgdg-redhat93-9.3-1.noarch.rpm"
|
||||
'9.5' => {
|
||||
'amazon' => {
|
||||
'2015' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.5/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-ami201503-95-9.5-3.noarch.rpm',
|
||||
},
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.5/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-ami201503-95-9.5-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/",
|
||||
"package" => "pgdg-redhat93-9.3-1.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"2014" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-6-i386/",
|
||||
"package" => "pgdg-redhat93-9.3-1.noarch.rpm"
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/",
|
||||
"package" => "pgdg-redhat93-9.3-1.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"2013" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-6-i386/",
|
||||
"package" => "pgdg-redhat93-9.3-1.noarch.rpm"
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/",
|
||||
"package" => "pgdg-redhat93-9.3-1.noarch.rpm"
|
||||
}
|
||||
}
|
||||
},
|
||||
"centos" => {
|
||||
"7" => {
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/",
|
||||
"package" => "pgdg-centos93-9.3-1.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"6" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-6-i386/",
|
||||
"package" => "pgdg-centos93-9.3-1.noarch.rpm"
|
||||
'centos' => {
|
||||
'7' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/',
|
||||
'package' => 'pgdg-centos95-9.5-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/",
|
||||
"package" => "pgdg-centos93-9.3-1.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"5" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-5-i386/",
|
||||
"package" => "pgdg-centos93-9.3-1.noarch.rpm"
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.5/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-centos95-9.5-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-5-x86_64/",
|
||||
"package" => "pgdg-centos93-9.3-1.noarch.rpm"
|
||||
}
|
||||
}
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.5/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-centos95-9.5-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
"redhat" => {
|
||||
"7" => {
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/",
|
||||
"package" => "pgdg-redhat93-9.3-1.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"6" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-6-i386/",
|
||||
"package" => "pgdg-redhat93-9.3-1.noarch.rpm",
|
||||
'redhat' => {
|
||||
'7' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/',
|
||||
'package' => 'pgdg-redhat95-9.5-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/",
|
||||
"package" => "pgdg-redhat93-9.3-1.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"5" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-5-i386/",
|
||||
"package" => "pgdg-redhat93-9.3-1.noarch.rpm"
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.5/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-redhat95-9.5-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-5-x86_64/",
|
||||
"package" => "pgdg-redhat93-9.3-1.noarch.rpm"
|
||||
}
|
||||
}
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.5/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-redhat95-9.5-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
"oracle" => {
|
||||
"6" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-6-i386/",
|
||||
"package" => "pgdg-redhat93-9.3-1.noarch.rpm"
|
||||
'oracle' => {
|
||||
'7' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/',
|
||||
'package' => 'pgdg-oraclelinux95-9.5-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/",
|
||||
"package" => "pgdg-redhat93-9.3-1.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"5" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-5-i386/",
|
||||
"package" => "pgdg-redhat93-9.3-1.noarch.rpm"
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.5/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-oraclelinux95-9.5-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-5-x86_64/",
|
||||
"package" => "pgdg-redhat93-9.3-1.noarch.rpm"
|
||||
}
|
||||
}
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.5/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-oraclelinux95-9.5-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
"scientific" => {
|
||||
"6" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-6-i386/",
|
||||
"package" => "pgdg-sl93-9.3-1.noarch.rpm"
|
||||
'scientific' => {
|
||||
'7' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/',
|
||||
'package' => 'pgdg-sl95-9.5-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/",
|
||||
"package" => "pgdg-sl93-9.3-1.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"5" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-5-i386/",
|
||||
"package" => "pgdg-sl93-9.3-1.noarch.rpm"
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.5/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-sl95-9.5-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/redhat/rhel-5-x86_64/",
|
||||
"package" => "pgdg-sl93-9.3-1.noarch.rpm"
|
||||
}
|
||||
}
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.5/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-sl95-9.5-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
"fedora" => {
|
||||
"20" => {
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/fedora/fedora-20-x86_64/",
|
||||
"pakcage" => "pgdg-fedora93-9.3-1.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"19" => {
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/fedora/fedora-19-x86_64/",
|
||||
"pakcage" => "pgdg-fedora93-9.3-1.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"18" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/fedora/fedora-18-i386/",
|
||||
"package" => "pgdg-fedora93-9.3-1.noarch.rpm"
|
||||
'fedora' => {
|
||||
'22' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.5/fedora/fedora-22-x86_64/',
|
||||
'package' => 'pgdg-fedora95-9.5-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/fedora/fedora-18-x86_64/",
|
||||
"package" => "pgdg-fedora93-9.3-1.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"17" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/fedora/fedora-17-i386/",
|
||||
"package" => "pgdg-fedora93-9.3-1.noarch.rpm"
|
||||
'23' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.5/fedora/fedora-23-x86_64/',
|
||||
'package' => 'pgdg-fedora95-9.5-4.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.3/fedora/fedora-17-x86_64/",
|
||||
"package" => "pgdg-fedora93-9.3-1.noarch.rpm"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'24' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.5/fedora/fedora-24-x86_64/',
|
||||
'package' => 'pgdg-fedora95-9.5-4.noarch.rpm',
|
||||
},
|
||||
},
|
||||
'25' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.5/fedora/fedora-25-x86_64/',
|
||||
'package' => 'pgdg-fedora95-9.5-4.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"9.2" => {
|
||||
"centos" => {
|
||||
"6" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/redhat/rhel-6-i386/",
|
||||
"package" => "pgdg-centos92-9.2-7.noarch.rpm"
|
||||
'9.4' => {
|
||||
'redhat' => {
|
||||
'7' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/',
|
||||
'package' => 'pgdg-redhat94-9.4-2.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/",
|
||||
"package" => "pgdg-centos92-9.2-7.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"5" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/redhat/rhel-5-i386/",
|
||||
"package" => "pgdg-centos92-9.2-7.noarch.rpm"
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-redhat94-9.4-2.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/redhat/rhel-5-x86_64/",
|
||||
"package" => "pgdg-centos92-9.2-7.noarch.rpm"
|
||||
}
|
||||
}
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-redhat94-9.4-2.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
"redhat" => {
|
||||
"6" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/redhat/rhel-6-i386/",
|
||||
"package" => "pgdg-redhat92-9.2-7.noarch.rpm"
|
||||
'centos' => {
|
||||
'7' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/',
|
||||
'package' => 'pgdg-centos94-9.4-2.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/",
|
||||
"package" => "pgdg-redhat92-9.2-7.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"5" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/redhat/rhel-5-i386/",
|
||||
"package" => "pgdg-redhat92-9.2-7.noarch.rpm"
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-centos94-9.4-2.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/redhat/rhel-5-x86_64/",
|
||||
"package" => "pgdg-redhat92-9.2-7.noarch.rpm"
|
||||
}
|
||||
}
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-centos94-9.4-2.noarch.rpm',
|
||||
},
|
||||
},
|
||||
'5' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/redhat/rhel-5-i386/',
|
||||
'package' => 'pgdg-centos94-9.4-3.noarch.rpm',
|
||||
},
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/',
|
||||
'package' => 'pgdg-centos94-9.4-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
"oracle" => {
|
||||
"6" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/redhat/rhel-6-i386/",
|
||||
"package" => "pgdg-redhat92-9.2-7.noarch.rpm"
|
||||
'fedora' => {
|
||||
'22' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/fedora/fedora-22-x86_64/',
|
||||
'package' => 'pgdg-fedora94-9.4-4.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/",
|
||||
"package" => "pgdg-redhat92-9.2-7.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"5" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/redhat/rhel-5-i386/",
|
||||
"package" => "pgdg-redhat92-9.2-7.noarch.rpm"
|
||||
'23' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/fedora/fedora-23-x86_64/',
|
||||
'package' => 'pgdg-fedora94-9.4-5.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/redhat/rhel-5-x86_64/",
|
||||
"package" => "pgdg-redhat92-9.2-7.noarch.rpm"
|
||||
}
|
||||
}
|
||||
},
|
||||
'24' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/fedora/fedora-24-x86_64/',
|
||||
'package' => 'pgdg-fedora94-9.4-5.noarch.rpm',
|
||||
},
|
||||
},
|
||||
'25' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/fedora/fedora-25-x86_64/',
|
||||
'package' => 'pgdg-fedora94-9.4-5.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
"scientific" => {
|
||||
"6" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/redhat/rhel-6-i386/",
|
||||
"package" => "pgdg-sl92-9.2-8.noarch.rpm"
|
||||
'amazon' => {
|
||||
'2015' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-ami201503-94-9.4-3.noarch.rpm',
|
||||
},
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-ami201503-94-9.4-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/",
|
||||
"package" => "pgdg-sl92-9.2-8.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"5" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/redhat/rhel-5-i386/",
|
||||
"package" => "pgdg-sl92-9.2-8.noarch.rpm"
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/redhat/rhel-5-x86_64/",
|
||||
"package" => "pgdg-sl92-9.2-8.noarch.rpm"
|
||||
}
|
||||
}
|
||||
},
|
||||
"fedora" => {
|
||||
"19" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/fedora/fedora-19-i386/",
|
||||
"package" => "pgdg-fedora92-9.2-6.noarch.rpm"
|
||||
'scientific' => {
|
||||
'7' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/',
|
||||
'package' => 'pgdg-sl94-9.4-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/fedora/fedora-19-x86_64/",
|
||||
"package" => "pgdg-fedora92-9.2-6.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"18" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/fedora/fedora-18-i386/",
|
||||
"package" => "pgdg-fedora92-9.2-6.noarch.rpm"
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-sl94-9.4-3.noarch.rpm',
|
||||
},
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-sl94-9.4-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/fedora/fedora-18-x86_64/",
|
||||
"package" => "pgdg-fedora92-9.2-6.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"17" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/fedora/fedora-17-i386/",
|
||||
"package" => "pgdg-fedora92-9.2-6.noarch.rpm"
|
||||
},
|
||||
'oracle' => {
|
||||
'7' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/',
|
||||
'package' => 'pgdg-oraclelinux94-9.4-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/fedora/fedora-17-x86_64/",
|
||||
"package" => "pgdg-fedora92-9.2-5.noarch.rpm"
|
||||
}
|
||||
},
|
||||
"16" => {
|
||||
"i386" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/fedora/fedora-16-i386/",
|
||||
"package" => "pgdg-fedora92-9.2-5.noarch.rpm"
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-oraclelinux94-9.4-3.noarch.rpm',
|
||||
},
|
||||
"x86_64" => {
|
||||
"url" => "http://yum.postgresql.org/9.2/fedora/fedora-16-x86_64/",
|
||||
"package" => "pgdg-fedora92-9.2-5.noarch.rpm"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-oraclelinux94-9.4-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
'9.3' => {
|
||||
'amazon' => {
|
||||
'2015' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.3/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-redhat93-9.3-3.noarch.rpm',
|
||||
},
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-redhat93-9.3-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
'2014' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.3/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-redhat93-9.3-3.noarch.rpm',
|
||||
},
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-redhat93-9.3-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
'centos' => {
|
||||
'7' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/',
|
||||
'package' => 'pgdg-centos93-9.3-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.3/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-centos93-9.3-3.noarch.rpm',
|
||||
},
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-centos93-9.3-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
'fedora' => {
|
||||
'23' => {
|
||||
'x86_64' => {
|
||||
'url' => 'https://yum.postgresql.org/9.3/fedora/fedora-23-x86_64/',
|
||||
'package' => 'pgdg-fedora93-9.3-4.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
'redhat' => {
|
||||
'7' => {
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/',
|
||||
'package' => 'pgdg-redhat93-9.3-2.noarch.rpm',
|
||||
},
|
||||
},
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.3/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-redhat93-9.3-3.noarch.rpm',
|
||||
},
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-redhat93-9.3-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
'oracle' => {
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.3/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-redhat93-9.3-3.noarch.rpm',
|
||||
},
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-redhat93-9.3-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
'scientific' => {
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.3/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-sl93-9.3-3.noarch.rpm',
|
||||
},
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-sl93-9.3-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
'5' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.3/redhat/rhel-5-i386/',
|
||||
'package' => 'pgdg-sl93-9.3-3.noarch.rpm',
|
||||
},
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.3/redhat/rhel-5-x86_64/',
|
||||
'package' => 'pgdg-sl93-9.3-3.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
'9.2' => {
|
||||
'centos' => {
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.2/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-centos92-9.2-8.noarch.rpm',
|
||||
},
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-centos92-9.2-8.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
'redhat' => {
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.2/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-redhat92-9.2-9.noarch.rpm',
|
||||
},
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-redhat92-9.2-9.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
'oracle' => {
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.2/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-redhat92-9.2-9.noarch.rpm',
|
||||
},
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-redhat92-9.2-9.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
'scientific' => {
|
||||
'6' => {
|
||||
'i386' => {
|
||||
'url' => 'http://yum.postgresql.org/9.2/redhat/rhel-6-i386/',
|
||||
'package' => 'pgdg-sl92-9.2-10.noarch.rpm',
|
||||
},
|
||||
'x86_64' => {
|
||||
'url' => 'http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/',
|
||||
'package' => 'pgdg-sl92-9.2-10.noarch.rpm',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
#
|
||||
# Copyright 2012, Opscode, Inc.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
require File.expand_path('../support/helpers', __FILE__)
|
||||
|
||||
describe 'postgresql::apt_pgdg_postgresql' do
|
||||
include Helpers::Postgresql
|
||||
|
||||
it 'removes the Pitti PPA sources.list' do
|
||||
skip unless %w{debian}.include?(node['platform_family'])
|
||||
file("/etc/apt/sources.list.d/pitti-postgresql-ppa").wont_exist
|
||||
end
|
||||
it 'creates the PGDG apt sources.list' do
|
||||
skip unless %w{debian}.include?(node['platform_family'])
|
||||
file("/etc/apt/sources.list.d/apt.postgresql.org.list").must_exist
|
||||
end
|
||||
|
||||
it 'installs postgresql-client-9.4' do
|
||||
package("postgresql-client-9.4").must_be_installed
|
||||
end
|
||||
|
||||
it 'makes psql version 9.4 available' do
|
||||
psql = shell_out("psql --version")
|
||||
assert psql.stdout.include?("psql (PostgreSQL) 9.4")
|
||||
end
|
||||
end
|
||||
@@ -1,27 +0,0 @@
|
||||
#
|
||||
# Copyright 2012, Opscode, Inc.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
require File.expand_path('../support/helpers', __FILE__)
|
||||
|
||||
describe 'postgresql::default' do
|
||||
include Helpers::Postgresql
|
||||
|
||||
it 'installs the postgresql client packages' do
|
||||
node['postgresql']['client']['packages'].each do |pkg|
|
||||
package(pkg).must_be_installed
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,28 +0,0 @@
|
||||
#
|
||||
# Cookbook Name:: postgresql_test
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2012, Opscode, Inc.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
require File.expand_path('../support/helpers', __FILE__)
|
||||
|
||||
describe 'postgresql::ruby' do
|
||||
include Helpers::Postgresql
|
||||
|
||||
it 'installs the pg gem in Chefs ruby environment' do
|
||||
assert Gem::Specification.all_names.grep("pg-.*")
|
||||
end
|
||||
end
|
||||
@@ -1,44 +0,0 @@
|
||||
#
|
||||
# Copyright 2012, Opscode, Inc.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
require File.expand_path('../support/helpers', __FILE__)
|
||||
|
||||
describe 'postgresql::server' do
|
||||
include Helpers::Postgresql
|
||||
|
||||
it 'installs the postgresql server packages' do
|
||||
node['postgresql']['server']['packages'].each do |pkg|
|
||||
package(pkg).must_be_installed
|
||||
end
|
||||
end
|
||||
|
||||
it 'runs the postgresql service' do
|
||||
service((node['postgresql']['server']['service_name'] || 'postgresql')).must_be_running
|
||||
end
|
||||
|
||||
it 'can connect to postgresql' do
|
||||
Gem.clear_paths
|
||||
require 'pg'
|
||||
conn = PG::Connection.new(
|
||||
:host => 'localhost',
|
||||
:port => '5432',
|
||||
:password => node['postgresql']['password']['postgres'],
|
||||
:user => "postgres"
|
||||
)
|
||||
assert_match(/localhost/, conn.host)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,29 +0,0 @@
|
||||
#
|
||||
# Cookbook Name:: postgresql_test
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2012, Opscode, Inc.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
module Helpers
|
||||
module Postgresql
|
||||
require 'chef/mixin/shell_out'
|
||||
include Chef::Mixin::ShellOut
|
||||
include MiniTest::Chef::Assertions
|
||||
include MiniTest::Chef::Context
|
||||
include MiniTest::Chef::Resources
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: false
|
||||
#
|
||||
# Cookbook Name:: postgresql
|
||||
# Cookbook:: postgresql
|
||||
# Library:: default
|
||||
# Author:: David Crane (<davidc@donorschoose.org>)
|
||||
#
|
||||
@@ -20,186 +21,179 @@ include Chef::Mixin::ShellOut
|
||||
|
||||
module Opscode
|
||||
module PostgresqlHelpers
|
||||
|
||||
#######
|
||||
# Function to truncate value to 4 significant bits, render human readable.
|
||||
# Used in recipes/config_initdb.rb to set this attribute:
|
||||
#
|
||||
# The memory settings (shared_buffers, effective_cache_size, work_mem,
|
||||
# maintenance_work_mem and wal_buffers) will be rounded down to keep
|
||||
# the 4 most significant bits, so that SHOW will be likely to use a
|
||||
# larger divisor. The output is actually a human readable string that
|
||||
# ends with "GB", "MB" or "kB" if over 1023, exactly what Postgresql
|
||||
# will expect in a postgresql.conf setting. The output may be up to
|
||||
# 6.25% less than the original value because of the rounding.
|
||||
def binaryround(value)
|
||||
|
||||
# Keep a multiplier which grows through powers of 1
|
||||
multiplier = 1
|
||||
|
||||
# Truncate value to 4 most significant bits
|
||||
while value >= 16
|
||||
value = (value / 2).floor
|
||||
multiplier = multiplier * 2
|
||||
end
|
||||
|
||||
# Factor any remaining powers of 2 into the multiplier
|
||||
while value == 2*((value / 2).floor)
|
||||
value = (value / 2).floor
|
||||
multiplier = multiplier * 2
|
||||
end
|
||||
|
||||
# Factor enough powers of 2 back into the value to
|
||||
# leave the multiplier as a power of 1024 that can
|
||||
# be represented as units of "GB", "MB" or "kB".
|
||||
if multiplier >= 1024*1024*1024
|
||||
while multiplier > 1024*1024*1024
|
||||
value = 2*value
|
||||
multiplier = (multiplier/2).floor
|
||||
end
|
||||
multiplier = 1
|
||||
units = "GB"
|
||||
|
||||
elsif multiplier >= 1024*1024
|
||||
while multiplier > 1024*1024
|
||||
value = 2*value
|
||||
multiplier = (multiplier/2).floor
|
||||
end
|
||||
multiplier = 1
|
||||
units = "MB"
|
||||
|
||||
elsif multiplier >= 1024
|
||||
while multiplier > 1024
|
||||
value = 2*value
|
||||
multiplier = (multiplier/2).floor
|
||||
end
|
||||
multiplier = 1
|
||||
units = "kB"
|
||||
|
||||
else
|
||||
units = ""
|
||||
end
|
||||
|
||||
# Now we can return a nice human readable string.
|
||||
return "#{multiplier * value}#{units}"
|
||||
end
|
||||
|
||||
#######
|
||||
# Locale Configuration
|
||||
|
||||
# Function to test the date order.
|
||||
# Used in recipes/config_initdb.rb to set this attribute:
|
||||
# node.default['postgresql']['config']['datestyle']
|
||||
def locale_date_order
|
||||
# Test locale conversion of mon=11, day=22, year=33
|
||||
testtime = DateTime.new(2033,11,22,0,0,0,"-00:00")
|
||||
#=> #<DateTime: 2033-11-22T00:00:00-0000 ...>
|
||||
|
||||
# %x - Preferred representation for the date alone, no time
|
||||
res = testtime.strftime("%x")
|
||||
|
||||
if res.nil?
|
||||
return 'mdy'
|
||||
end
|
||||
|
||||
posM = res.index("11")
|
||||
posD = res.index("22")
|
||||
posY = res.index("33")
|
||||
|
||||
if (posM.nil? || posD.nil? || posY.nil?)
|
||||
return 'mdy'
|
||||
elseif (posY < posM && posM < posD)
|
||||
return 'ymd'
|
||||
elseif (posD < posM)
|
||||
return 'dmy'
|
||||
else
|
||||
return 'mdy'
|
||||
end
|
||||
end
|
||||
|
||||
#######
|
||||
# Timezone Configuration
|
||||
require 'find'
|
||||
|
||||
# Function to determine where the system stored shared timezone data.
|
||||
# Used in recipes/config_initdb.rb to detemine where it should have
|
||||
# select_default_timezone(tzdir) search.
|
||||
def pg_TZDIR()
|
||||
# System time zone conversions are controlled by a timezone data file
|
||||
# identified through environment variables (TZ and TZDIR) and/or file
|
||||
# and directory naming conventions specific to the Linux distribution.
|
||||
# Each of these timezone names will have been loaded into the PostgreSQL
|
||||
# pg_timezone_names view by the package maintainer.
|
||||
#######
|
||||
# Function to truncate value to 4 significant bits, render human readable.
|
||||
# Used in recipes/config_initdb.rb to set this attribute:
|
||||
#
|
||||
# Instead of using the timezone name configured as the system default,
|
||||
# the PostgreSQL server uses ones named in postgresql.conf settings
|
||||
# (timezone and log_timezone). The initdb utility does initialize those
|
||||
# settings to the timezone name that corresponds to the system default.
|
||||
#
|
||||
# The system's timezone name is actually a filename relative to the
|
||||
# shared zoneinfo directory. That is usually /usr/share/zoneinfo, but
|
||||
# it was /usr/lib/zoneinfo in older distributions and can be anywhere
|
||||
# if specified by the environment variable TZDIR. The tzset(3) manpage
|
||||
# seems to indicate the following precedence:
|
||||
tzdir = nil
|
||||
if ::File.directory?("/usr/lib/zoneinfo")
|
||||
tzdir = "/usr/lib/zoneinfo"
|
||||
else
|
||||
share_path = [ ENV['TZDIR'], "/usr/share/zoneinfo" ].compact.first
|
||||
if ::File.directory?(share_path)
|
||||
tzdir = share_path
|
||||
# The memory settings (shared_buffers, effective_cache_size, work_mem,
|
||||
# maintenance_work_mem and wal_buffers) will be rounded down to keep
|
||||
# the 4 most significant bits, so that SHOW will be likely to use a
|
||||
# larger divisor. The output is actually a human readable string that
|
||||
# ends with "GB", "MB" or "kB" if over 1023, exactly what Postgresql
|
||||
# will expect in a postgresql.conf setting. The output may be up to
|
||||
# 6.25% less than the original value because of the rounding.
|
||||
def binaryround(value)
|
||||
# Keep a multiplier which grows through powers of 1
|
||||
multiplier = 1
|
||||
|
||||
# Truncate value to 4 most significant bits
|
||||
while value >= 16
|
||||
value = (value / 2).floor
|
||||
multiplier *= 2
|
||||
end
|
||||
|
||||
# Factor any remaining powers of 2 into the multiplier
|
||||
while value == 2 * (value / 2).floor
|
||||
value = (value / 2).floor
|
||||
multiplier *= 2
|
||||
end
|
||||
|
||||
# Factor enough powers of 2 back into the value to
|
||||
# leave the multiplier as a power of 1024 that can
|
||||
# be represented as units of "GB", "MB" or "kB".
|
||||
if multiplier >= 1024 * 1024 * 1024
|
||||
while multiplier > 1024 * 1024 * 1024
|
||||
value = 2 * value
|
||||
multiplier = (multiplier / 2).floor
|
||||
end
|
||||
multiplier = 1
|
||||
units = 'GB'
|
||||
|
||||
elsif multiplier >= 1024 * 1024
|
||||
while multiplier > 1024 * 1024
|
||||
value = 2 * value
|
||||
multiplier = (multiplier / 2).floor
|
||||
end
|
||||
multiplier = 1
|
||||
units = 'MB'
|
||||
|
||||
elsif multiplier >= 1024
|
||||
while multiplier > 1024
|
||||
value = 2 * value
|
||||
multiplier = (multiplier / 2).floor
|
||||
end
|
||||
multiplier = 1
|
||||
units = 'kB'
|
||||
|
||||
else
|
||||
units = ''
|
||||
end
|
||||
|
||||
# Now we can return a nice human readable string.
|
||||
"#{multiplier * value}#{units}"
|
||||
end
|
||||
return tzdir
|
||||
end
|
||||
|
||||
#######
|
||||
# Function to support select_default_timezone(tzdir), which is
|
||||
# used in recipes/config_initdb.rb.
|
||||
def validate_zone(tzname)
|
||||
# PostgreSQL does not support leap seconds, so this function tests
|
||||
# the usual Linux tzname convention to avoid a misconfiguration.
|
||||
# Assume that the tzdata package maintainer has kept all timezone
|
||||
# data files with support for leap seconds is kept under the
|
||||
# so-named "right/" subdir of the shared zoneinfo directory.
|
||||
#
|
||||
# The original PostgreSQL initdb is not Unix-specific, so it did a
|
||||
# very complicated, thorough test in its pg_tz_acceptable() function
|
||||
# that I could not begin to understand how to do in ruby :).
|
||||
#
|
||||
# Testing the tzname is good enough, since a misconfiguration
|
||||
# will result in an immediate fatal error when the PostgreSQL
|
||||
# service is started, with pgstartup.log messages such as:
|
||||
# LOG: time zone "right/US/Eastern" appears to use leap seconds
|
||||
# DETAIL: PostgreSQL does not support leap seconds.
|
||||
#######
|
||||
# Locale Configuration
|
||||
|
||||
if tzname.index("right/") == 0
|
||||
return false
|
||||
else
|
||||
return true
|
||||
# Function to test the date order.
|
||||
# Used in recipes/config_initdb.rb to set this attribute:
|
||||
# node.default['postgresql']['config']['datestyle']
|
||||
def locale_date_order
|
||||
# Test locale conversion of mon=11, day=22, year=33
|
||||
testtime = DateTime.new(2033, 11, 22, 0, 0, 0, '-00:00')
|
||||
#=> #<DateTime: 2033-11-22T00:00:00-0000 ...>
|
||||
|
||||
# %x - Preferred representation for the date alone, no time
|
||||
res = testtime.strftime('%x')
|
||||
|
||||
return 'mdy' if res.nil?
|
||||
|
||||
posM = res.index('11')
|
||||
posD = res.index('22')
|
||||
posY = res.index('33')
|
||||
|
||||
if posM.nil? || posD.nil? || posY.nil?
|
||||
return 'mdy'
|
||||
elseif (posY < posM && posM < posD)
|
||||
return 'ymd'
|
||||
elseif (posD < posM)
|
||||
return 'dmy'
|
||||
end
|
||||
'mdy'
|
||||
end
|
||||
end
|
||||
|
||||
# Function to support select_default_timezone(tzdir), which is
|
||||
# used in recipes/config_initdb.rb.
|
||||
def scan_available_timezones(tzdir)
|
||||
# There should be an /etc/localtime zoneinfo file that is a link to
|
||||
# (or a copy of) a timezone data file under tzdir, which should have
|
||||
# been installed under the "share" directory by the tzdata package.
|
||||
#
|
||||
# The initdb utility determines which shared timezone file is being
|
||||
# used as the system's default /etc/localtime. The timezone name is
|
||||
# the timezone file path relative to the tzdir.
|
||||
#######
|
||||
# Timezone Configuration
|
||||
require 'find'
|
||||
|
||||
bestzonename = nil
|
||||
# Function to determine where the system stored shared timezone data.
|
||||
# Used in recipes/config_initdb.rb to detemine where it should have
|
||||
# select_default_timezone(tzdir) search.
|
||||
def pg_TZDIR
|
||||
# System time zone conversions are controlled by a timezone data file
|
||||
# identified through environment variables (TZ and TZDIR) and/or file
|
||||
# and directory naming conventions specific to the Linux distribution.
|
||||
# Each of these timezone names will have been loaded into the PostgreSQL
|
||||
# pg_timezone_names view by the package maintainer.
|
||||
#
|
||||
# Instead of using the timezone name configured as the system default,
|
||||
# the PostgreSQL server uses ones named in postgresql.conf settings
|
||||
# (timezone and log_timezone). The initdb utility does initialize those
|
||||
# settings to the timezone name that corresponds to the system default.
|
||||
#
|
||||
# The system's timezone name is actually a filename relative to the
|
||||
# shared zoneinfo directory. That is usually /usr/share/zoneinfo, but
|
||||
# it was /usr/lib/zoneinfo in older distributions and can be anywhere
|
||||
# if specified by the environment variable TZDIR. The tzset(3) manpage
|
||||
# seems to indicate the following precedence:
|
||||
tzdir = nil
|
||||
if ::File.directory?('/usr/lib/zoneinfo')
|
||||
tzdir = '/usr/lib/zoneinfo'
|
||||
else
|
||||
share_path = [ENV['TZDIR'], '/usr/share/zoneinfo'].compact.first
|
||||
tzdir = share_path if ::File.directory?(share_path)
|
||||
end
|
||||
tzdir
|
||||
end
|
||||
|
||||
if (tzdir.nil?)
|
||||
Chef::Log.error("The zoneinfo directory not found (looked for /usr/share/zoneinfo and /usr/lib/zoneinfo)")
|
||||
elsif !::File.exists?("/etc/localtime")
|
||||
Chef::Log.error("The system zoneinfo file not found (looked for /etc/localtime)")
|
||||
elsif ::File.directory?("/etc/localtime")
|
||||
Chef::Log.error("The system zoneinfo file not found (/etc/localtime is a directory instead)")
|
||||
elsif ::File.symlink?("/etc/localtime")
|
||||
#######
|
||||
# Function to support select_default_timezone(tzdir), which is
|
||||
# used in recipes/config_initdb.rb.
|
||||
def validate_zone(tzname)
|
||||
# PostgreSQL does not support leap seconds, so this function tests
|
||||
# the usual Linux tzname convention to avoid a misconfiguration.
|
||||
# Assume that the tzdata package maintainer has kept all timezone
|
||||
# data files with support for leap seconds is kept under the
|
||||
# so-named "right/" subdir of the shared zoneinfo directory.
|
||||
#
|
||||
# The original PostgreSQL initdb is not Unix-specific, so it did a
|
||||
# very complicated, thorough test in its pg_tz_acceptable() function
|
||||
# that I could not begin to understand how to do in ruby :).
|
||||
#
|
||||
# Testing the tzname is good enough, since a misconfiguration
|
||||
# will result in an immediate fatal error when the PostgreSQL
|
||||
# service is started, with pgstartup.log messages such as:
|
||||
# LOG: time zone "right/US/Eastern" appears to use leap seconds
|
||||
# DETAIL: PostgreSQL does not support leap seconds.
|
||||
|
||||
if tzname.index('right/') == 0
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
# Function to support select_default_timezone(tzdir), which is
|
||||
# used in recipes/config_initdb.rb.
|
||||
def scan_available_timezones(tzdir)
|
||||
# There should be an /etc/localtime zoneinfo file that is a link to
|
||||
# (or a copy of) a timezone data file under tzdir, which should have
|
||||
# been installed under the "share" directory by the tzdata package.
|
||||
#
|
||||
# The initdb utility determines which shared timezone file is being
|
||||
# used as the system's default /etc/localtime. The timezone name is
|
||||
# the timezone file path relative to the tzdir.
|
||||
|
||||
bestzonename = nil
|
||||
|
||||
if tzdir.nil?
|
||||
Chef::Log.error('The zoneinfo directory not found (looked for /usr/share/zoneinfo and /usr/lib/zoneinfo)')
|
||||
elsif !::File.exist?('/etc/localtime')
|
||||
Chef::Log.error('The system zoneinfo file not found (looked for /etc/localtime)')
|
||||
elsif ::File.directory?('/etc/localtime')
|
||||
Chef::Log.error('The system zoneinfo file not found (/etc/localtime is a directory instead)')
|
||||
elsif ::File.symlink?('/etc/localtime')
|
||||
# PostgreSQL initdb doesn't use the symlink target, but this
|
||||
# certainly will make sense to any system administrator. A full
|
||||
# scan of the tzdir to find the shortest filename could result
|
||||
@@ -207,147 +201,107 @@ def scan_available_timezones(tzdir)
|
||||
# in spite of what the sysadmin had specified in the symlink.
|
||||
# (There are many duplicates under tzdir, with the same timezone
|
||||
# content appearing as an average of 2-3 different file names.)
|
||||
path = ::File.readlink("/etc/localtime")
|
||||
bestzonename = path.gsub("#{tzdir}/","")
|
||||
else # /etc/localtime is a file, so scan for it under tzdir
|
||||
localtime_content = File.read("/etc/localtime")
|
||||
path = ::File.realdirpath('/etc/localtime')
|
||||
bestzonename = path.gsub("#{tzdir}/", '')
|
||||
else # /etc/localtime is a file, so scan for it under tzdir
|
||||
localtime_content = File.read('/etc/localtime')
|
||||
|
||||
Find.find(tzdir) do |path|
|
||||
# Only consider files (skip directories or symlinks)
|
||||
if !::File.directory?(path) && !::File.symlink?(path)
|
||||
# Ignore any file named "posixrules" or "localtime"
|
||||
if ::File.basename(path) != "posixrules" && ::File.basename(path) != "localtime"
|
||||
# Do consider if content exactly matches /etc/localtime.
|
||||
if localtime_content == File.read(path)
|
||||
tzname = path.gsub("#{tzdir}/","")
|
||||
if validate_zone(tzname)
|
||||
if (bestzonename.nil? ||
|
||||
tzname.length < bestzonename.length ||
|
||||
(tzname.length == bestzonename.length &&
|
||||
(tzname <=> bestzonename) < 0)
|
||||
)
|
||||
bestzonename = tzname
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# Only consider files (skip directories or symlinks)
|
||||
next unless !::File.directory?(path) && !::File.symlink?(path)
|
||||
# Ignore any file named "posixrules" or "localtime"
|
||||
next unless ::File.basename(path) != 'posixrules' && ::File.basename(path) != 'localtime'
|
||||
# Do consider if content exactly matches /etc/localtime.
|
||||
next unless localtime_content == File.read(path)
|
||||
tzname = path.gsub("#{tzdir}/", '')
|
||||
next unless validate_zone(tzname)
|
||||
if bestzonename.nil? ||
|
||||
tzname.length < bestzonename.length ||
|
||||
(tzname.length == bestzonename.length &&
|
||||
(tzname <=> bestzonename) < 0)
|
||||
|
||||
bestzonename = tzname
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
bestzonename
|
||||
end
|
||||
|
||||
return bestzonename
|
||||
end
|
||||
# Function to support select_default_timezone(tzdir), which is
|
||||
# used in recipes/config_initdb.rb.
|
||||
def identify_system_timezone(tzdir)
|
||||
resultbuf = scan_available_timezones(tzdir)
|
||||
|
||||
# Function to support select_default_timezone(tzdir), which is
|
||||
# used in recipes/config_initdb.rb.
|
||||
def identify_system_timezone(tzdir)
|
||||
resultbuf = scan_available_timezones(tzdir)
|
||||
|
||||
if !resultbuf.nil?
|
||||
if !resultbuf.nil?
|
||||
# Ignore Olson's rather silly "Factory" zone; use GMT instead
|
||||
if (resultbuf <=> "Factory") == 0
|
||||
resultbuf = nil
|
||||
end
|
||||
resultbuf = nil if (resultbuf <=> 'Factory') == 0
|
||||
|
||||
else
|
||||
else
|
||||
# Did not find the timezone. Fallback to use a GMT zone. Note that the
|
||||
# Olson timezone database names the GMT-offset zones in POSIX style: plus
|
||||
# is west of Greenwich.
|
||||
testtime = DateTime.now
|
||||
std_ofs = testtime.strftime("%:z").split(":")[0].to_i
|
||||
std_ofs = testtime.strftime('%:z').split(':')[0].to_i
|
||||
|
||||
resultbuf = [
|
||||
"Etc/GMT",
|
||||
(-std_ofs > 0) ? "+" : "",
|
||||
(-std_ofs).to_s
|
||||
].join('')
|
||||
'Etc/GMT',
|
||||
-std_ofs > 0 ? '+' : '',
|
||||
(-std_ofs).to_s,
|
||||
].join('')
|
||||
end
|
||||
|
||||
resultbuf
|
||||
end
|
||||
|
||||
return resultbuf
|
||||
end
|
||||
#######
|
||||
# Function to determine the name of the system's default timezone.
|
||||
# Used in recipes/config_initdb.rb to set these attributes:
|
||||
# node.default['postgresql']['config']['log_timezone']
|
||||
# node.default['postgresql']['config']['timezone']
|
||||
def select_default_timezone(tzdir)
|
||||
system_timezone = nil
|
||||
|
||||
#######
|
||||
# Function to determine the name of the system's default timezone.
|
||||
# Used in recipes/config_initdb.rb to set these attributes:
|
||||
# node.default['postgresql']['config']['log_timezone']
|
||||
# node.default['postgresql']['config']['timezone']
|
||||
def select_default_timezone(tzdir)
|
||||
|
||||
system_timezone = nil
|
||||
|
||||
# Check TZ environment variable
|
||||
tzname = ENV['TZ']
|
||||
if !tzname.nil? && !tzname.empty? && validate_zone(tzname)
|
||||
# Check TZ environment variable
|
||||
tzname = ENV['TZ']
|
||||
if !tzname.nil? && !tzname.empty? && validate_zone(tzname)
|
||||
system_timezone = tzname
|
||||
|
||||
else
|
||||
else
|
||||
# Nope, so try to identify system timezone from /etc/localtime
|
||||
tzname = identify_system_timezone(tzdir)
|
||||
if validate_zone(tzname)
|
||||
system_timezone = tzname
|
||||
end
|
||||
system_timezone = tzname if validate_zone(tzname)
|
||||
end
|
||||
|
||||
system_timezone
|
||||
end
|
||||
|
||||
return system_timezone
|
||||
end
|
||||
|
||||
#######
|
||||
# Function to determine the name of the system's default timezone.
|
||||
def get_result_orig(query)
|
||||
# query could be a String or an Array of String
|
||||
if (query.is_a?(String))
|
||||
stdin = query
|
||||
else
|
||||
stdin = query.join("\n")
|
||||
end
|
||||
@get_result ||= begin
|
||||
cmd = shell_out("cat", :input => stdin)
|
||||
cmd.stdout
|
||||
end
|
||||
end
|
||||
|
||||
#######
|
||||
# Function to execute an SQL statement in the default database.
|
||||
# Input: Query could be a single String or an Array of String.
|
||||
# Output: A String with |-separated columns and \n-separated rows.
|
||||
# Note an empty output could mean psql couldn't connect.
|
||||
# This is easiest for 1-field (1-row, 1-col) results, otherwise
|
||||
# it will be complex to parse the results.
|
||||
def execute_sql(query)
|
||||
db_name = node['postgresql']['database_name']
|
||||
# query could be a String or an Array of String
|
||||
statement = query.is_a?(String) ? query : query.join("\n")
|
||||
@execute_sql ||= begin
|
||||
cmd = shell_out("psql -q --tuples-only --no-align -d #{db_name} -f -",
|
||||
:user => "postgres",
|
||||
:input => statement
|
||||
)
|
||||
# If psql fails, generally the postgresql service is down.
|
||||
# Instead of aborting chef with a fatal error, let's just
|
||||
# pass these non-zero exitstatus back as empty cmd.stdout.
|
||||
if (cmd.exitstatus() == 0 and !cmd.stderr.empty?)
|
||||
# An SQL failure is still a zero exitstatus, but then the
|
||||
# stderr explains the error, so let's rais that as fatal.
|
||||
Chef::Log.fatal("psql failed executing this SQL statement:\n#{statement}")
|
||||
Chef::Log.fatal(cmd.stderr)
|
||||
raise "SQL ERROR"
|
||||
#######
|
||||
# Function to execute an SQL statement in the default database.
|
||||
# Input: Query could be a single String or an Array of String.
|
||||
# Output: A String with |-separated columns and \n-separated rows.
|
||||
# Note an empty output could mean psql couldn't connect.
|
||||
# This is easiest for 1-field (1-row, 1-col) results, otherwise
|
||||
# it will be complex to parse the results.
|
||||
def execute_sql(query, db_name = node['postgresql']['database_name'])
|
||||
# query could be a String or an Array of String
|
||||
statement = query.is_a?(String) ? query : query.join("\n")
|
||||
cmd = shell_out("psql -q --tuples-only --no-align -d #{db_name} -f -",
|
||||
user: 'postgres',
|
||||
input: statement)
|
||||
# If psql fails, generally the postgresql service is down.
|
||||
# Instead of aborting chef with a fatal error, let's just
|
||||
# pass these non-zero exitstatus back as empty cmd.stdout.
|
||||
if cmd.exitstatus == 0 && !cmd.stderr.empty?
|
||||
# An SQL failure is still a zero exitstatus, but then the
|
||||
# stderr explains the error, so let's rais that as fatal.
|
||||
Chef::Log.fatal("psql failed executing this SQL statement:\n#{statement}")
|
||||
Chef::Log.fatal(cmd.stderr)
|
||||
raise 'SQL ERROR'
|
||||
end
|
||||
cmd.stdout.chomp
|
||||
end
|
||||
cmd.stdout.chomp
|
||||
end
|
||||
end
|
||||
|
||||
#######
|
||||
# Function to determine if a standard contrib extension is already installed.
|
||||
# Input: Extension name
|
||||
# Output: true or false
|
||||
# Best use as a not_if gate on bash "install-#{pg_ext}-extension" resource.
|
||||
def extension_installed?(pg_ext)
|
||||
@extension_installed ||= begin
|
||||
installed=execute_sql("select 'installed' from pg_extension where extname = '#{pg_ext}';")
|
||||
installed =~ /^installed$/
|
||||
end
|
||||
end
|
||||
|
||||
# End the Opscode::PostgresqlHelpers module
|
||||
# End the Opscode::PostgresqlHelpers module
|
||||
end
|
||||
end
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,28 +0,0 @@
|
||||
name "postgresql"
|
||||
maintainer "Heavy Water Operations, LLC"
|
||||
maintainer_email "helpdesk@heavywater.io"
|
||||
license "Apache 2.0"
|
||||
description "Installs and configures postgresql for clients or servers"
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version "4.0.0"
|
||||
recipe "postgresql", "Includes postgresql::client"
|
||||
recipe "postgresql::ruby", "Installs pg gem for Ruby bindings"
|
||||
recipe "postgresql::client", "Installs postgresql client package(s)"
|
||||
recipe "postgresql::server", "Installs postgresql server packages, templates"
|
||||
recipe "postgresql::server_redhat", "Installs postgresql server packages, redhat family style"
|
||||
recipe "postgresql::server_debian", "Installs postgresql server packages, debian family style"
|
||||
|
||||
|
||||
supports "ubuntu", "< 14.10"
|
||||
|
||||
%w{debian fedora suse opensuse amazon}.each do |os|
|
||||
supports os
|
||||
end
|
||||
|
||||
%w{redhat centos scientific oracle}.each do |el|
|
||||
supports el, "~> 6.0"
|
||||
end
|
||||
|
||||
depends "apt", ">= 1.9.0"
|
||||
depends "build-essential"
|
||||
depends "openssl", "~> 4.0"
|
||||
@@ -1,14 +1,4 @@
|
||||
if not %w(jessie squeeze wheezy sid lucid precise saucy trusty utopic).include? node['postgresql']['pgdg']['release_apt_codename']
|
||||
raise "Not supported release by PGDG apt repository"
|
||||
end
|
||||
|
||||
include_recipe 'apt'
|
||||
|
||||
file "remove deprecated Pitti PPA apt repository" do
|
||||
action :delete
|
||||
path "/etc/apt/sources.list.d/pitti-postgresql-ppa"
|
||||
end
|
||||
|
||||
# frozen_string_literal: true
|
||||
apt_repository 'apt.postgresql.org' do
|
||||
uri 'http://apt.postgresql.org/pub/repos/apt'
|
||||
distribution "#{node['postgresql']['pgdg']['release_apt_codename']}-pgdg"
|
||||
|
||||
@@ -1,6 +1,2 @@
|
||||
# some older linux distributions have expired certificate bundles
|
||||
# for pgdg repositories. Upgrading this package before trying to
|
||||
# install postgresql is necessary.
|
||||
package "ca-certificates" do
|
||||
action :upgrade
|
||||
end
|
||||
# frozen_string_literal: true
|
||||
Chef::Log.warn('The postgresql::ca-certificates recipe has been deprecated and will be removed in the next major release of the cookbook')
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Cookbook Name:: postgresql
|
||||
# Cookbook:: postgresql
|
||||
# Recipe:: client
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -15,23 +16,19 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe "postgresql::ca_certificates"
|
||||
|
||||
case node['platform_family']
|
||||
when 'debian'
|
||||
if node['postgresql']['version'].to_f > 9.3
|
||||
node.set['postgresql']['enable_pgdg_apt'] = true
|
||||
node.normal['postgresql']['enable_pgdg_apt'] = true
|
||||
end
|
||||
|
||||
if node['postgresql']['enable_pgdg_apt']
|
||||
include_recipe 'postgresql::apt_pgdg_postgresql'
|
||||
end
|
||||
when 'rhel'
|
||||
when 'rhel', 'fedora'
|
||||
if node['postgresql']['enable_pgdg_yum']
|
||||
include_recipe 'postgresql::yum_pgdg_postgresql'
|
||||
end
|
||||
end
|
||||
|
||||
node['postgresql']['client']['packages'].each do |pkg|
|
||||
package pkg
|
||||
end
|
||||
package node['postgresql']['client']['packages']
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Cookbook Name:: postgresql
|
||||
# Cookbook:: postgresql
|
||||
# Recipe:: config_initdb
|
||||
# Author:: David Crane (<davidc@donorschoose.org>)
|
||||
#
|
||||
@@ -69,23 +70,23 @@
|
||||
# Locale Configuration
|
||||
|
||||
# See libraries/default.rb for the locale_date_order() method.
|
||||
node.default['postgresql']['config']['datestyle'] = "iso, #{locale_date_order()}"
|
||||
node.default['postgresql']['config']['datestyle'] = "iso, #{locale_date_order}"
|
||||
|
||||
# According to the locale(1) manpage, the locale settings are determined
|
||||
# by environment variables according to the following precedence:
|
||||
# LC_ALL > (LC_MESSAGES, LC_MONETARY, LC_NUMERIC, LC_TIME) > LANG.
|
||||
|
||||
node.default['postgresql']['config']['lc_messages'] =
|
||||
[ ENV['LC_ALL'], ENV['LC_MESSAGES'], ENV['LANG'] ].compact.first
|
||||
[ENV['LC_ALL'], ENV['LC_MESSAGES'], ENV['LANG']].compact.first
|
||||
|
||||
node.default['postgresql']['config']['lc_monetary'] =
|
||||
[ ENV['LC_ALL'], ENV['LC_MONETARY'], ENV['LANG'] ].compact.first
|
||||
[ENV['LC_ALL'], ENV['LC_MONETARY'], ENV['LANG']].compact.first
|
||||
|
||||
node.default['postgresql']['config']['lc_numeric'] =
|
||||
[ ENV['LC_ALL'], ENV['LC_NUMERIC'], ENV['LANG'] ].compact.first
|
||||
[ENV['LC_ALL'], ENV['LC_NUMERIC'], ENV['LANG']].compact.first
|
||||
|
||||
node.default['postgresql']['config']['lc_time'] =
|
||||
[ ENV['LC_ALL'], ENV['LC_TIME'], ENV['LANG'] ].compact.first
|
||||
[ENV['LC_ALL'], ENV['LC_TIME'], ENV['LANG']].compact.first
|
||||
|
||||
node.default['postgresql']['config']['default_text_search_config'] =
|
||||
case ENV['LANG']
|
||||
@@ -119,8 +120,6 @@ node.default['postgresql']['config']['default_text_search_config'] =
|
||||
'pg_catalog.swedish'
|
||||
when /tr_.*/
|
||||
'pg_catalog.turkish'
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
||||
#######
|
||||
@@ -130,11 +129,11 @@ node.default['postgresql']['config']['default_text_search_config'] =
|
||||
# defaults for the postgresql.cof settings. If the timezone cannot be
|
||||
# identified, do as initdb would do: leave it unspecified so PostgreSQL
|
||||
# uses it's internal default of GMT.
|
||||
tzdirpath = pg_TZDIR() # See libraries/default.rb
|
||||
tzdirpath = pg_TZDIR # See libraries/default.rb
|
||||
default_timezone = select_default_timezone(tzdirpath) # See libraries/default.rb
|
||||
if !default_timezone.nil?
|
||||
node.default['postgresql']['config']['log_timezone'] = default_timezone
|
||||
node.default['postgresql']['config']['timezone'] = default_timezone
|
||||
unless default_timezone.nil?
|
||||
node.default['postgresql']['config']['log_timezone'] = default_timezone
|
||||
node.default['postgresql']['config']['timezone'] = default_timezone
|
||||
end
|
||||
|
||||
#######
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Cookbook Name:: postgresql
|
||||
# Cookbook:: postgresql
|
||||
# Recipe:: config_pgtune
|
||||
# Author:: David Crane (<davidc@donorschoose.org>)
|
||||
#
|
||||
@@ -86,35 +87,35 @@
|
||||
# Parse out db_type option, or use default.
|
||||
db_type = 'mixed'
|
||||
|
||||
if (node['postgresql'].attribute?('config_pgtune') && node['postgresql']['config_pgtune'].attribute?('db_type'))
|
||||
if node['postgresql'].attribute?('config_pgtune') && node['postgresql']['config_pgtune'].attribute?('db_type')
|
||||
db_type = node['postgresql']['config_pgtune']['db_type']
|
||||
if (!(["dw","oltp","web","mixed","desktop"].include?(db_type)))
|
||||
unless %w(dw oltp web mixed desktop).include?(db_type)
|
||||
Chef::Log.fatal([
|
||||
"Bad value (#{db_type})",
|
||||
"for node['postgresql']['config_pgtune']['db_type'] attribute.",
|
||||
"Valid values are one of dw, oltp, web, mixed, desktop."
|
||||
].join(' '))
|
||||
"Bad value (#{db_type})",
|
||||
"for node['postgresql']['config_pgtune']['db_type'] attribute.",
|
||||
'Valid values are one of dw, oltp, web, mixed, desktop.',
|
||||
].join(' '))
|
||||
raise
|
||||
end
|
||||
end
|
||||
|
||||
# Parse out max_connections option, or use a value based on db_type.
|
||||
con =
|
||||
{ "web" => 200,
|
||||
"oltp" => 300,
|
||||
"dw" => 20,
|
||||
"mixed" => 80,
|
||||
"desktop" => 5
|
||||
}.fetch(db_type)
|
||||
{ 'web' => 200,
|
||||
'oltp' => 300,
|
||||
'dw' => 20,
|
||||
'mixed' => 80,
|
||||
'desktop' => 5,
|
||||
}.fetch(db_type)
|
||||
|
||||
if (node['postgresql'].attribute?('config_pgtune') && node['postgresql']['config_pgtune'].attribute?('max_connections'))
|
||||
if node['postgresql'].attribute?('config_pgtune') && node['postgresql']['config_pgtune'].attribute?('max_connections')
|
||||
max_connections = node['postgresql']['config_pgtune']['max_connections'].to_i
|
||||
if max_connections <= 0
|
||||
Chef::Log.fatal([
|
||||
"Bad value (#{max_connections})",
|
||||
"for node['postgresql']['config_pgtune']['max_connections'] attribute.",
|
||||
"Valid values are non-zero integers only."
|
||||
].join(' '))
|
||||
"Bad value (#{max_connections})",
|
||||
"for node['postgresql']['config_pgtune']['max_connections'] attribute.",
|
||||
'Valid values are non-zero integers only.',
|
||||
].join(' '))
|
||||
raise
|
||||
end
|
||||
con = max_connections
|
||||
@@ -125,19 +126,19 @@ total_memory = node['memory']['total']
|
||||
|
||||
# Override max_connections with a node attribute if DevOps desires.
|
||||
# For example, on a system *not* dedicated to Postgresql.
|
||||
if (node['postgresql'].attribute?('config_pgtune') && node['postgresql']['config_pgtune'].attribute?('total_memory'))
|
||||
if node['postgresql'].attribute?('config_pgtune') && node['postgresql']['config_pgtune'].attribute?('total_memory')
|
||||
total_memory = node['postgresql']['config_pgtune']['total_memory']
|
||||
if (total_memory.match(/\A[1-9]\d*kB\Z/) == nil)
|
||||
if total_memory.match(/\A[1-9]\d*kB\Z/).nil?
|
||||
Chef::Application.fatal!([
|
||||
"Bad value (#{total_memory})",
|
||||
"for node['postgresql']['config_pgtune']['total_memory'] attribute.",
|
||||
"Valid values are non-zero integers followed by kB (e.g., 49416564kB)."
|
||||
].join(' '))
|
||||
"Bad value (#{total_memory})",
|
||||
"for node['postgresql']['config_pgtune']['total_memory'] attribute.",
|
||||
'Valid values are non-zero integers followed by kB (e.g., 49416564kB).',
|
||||
].join(' '))
|
||||
end
|
||||
end
|
||||
|
||||
# Ohai reports node[:memory][:total] in kB, as in "921756kB"
|
||||
mem = total_memory.split("kB")[0].to_i / 1024 # in MB
|
||||
mem = total_memory.split('kB')[0].to_i / 1024 # in MB
|
||||
|
||||
#######
|
||||
# RAM-related settings computed as in Greg Smith's pgtune script.
|
||||
@@ -152,79 +153,73 @@ node.default['postgresql']['config']['max_connections'] = con
|
||||
# for low memory systems. In that case, the calculation is skipped,
|
||||
# leaving the built-in Postgresql settings, which are actually
|
||||
# intended for those low memory systems.
|
||||
if (mem >= 256)
|
||||
if mem >= 256
|
||||
|
||||
# (2) shared_buffers
|
||||
# Sets the number of shared memory buffers used by the server.
|
||||
shared_buffers =
|
||||
{ "web" => mem/4,
|
||||
"oltp" => mem/4,
|
||||
"dw" => mem/4,
|
||||
"mixed" => mem/4,
|
||||
"desktop" => mem/16
|
||||
}.fetch(db_type)
|
||||
{ 'web' => mem / 4,
|
||||
'oltp' => mem / 4,
|
||||
'dw' => mem / 4,
|
||||
'mixed' => mem / 4,
|
||||
'desktop' => mem / 16,
|
||||
}.fetch(db_type)
|
||||
|
||||
# Robert Haas has advised to cap the size of shared_buffers based on
|
||||
# the memory architecture: 2GB on 32-bit and 8GB on 64-bit machines.
|
||||
# http://rhaas.blogspot.com/2012/03/tuning-sharedbuffers-and-walbuffers.html
|
||||
case node['kernel']['machine']
|
||||
when "i386" # 32-bit machines
|
||||
if shared_buffers > 2*1024
|
||||
shared_buffers = 2*1024
|
||||
end
|
||||
when "x86_64" # 64-bit machines
|
||||
if shared_buffers > 8*1024
|
||||
shared_buffers = 8*1024
|
||||
end
|
||||
when 'i386' # 32-bit machines
|
||||
shared_buffers = 2 * 1024 if shared_buffers > 2 * 1024
|
||||
when 'x86_64' # 64-bit machines
|
||||
shared_buffers = 8 * 1024 if shared_buffers > 8 * 1024
|
||||
end
|
||||
|
||||
node.default['postgresql']['config']['shared_buffers'] = binaryround(shared_buffers*1024*1024)
|
||||
node.default['postgresql']['config']['shared_buffers'] = binaryround(shared_buffers * 1024 * 1024)
|
||||
|
||||
# (3) effective_cache_size
|
||||
# Sets the planner's assumption about the size of the disk cache.
|
||||
# That is, the portion of the kernel's disk cache that will be
|
||||
# used for PostgreSQL data files.
|
||||
effective_cache_size =
|
||||
{ "web" => mem * 3 / 4,
|
||||
"oltp" => mem * 3 / 4,
|
||||
"dw" => mem * 3 / 4,
|
||||
"mixed" => mem * 3 / 4,
|
||||
"desktop" => mem / 4
|
||||
}.fetch(db_type)
|
||||
{ 'web' => mem * 3 / 4,
|
||||
'oltp' => mem * 3 / 4,
|
||||
'dw' => mem * 3 / 4,
|
||||
'mixed' => mem * 3 / 4,
|
||||
'desktop' => mem / 4,
|
||||
}.fetch(db_type)
|
||||
|
||||
node.default['postgresql']['config']['effective_cache_size'] = binaryround(effective_cache_size*1024*1024)
|
||||
node.default['postgresql']['config']['effective_cache_size'] = binaryround(effective_cache_size * 1024 * 1024)
|
||||
|
||||
# (4) work_mem
|
||||
# Sets the maximum memory to be used for query workspaces.
|
||||
mem_con_v = (mem.to_f / con).ceil
|
||||
|
||||
work_mem =
|
||||
{ "web" => mem_con_v,
|
||||
"oltp" => mem_con_v,
|
||||
"dw" => mem_con_v / 2,
|
||||
"mixed" => mem_con_v / 2,
|
||||
"desktop" => mem_con_v / 6
|
||||
{ 'web' => mem_con_v,
|
||||
'oltp' => mem_con_v,
|
||||
'dw' => mem_con_v / 2,
|
||||
'mixed' => mem_con_v / 2,
|
||||
'desktop' => mem_con_v / 6,
|
||||
}.fetch(db_type)
|
||||
|
||||
node.default['postgresql']['config']['work_mem'] = binaryround(work_mem*1024*1024)
|
||||
node.default['postgresql']['config']['work_mem'] = binaryround(work_mem * 1024 * 1024)
|
||||
|
||||
# (5) maintenance_work_mem
|
||||
# Sets the maximum memory to be used for maintenance operations.
|
||||
# This includes operations such as VACUUM and CREATE INDEX.
|
||||
maintenance_work_mem =
|
||||
{ "web" => mem / 16,
|
||||
"oltp" => mem / 16,
|
||||
"dw" => mem / 8,
|
||||
"mixed" => mem / 16,
|
||||
"desktop" => mem / 16
|
||||
}.fetch(db_type)
|
||||
{ 'web' => mem / 16,
|
||||
'oltp' => mem / 16,
|
||||
'dw' => mem / 8,
|
||||
'mixed' => mem / 16,
|
||||
'desktop' => mem / 16,
|
||||
}.fetch(db_type)
|
||||
|
||||
# Cap maintenence RAM at 1GB on servers with lots of memory
|
||||
if (maintenance_work_mem > 1*1024)
|
||||
maintenance_work_mem = 1*1024
|
||||
end
|
||||
maintenance_work_mem = 1 * 1024 if maintenance_work_mem > 1 * 1024
|
||||
|
||||
node.default['postgresql']['config']['maintenance_work_mem'] = binaryround(maintenance_work_mem*1024*1024)
|
||||
node.default['postgresql']['config']['maintenance_work_mem'] = binaryround(maintenance_work_mem * 1024 * 1024)
|
||||
|
||||
end
|
||||
|
||||
@@ -235,25 +230,29 @@ end
|
||||
# (6) checkpoint_segments
|
||||
# Sets the maximum distance in log segments between automatic WAL checkpoints.
|
||||
checkpoint_segments =
|
||||
{ "web" => 8,
|
||||
"oltp" => 16,
|
||||
"dw" => 64,
|
||||
"mixed" => 16,
|
||||
"desktop" => 3
|
||||
}.fetch(db_type)
|
||||
{ 'web' => 8,
|
||||
'oltp' => 16,
|
||||
'dw' => 64,
|
||||
'mixed' => 16,
|
||||
'desktop' => 3,
|
||||
}.fetch(db_type)
|
||||
|
||||
node.default['postgresql']['config']['checkpoint_segments'] = checkpoint_segments
|
||||
if node['postgresql']['version'].to_f >= 9.5
|
||||
node.default['postgresql']['config']['max_wal_size'] = ((3 * checkpoint_segments) * 16).to_s + 'MB'
|
||||
else
|
||||
node.default['postgresql']['config']['checkpoint_segments'] = checkpoint_segments
|
||||
end
|
||||
|
||||
# (7) checkpoint_completion_target
|
||||
# Time spent flushing dirty buffers during checkpoint, as fraction
|
||||
# of checkpoint interval.
|
||||
checkpoint_completion_target =
|
||||
{ "web" => "0.7",
|
||||
"oltp" => "0.9",
|
||||
"dw" => "0.9",
|
||||
"mixed" => "0.9",
|
||||
"desktop" => "0.5"
|
||||
}.fetch(db_type)
|
||||
{ 'web' => '0.7',
|
||||
'oltp' => '0.9',
|
||||
'dw' => '0.9',
|
||||
'mixed' => '0.9',
|
||||
'desktop' => '0.5',
|
||||
}.fetch(db_type)
|
||||
|
||||
node.default['postgresql']['config']['checkpoint_completion_target'] = checkpoint_completion_target
|
||||
|
||||
@@ -264,9 +263,9 @@ node.default['postgresql']['config']['checkpoint_completion_target'] = checkpoin
|
||||
if node['postgresql']['version'].to_f < 9.1
|
||||
wal_buffers = 512 * checkpoint_segments
|
||||
# The pgtune seems to use 1kB units for wal_buffers
|
||||
node.default['postgresql']['config']['wal_buffers'] = binaryround(wal_buffers*1024)
|
||||
node.default['postgresql']['config']['wal_buffers'] = binaryround(wal_buffers * 1024)
|
||||
else
|
||||
node.default['postgresql']['config']['wal_buffers'] = "-1"
|
||||
node.default['postgresql']['config']['wal_buffers'] = '-1'
|
||||
end
|
||||
|
||||
# (9) default_statistics_target
|
||||
@@ -274,11 +273,11 @@ end
|
||||
# that have not had a column-specific target set via
|
||||
# ALTER TABLE SET STATISTICS.
|
||||
default_statistics_target =
|
||||
{ "web" => 100,
|
||||
"oltp" => 100,
|
||||
"dw" => 500,
|
||||
"mixed" => 100,
|
||||
"desktop" => 100
|
||||
}.fetch(db_type)
|
||||
{ 'web' => 100,
|
||||
'oltp' => 100,
|
||||
'dw' => 500,
|
||||
'mixed' => 100,
|
||||
'desktop' => 100,
|
||||
}.fetch(db_type)
|
||||
|
||||
node.default['postgresql']['config']['default_statistics_target'] = default_statistics_target
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Cookbook Name:: postgresql
|
||||
# Cookbook:: postgresql
|
||||
# Recipe:: contrib
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -19,26 +20,14 @@ db_name = node['postgresql']['database_name']
|
||||
|
||||
# Install the PostgreSQL contrib package(s) from the distribution,
|
||||
# as specified by the node attributes.
|
||||
node['postgresql']['contrib']['packages'].each do |pg_pack|
|
||||
package node['postgresql']['contrib']['packages']
|
||||
|
||||
package pg_pack
|
||||
|
||||
end
|
||||
|
||||
include_recipe "postgresql::server"
|
||||
include_recipe 'postgresql::server'
|
||||
|
||||
# Install PostgreSQL contrib extentions into the database, as specified by the
|
||||
# node attribute node['postgresql']['database_name'].
|
||||
if (node['postgresql']['contrib'].attribute?('extensions'))
|
||||
if node['postgresql']['contrib'].attribute?('extensions')
|
||||
node['postgresql']['contrib']['extensions'].each do |pg_ext|
|
||||
bash "install-#{pg_ext}-extension" do
|
||||
user 'postgres'
|
||||
code <<-EOH
|
||||
echo 'CREATE EXTENSION IF NOT EXISTS "#{pg_ext}";' | psql -d "#{db_name}"
|
||||
EOH
|
||||
action :run
|
||||
::Chef::Resource.send(:include, Opscode::PostgresqlHelpers)
|
||||
not_if {extension_installed?(pg_ext)}
|
||||
end
|
||||
postgresql_extension "#{db_name}/#{pg_ext}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Cookbook Name:: postgresql
|
||||
# Cookbook:: postgresql
|
||||
# Recipe:: default
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -15,4 +16,4 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe "postgresql::client"
|
||||
include_recipe 'postgresql::client'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: false
|
||||
#
|
||||
# Cookbook Name:: postgresql
|
||||
# Cookbook:: postgresql
|
||||
# Recipe:: ruby
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -21,70 +22,51 @@
|
||||
begin
|
||||
require 'pg'
|
||||
rescue LoadError
|
||||
|
||||
if platform_family?('ubuntu', 'debian')
|
||||
e = execute 'apt-get update' do
|
||||
if platform_family?('debian')
|
||||
e = apt_update 'update' do
|
||||
action :nothing
|
||||
end
|
||||
e.run_action(:run) unless ::File.exists?('/var/lib/apt/periodic/update-success-stamp')
|
||||
e.run_action(:update)
|
||||
end
|
||||
|
||||
node.set['build-essential']['compile_time'] = true
|
||||
include_recipe "build-essential"
|
||||
node.override['build-essential']['compile_time'] = true
|
||||
include_recipe 'build-essential'
|
||||
|
||||
if node['postgresql']['enable_pgdg_yum']
|
||||
package "ca-certificates" do
|
||||
action :nothing
|
||||
end.run_action(:upgrade)
|
||||
|
||||
include_recipe "postgresql::yum_pgdg_postgresql"
|
||||
if node['postgresql']['enable_pgdg_yum'] && platform_family?('rhel', 'fedora')
|
||||
include_recipe 'postgresql::yum_pgdg_postgresql'
|
||||
|
||||
rpm_platform = node['platform']
|
||||
rpm_platform_version = node['platform_version'].to_f.to_i.to_s
|
||||
rpm_platform_version = node['platform_version'].to_i.to_s
|
||||
arch = node['kernel']['machine']
|
||||
|
||||
resources("remote_file[#{Chef::Config[:file_cache_path]}/#{node[:postgresql][:pgdg][:repo_rpm_url][node[:postgresql][:version]][rpm_platform][rpm_platform_version][arch][:package]}]").run_action(:create)
|
||||
resources("package[#{node[:postgresql][:pgdg][:repo_rpm_url][node[:postgresql][:version]][rpm_platform][rpm_platform_version][arch][:package]}]").run_action(:install)
|
||||
resources("remote_file[#{Chef::Config[:file_cache_path]}/#{node['postgresql']['pgdg']['repo_rpm_url'][node['postgresql']['version']][rpm_platform][rpm_platform_version][arch]['package']}]").run_action(:create)
|
||||
resources("package[#{node['postgresql']['pgdg']['repo_rpm_url'][node['postgresql']['version']][rpm_platform][rpm_platform_version][arch]['package']}]").run_action(:install)
|
||||
|
||||
ENV['PATH'] = "/usr/pgsql-#{node['postgresql']['version']}/bin:#{ENV['PATH']}"
|
||||
|
||||
node['postgresql']['client']['packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :nothing
|
||||
end.run_action(:install)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if node['postgresql']['enable_pgdg_apt']
|
||||
include_recipe "postgresql::apt_pgdg_postgresql"
|
||||
resources("file[remove deprecated Pitti PPA apt repository]").run_action(:delete)
|
||||
resources("apt_repository[apt.postgresql.org]").run_action(:add)
|
||||
|
||||
node['postgresql']['client']['packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :nothing
|
||||
end.run_action(:install)
|
||||
end
|
||||
|
||||
if node['postgresql']['enable_pgdg_apt'] && platform_family?('debian')
|
||||
include_recipe 'postgresql::apt_pgdg_postgresql'
|
||||
resources('apt_repository[apt.postgresql.org]').run_action(:add)
|
||||
end
|
||||
|
||||
include_recipe "postgresql::client"
|
||||
include_recipe 'postgresql::client'
|
||||
|
||||
node['postgresql']['client']['packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :nothing
|
||||
end.run_action(:install)
|
||||
end
|
||||
package node['postgresql']['client']['packages'] do
|
||||
action :nothing
|
||||
end.run_action(:install)
|
||||
|
||||
begin
|
||||
chef_gem "pg"
|
||||
chef_gem 'pg' do
|
||||
compile_time true
|
||||
version node['postgresql']['pg_gem']['version'] if node['postgresql']['pg_gem']['version']
|
||||
end
|
||||
rescue Gem::Installer::ExtensionBuildError, Mixlib::ShellOut::ShellCommandFailed => e
|
||||
# Are we an omnibus install?
|
||||
raise if RbConfig.ruby.scan(%r{(chef|opscode)}).empty?
|
||||
raise if RbConfig.ruby.scan(/(chef|opscode)/).empty?
|
||||
# Still here, must be omnibus. Lets make this thing install!
|
||||
Chef::Log.warn 'Failed to properly build pg gem. Forcing properly linking and retrying (omnibus fix)'
|
||||
gem_dir = e.message.scan(%r{will remain installed in ([^ ]+)}).flatten.first
|
||||
gem_dir = e.message.scan(/will remain installed in ([^ ]+)/).flatten.first
|
||||
raise unless gem_dir
|
||||
gem_name = File.basename(gem_dir)
|
||||
ext_dir = File.join(gem_dir, 'ext')
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Cookbook Name:: postgresql
|
||||
# Cookbook:: postgresql
|
||||
# Recipe:: server
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -15,25 +16,23 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe "postgresql::ca_certificates"
|
||||
|
||||
::Chef::Recipe.send(:include, OpenSSLCookbook::RandomPassword)
|
||||
|
||||
include_recipe "postgresql::client"
|
||||
include_recipe 'postgresql::client'
|
||||
|
||||
# randomly generate postgres password, unless using solo - see README
|
||||
if Chef::Config[:solo]
|
||||
missing_attrs = %w{
|
||||
missing_attrs = %w(
|
||||
postgres
|
||||
}.select do |attr|
|
||||
).select do |attr|
|
||||
node['postgresql']['password'][attr].nil?
|
||||
end.map { |attr| "node['postgresql']['password']['#{attr}']" }
|
||||
|
||||
if !missing_attrs.empty?
|
||||
unless missing_attrs.empty?
|
||||
Chef::Log.fatal([
|
||||
"You must set #{missing_attrs.join(', ')} in chef-solo mode.",
|
||||
"For more information, see https://github.com/opscode-cookbooks/postgresql#chef-solo-note"
|
||||
].join(' '))
|
||||
"You must set #{missing_attrs.join(', ')} in chef-solo mode.",
|
||||
'For more information, see https://github.com/opscode-cookbooks/postgresql#chef-solo-note',
|
||||
].join(' '))
|
||||
raise
|
||||
end
|
||||
else
|
||||
@@ -44,7 +43,7 @@ else
|
||||
# useful if it weren't saved as clear text in Chef Server for later
|
||||
# retrieval.
|
||||
unless node.key?('postgresql') && node['postgresql'].key?('password') && node['postgresql']['password'].key?('postgres')
|
||||
node.set_unless['postgresql']['password']['postgres'] = random_password(length: 20, mode: :base64)
|
||||
node.normal_unless['postgresql']['password']['postgres'] = random_password(length: 20, mode: :base64)
|
||||
node.save
|
||||
end
|
||||
end
|
||||
@@ -52,30 +51,29 @@ end
|
||||
# Include the right "family" recipe for installing the server
|
||||
# since they do things slightly differently.
|
||||
case node['platform_family']
|
||||
when "rhel", "fedora"
|
||||
node.set['postgresql']['dir'] = "/var/lib/pgsql/#{node['postgresql']['version']}/data"
|
||||
node.set['postgresql']['config']['data_directory'] = "/var/lib/pgsql/#{node['postgresql']['version']}/data"
|
||||
include_recipe "postgresql::server_redhat"
|
||||
when "debian"
|
||||
node.set['postgresql']['config']['data_directory'] = "/var/lib/postgresql/#{node['postgresql']['version']}/main"
|
||||
include_recipe "postgresql::server_debian"
|
||||
when 'rhel', 'fedora'
|
||||
node.normal['postgresql']['dir'] = "/var/lib/pgsql/#{node['postgresql']['version']}/data"
|
||||
node.normal['postgresql']['config']['data_directory'] = "/var/lib/pgsql/#{node['postgresql']['version']}/data"
|
||||
include_recipe 'postgresql::server_redhat'
|
||||
when 'debian'
|
||||
node.normal['postgresql']['config']['data_directory'] = "/var/lib/postgresql/#{node['postgresql']['version']}/main"
|
||||
include_recipe 'postgresql::server_debian'
|
||||
when 'suse'
|
||||
node.set['postgresql']['config']['data_directory'] = node['postgresql']['dir']
|
||||
include_recipe "postgresql::server_redhat"
|
||||
node.normal['postgresql']['config']['data_directory'] = node['postgresql']['dir']
|
||||
include_recipe 'postgresql::server_redhat'
|
||||
end
|
||||
|
||||
# Versions prior to 9.2 do not have a config file option to set the SSL
|
||||
# key and cert path, and instead expect them to be in a specific location.
|
||||
if node['postgresql']['version'].to_f < 9.2 && node['postgresql']['config'].attribute?('ssl_cert_file')
|
||||
link ::File.join(node['postgresql']['config']['data_directory'], 'server.crt') do
|
||||
to node['postgresql']['config']['ssl_cert_file']
|
||||
end
|
||||
|
||||
link ::File.join(node['postgresql']['config']['data_directory'], 'server.crt') do
|
||||
to node['postgresql']['config']['ssl_cert_file']
|
||||
only_if { node['postgresql']['version'].to_f < 9.2 && node['postgresql']['config'].attribute?('ssl_cert_file') }
|
||||
end
|
||||
|
||||
if node['postgresql']['version'].to_f < 9.2 && node['postgresql']['config'].attribute?('ssl_key_file')
|
||||
link ::File.join(node['postgresql']['config']['data_directory'], 'server.key') do
|
||||
to node['postgresql']['config']['ssl_key_file']
|
||||
end
|
||||
link ::File.join(node['postgresql']['config']['data_directory'], 'server.key') do
|
||||
to node['postgresql']['config']['ssl_key_file']
|
||||
only_if { node['postgresql']['version'].to_f < 9.2 && node['postgresql']['config'].attribute?('ssl_key_file') }
|
||||
end
|
||||
|
||||
# NOTE: Consider two facts before modifying "assign-postgres-password":
|
||||
@@ -86,7 +84,7 @@ end
|
||||
# setting the same password. This chef recipe doesn't have access to
|
||||
# the plain text password, and testing the encrypted (md5 digest)
|
||||
# version is not straight-forward.
|
||||
bash "assign-postgres-password" do
|
||||
bash 'assign-postgres-password' do
|
||||
user 'postgres'
|
||||
code <<-EOH
|
||||
echo "ALTER ROLE postgres ENCRYPTED PASSWORD \'#{node['postgresql']['password']['postgres']}\';" | psql -p #{node['postgresql']['config']['port']}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Cookbook Name:: postgresql
|
||||
# Cookbook:: postgresql
|
||||
# Recipe:: server
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -20,37 +21,35 @@ change_notify = node['postgresql']['server']['config_change_notify']
|
||||
# There are some configuration items which depend on correctly evaluating the intended version being installed
|
||||
if node['platform_family'] == 'debian'
|
||||
|
||||
node.set['postgresql']['config']['hba_file'] = "/etc/postgresql/#{node['postgresql']['version']}/main/pg_hba.conf"
|
||||
node.set['postgresql']['config']['ident_file'] = "/etc/postgresql/#{node['postgresql']['version']}/main/pg_ident.conf"
|
||||
node.set['postgresql']['config']['external_pid_file'] = "/var/run/postgresql/#{node['postgresql']['version']}-main.pid"
|
||||
node.normal['postgresql']['config']['hba_file'] = "/etc/postgresql/#{node['postgresql']['version']}/main/pg_hba.conf"
|
||||
node.normal['postgresql']['config']['ident_file'] = "/etc/postgresql/#{node['postgresql']['version']}/main/pg_ident.conf"
|
||||
node.normal['postgresql']['config']['external_pid_file'] = "/var/run/postgresql/#{node['postgresql']['version']}-main.pid"
|
||||
|
||||
if node['postgresql']['version'].to_f < 9.3
|
||||
node.set['postgresql']['config']['unix_socket_directory'] = '/var/run/postgresql'
|
||||
node.normal['postgresql']['config']['unix_socket_directory'] = '/var/run/postgresql'
|
||||
else
|
||||
node.set['postgresql']['config']['unix_socket_directories'] = '/var/run/postgresql'
|
||||
node.normal['postgresql']['config']['unix_socket_directories'] = '/var/run/postgresql'
|
||||
end
|
||||
|
||||
node.set['postgresql']['config']['max_fsm_pages'] = 153600 if node['postgresql']['version'].to_f < 8.4
|
||||
|
||||
if node['postgresql']['config']['ssl']
|
||||
node.set['postgresql']['config']['ssl_cert_file'] = '/etc/ssl/certs/ssl-cert-snakeoil.pem' if node['postgresql']['version'].to_f >= 9.2
|
||||
node.set['postgresql']['config']['ssl_key_file'] = '/etc/ssl/private/ssl-cert-snakeoil.key'if node['postgresql']['version'].to_f >= 9.2
|
||||
node.normal['postgresql']['config']['ssl_cert_file'] = '/etc/ssl/certs/ssl-cert-snakeoil.pem' if node['postgresql']['version'].to_f >= 9.2
|
||||
node.normal['postgresql']['config']['ssl_key_file'] = '/etc/ssl/private/ssl-cert-snakeoil.key' if node['postgresql']['version'].to_f >= 9.2
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
template "#{node['postgresql']['dir']}/postgresql.conf" do
|
||||
source "postgresql.conf.erb"
|
||||
owner "postgres"
|
||||
group "postgres"
|
||||
mode 0600
|
||||
source 'postgresql.conf.erb'
|
||||
owner 'postgres'
|
||||
group 'postgres'
|
||||
mode '0600'
|
||||
notifies change_notify, 'service[postgresql]', :immediately
|
||||
end
|
||||
|
||||
template "#{node['postgresql']['dir']}/pg_hba.conf" do
|
||||
source "pg_hba.conf.erb"
|
||||
owner "postgres"
|
||||
group "postgres"
|
||||
mode 00600
|
||||
source 'pg_hba.conf.erb'
|
||||
owner 'postgres'
|
||||
group 'postgres'
|
||||
mode '0600'
|
||||
notifies change_notify, 'service[postgresql]', :immediately
|
||||
end
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Cookbook Name:: postgresql
|
||||
# Cookbook:: postgresql
|
||||
# Recipe:: server
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -15,19 +16,15 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe "postgresql::client"
|
||||
include_recipe 'postgresql::client'
|
||||
|
||||
node['postgresql']['server']['packages'].each do |pg_pack|
|
||||
package node['postgresql']['server']['packages']
|
||||
|
||||
package pg_pack
|
||||
include_recipe 'postgresql::server_conf'
|
||||
|
||||
end
|
||||
|
||||
include_recipe "postgresql::server_conf"
|
||||
|
||||
service "postgresql" do
|
||||
service 'postgresql' do
|
||||
service_name node['postgresql']['server']['service_name']
|
||||
supports :restart => true, :status => true, :reload => true
|
||||
supports restart: true, status: true, reload: true
|
||||
action [:enable, :start]
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Cookbook Name:: postgresql
|
||||
# Cookbook:: postgresql
|
||||
# Recipe:: server
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -15,7 +16,7 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe "postgresql::client"
|
||||
include_recipe 'postgresql::client'
|
||||
|
||||
svc_name = node['postgresql']['server']['service_name']
|
||||
initdb_locale = node['postgresql']['initdb_locale']
|
||||
@@ -25,44 +26,39 @@ shortver = node['postgresql']['version'].split('.').join
|
||||
# Create a group and user like the package will.
|
||||
# Otherwise the templates fail.
|
||||
|
||||
group "postgres" do
|
||||
gid 26
|
||||
group 'postgres' do
|
||||
gid node['postgresql']['gid']
|
||||
end
|
||||
|
||||
user "postgres" do
|
||||
shell "/bin/bash"
|
||||
comment "PostgreSQL Server"
|
||||
home "/var/lib/pgsql"
|
||||
gid "postgres"
|
||||
user 'postgres' do
|
||||
shell '/bin/bash'
|
||||
comment 'PostgreSQL Server'
|
||||
home '/var/lib/pgsql'
|
||||
gid 'postgres'
|
||||
system true
|
||||
uid 26
|
||||
supports :manage_home => false
|
||||
uid node['postgresql']['uid']
|
||||
manage_home false
|
||||
end
|
||||
|
||||
directory node['postgresql']['config']['data_directory'] do
|
||||
owner "postgres"
|
||||
group "postgres"
|
||||
owner 'postgres'
|
||||
group 'postgres'
|
||||
recursive true
|
||||
action :create
|
||||
mode '0700'
|
||||
end
|
||||
|
||||
node['postgresql']['server']['packages'].each do |pg_pack|
|
||||
|
||||
package pg_pack
|
||||
|
||||
end
|
||||
package node['postgresql']['server']['packages']
|
||||
|
||||
# If using PGDG, add symlinks so that downstream commands all work
|
||||
if node['postgresql']['enable_pgdg_yum'] == true
|
||||
if node['postgresql']['enable_pgdg_yum'] == true || node['postgresql']['use_pgdg_packages'] == true
|
||||
[
|
||||
"postgresql#{shortver}-setup",
|
||||
"postgresql#{shortver}-check-db-dir"
|
||||
"postgresql#{shortver}-check-db-dir",
|
||||
].each do |cmd|
|
||||
|
||||
link "/usr/bin/#{cmd}" do
|
||||
to "/usr/pgsql-#{node['postgresql']['version']}/bin/#{cmd}"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -71,22 +67,44 @@ end
|
||||
|
||||
unless node['postgresql']['server']['init_package'] == 'systemd'
|
||||
|
||||
directory "/etc/sysconfig/pgsql" do
|
||||
mode "0644"
|
||||
directory '/etc/sysconfig/pgsql' do
|
||||
mode '0644'
|
||||
recursive true
|
||||
action :create
|
||||
end
|
||||
|
||||
template "/etc/sysconfig/pgsql/#{svc_name}" do
|
||||
source "pgsql.sysconfig.erb"
|
||||
mode "0644"
|
||||
notifies :restart, "service[postgresql]", :delayed
|
||||
source 'pgsql.sysconfig.erb'
|
||||
mode '0644'
|
||||
notifies :restart, 'service[postgresql]', :delayed
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if node['postgresql']['server']['init_package'] == 'systemd'
|
||||
|
||||
if node['platform_family'] == 'rhel'
|
||||
|
||||
template_path = if node['postgresql']['use_pgdg_packages']
|
||||
"/etc/systemd/system/postgresql-#{node['postgresql']['version']}.service"
|
||||
else
|
||||
'/etc/systemd/system/postgresql.service'
|
||||
end
|
||||
|
||||
template template_path do
|
||||
source 'postgresql.service.erb'
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0644'
|
||||
notifies :run, 'execute[systemctl-reload]', :immediately
|
||||
notifies :reload, 'service[postgresql]', :delayed
|
||||
end
|
||||
execute 'systemctl-reload' do
|
||||
command 'systemctl daemon-reload'
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
case node['platform_family']
|
||||
when 'suse'
|
||||
execute "initdb -d #{node['postgresql']['dir']}" do
|
||||
@@ -99,7 +117,7 @@ if node['postgresql']['server']['init_package'] == 'systemd'
|
||||
end
|
||||
end
|
||||
|
||||
elsif (!platform_family?("suse") && node['postgresql']['version'].to_f <= 9.3)
|
||||
elsif !platform_family?('suse') && node['postgresql']['version'].to_f <= 9.3
|
||||
|
||||
execute "/sbin/service #{svc_name} initdb #{initdb_locale}" do
|
||||
not_if { ::File.exist?("#{node['postgresql']['config']['data_directory']}/PG_VERSION") }
|
||||
@@ -113,10 +131,10 @@ else
|
||||
|
||||
end
|
||||
|
||||
service "postgresql" do
|
||||
service 'postgresql' do
|
||||
service_name svc_name
|
||||
supports :restart => true, :status => true, :reload => true
|
||||
supports restart: true, status: true, reload: true
|
||||
action [:enable, :start]
|
||||
end
|
||||
|
||||
include_recipe "postgresql::server_conf"
|
||||
include_recipe 'postgresql::server_conf'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Cookbook Name:: postgresql
|
||||
# Cookbook:: postgresql
|
||||
# Recipe::yum_pgdg_postgresql
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -21,16 +22,20 @@
|
||||
rpm_platform = node['platform']
|
||||
rpm_platform_version = node['platform_version'].to_f.to_i.to_s
|
||||
arch = node['kernel']['machine']
|
||||
pg_version = node['postgresql']['version']
|
||||
pgdg_setup = node['postgresql']['pgdg']['repo_rpm_url'][pg_version][rpm_platform][rpm_platform_version][arch]
|
||||
pgdg_package = pgdg_setup['package']
|
||||
pgdg_repository = pgdg_setup['url']
|
||||
|
||||
# Download the PGDG repository RPM as a local file
|
||||
remote_file "#{Chef::Config[:file_cache_path]}/#{node[:postgresql][:pgdg][:repo_rpm_url][node[:postgresql][:version]][rpm_platform][rpm_platform_version][arch][:package]}" do
|
||||
source "#{node[:postgresql][:pgdg][:repo_rpm_url][node[:postgresql][:version]][rpm_platform][rpm_platform_version][arch][:url]}#{node[:postgresql][:pgdg][:repo_rpm_url][node[:postgresql][:version]][rpm_platform][rpm_platform_version][arch][:package]}"
|
||||
mode "0644"
|
||||
remote_file "#{Chef::Config[:file_cache_path]}/#{pgdg_package}" do
|
||||
source "#{pgdg_repository}#{pgdg_package}"
|
||||
mode '0644'
|
||||
end
|
||||
|
||||
# Install the PGDG repository RPM from the local file
|
||||
package "#{node[:postgresql][:pgdg][:repo_rpm_url][node[:postgresql][:version]][rpm_platform][rpm_platform_version][arch][:package]}" do
|
||||
package pgdg_package.to_s do
|
||||
provider Chef::Provider::Package::Rpm
|
||||
source "#{Chef::Config[:file_cache_path]}/#{node[:postgresql][:pgdg][:repo_rpm_url][node[:postgresql][:version]][rpm_platform][rpm_platform_version][arch][:package]}"
|
||||
source "#{Chef::Config[:file_cache_path]}/#{pgdg_package}"
|
||||
action :install
|
||||
end
|
||||
|
||||
57
cookbooks/postgresql/resources/extension.rb
Normal file
57
cookbooks/postgresql/resources/extension.rb
Normal file
@@ -0,0 +1,57 @@
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Cookbook:: postgresql
|
||||
# Resource:: extension
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
include Opscode::PostgresqlHelpers
|
||||
|
||||
# name property should take the form:
|
||||
# database/extension
|
||||
|
||||
property :database, String,
|
||||
required: true,
|
||||
default: lazy { name.scan(%r{\A[^/]+(?=/)}).first }
|
||||
|
||||
property :extension, String,
|
||||
required: true,
|
||||
default: lazy { name.scan(%r{(?<=/)[^/]+\Z}).first }
|
||||
|
||||
action :create do
|
||||
bash "CREATE EXTENSION #{name}" do
|
||||
code psql("CREATE EXTENSION IF NOT EXISTS \"#{extension}\"")
|
||||
user 'postgres'
|
||||
action :run
|
||||
not_if { extension_installed? }
|
||||
end
|
||||
end
|
||||
|
||||
action :drop do
|
||||
bash "DROP EXTENSION #{name}" do
|
||||
code psql("DROP EXTENSION IF EXISTS \"#{extension}\"")
|
||||
user 'postgres'
|
||||
action :run
|
||||
only_if { extension_installed? }
|
||||
end
|
||||
end
|
||||
|
||||
def psql(query)
|
||||
"psql -d #{database} <<< '\\set ON_ERROR_STOP on\n#{query};'"
|
||||
end
|
||||
|
||||
def extension_installed?
|
||||
query = "SELECT 'installed' FROM pg_extension WHERE extname = '#{extension}';"
|
||||
!(execute_sql(query, database) =~ /^installed$/).nil?
|
||||
end
|
||||
@@ -18,7 +18,7 @@
|
||||
<% node['postgresql']['pg_hba'].each do |auth| -%>
|
||||
|
||||
<% if auth[:comment] %>
|
||||
<%= auth[:comment] %>
|
||||
# <%= auth[:comment] %>
|
||||
<% end %>
|
||||
<% if auth[:addr] %>
|
||||
<%= auth[:type].ljust(7) %> <%= auth[:db].ljust(15) %> <%= auth[:user].ljust(15) %> <%= auth[:addr].ljust(23) %> <%= auth[:method] %>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
[Service]
|
||||
<% if node['postgresql']['use_pgdg_packages'] %>
|
||||
.include /usr/lib/systemd/system/postgresql-<%= node['postgresql']['version'] %>.service
|
||||
<% else %>
|
||||
.include /usr/lib/systemd/system/postgresql.service
|
||||
<% end %>
|
||||
|
||||
Environment=
|
||||
Environment=PGPORT=<%= node['postgresql']['config']['port'] %>
|
||||
Environment=PGDATA=<%= node['postgresql']['config']['data_directory'] %>
|
||||
Reference in New Issue
Block a user