82c5863431
The postgresql init script on debian/ubuntu returns 0 no matter whether postgresql is started or stopped, so puppet has no way of knowing whether to start postgresql when the service is set to 'ensure => running'. This commit adds a param to the params class called $service_status which is set to the status piped to an egrep on debian/ubuntu, which reliably returns 0 if there are clusters running and 1 if there are none. The output before and after this patch can be seen below. If the init script is fixed at some point, the logic would need to be revisited. Before patch postgresql remains stopped after puppet run. $ # service postgresql stop $ # * Stopping PostgreSQL 9.1 database server $ # puppet apply -e "class {'postgresql::server':}" $ # notice: Finished catalog run in 0.15 seconds $ # service postgresql status $ # Running clusters: After patch postgresql is started after puppet run. $ # service postgresql stop $ # * Stopping PostgreSQL 9.1 database server $ # puppet apply -e "class {'postgresql::server':}" $ # notice: /Stage[main]/Postgresql::Server/Service[postgresqld]/ensure: ensure changed 'stopped' to 'running' $ # notice: Finished catalog run in 2.26 seconds $ # service postgresql status $ # Running clusters: 9.1/main |
||
---|---|---|
lib | ||
manifests | ||
spec | ||
templates | ||
tests | ||
.gitignore | ||
CHANGELOG.md | ||
LICENSE | ||
Modulefile | ||
README.md |
Puppet module for PostgreSQL resources
This module provides the following defined resource types for managing postgres:
postgresql::initdb
postgresql::db
postgresql::role
postgresql::user
(just for clarity; users are roles in postgres)postgresql::grant
And the fallback, analogous to exec resources, only for SQL statements:
postgresql::psql
Basic usage
postgresql::user{'marmot':
password => 'foo',
}
postgresql::grant{'grant select to marmot':
grantee => 'marmot',
on_object => 'my_table',
perm => 'select',
require => Postgresql::User['marmot'],
}
etc, etc.
Automated testing
Install and setup an RVM with vagrant, sahara, and rspec
$ curl -L get.rvm.io | bash -s stable
$ rvm install 1.9.3
$ rvm use --create 1.9.3@puppet-postgresql
$ gem install vagrant sahara rspec
Run the tests like so:
$ (cd spec; vagrant up)
$ rspec -f -d -c
The test suite will snapshot the VM and rollback between each test.
Next, take a look at the manifests used for the automated tests.
spec/
manifests/
test_*.pp
Contributors
- Andrew Moon
- Kenn Knowles (@kennknowles)
Copyright and License
Copyright 2012 Inkling Systems, 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.