Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for Debian Wheezy and lintian fixes #19

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Gemfile.lock
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
language: ruby

rvm:
- 1.8.7
- 1.9.3
- 2.0.0

matrix:
allow_failures:
- rvm: 2.0.0
env: PUPPET_VERSION="2.7"

script: 'rake'

env:
- PUPPET_VERSION="2.7"
- PUPPET_VERSION="3.0"
- PUPPET_VERSION="3.1"
- PUPPET_VERSION="3.2"

branches:
only:
- master
- develop

19 changes: 19 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
source 'https://rubygems.org'

puppetversion = ENV.key?('PUPPET_VERSION') ? "~> #{ENV['PUPPET_VERSION']}" : ['>= 3.2.1']
gem 'puppet', puppetversion

if puppetversion =~ /^3/
## rspec-hiera-puppet is puppet 3 only
gem 'rspec-hiera-puppet', '>=1.0.0'
end

facterversion = ENV.key?('FACTER_VERSION') ? "~> #{ENV['FACTER_VERSION']}" : ['>= 1.7.1']
gem 'facter', facterversion

gem 'rake'
gem 'rspec'
gem 'puppet-lint', '>=0.3.2'
gem 'rspec-puppet', '>=0.1.6'
gem 'puppetlabs_spec_helper', '>=0.4.1'

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ Contributors
* [Bert Hajee](https://github.com/hajee)
* [Patrick Hemmer](https://github.com/phemmer)
* [Marcello Barnaba](https://github.com/vjt)
* [Tom De Vylder](https://github.com/arioch) ([@tomdevylder](https://twitter.com/tomdevylder))

Copyright and License
---------------------
Expand Down
6 changes: 6 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require 'rake'

require 'rspec/core/rake_task'
require 'puppetlabs_spec_helper/rake_tasks'

task :default => [:spec, :lint]
41 changes: 22 additions & 19 deletions manifests/db.pp
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
# == Define postgresql::db
#
define postgresql::db (
$password,
$ensure = present,
$owner = $name,
$encoding = 'UTF8',
$locale = 'en_US.UTF-8',
$template = 'template0',
$password,
$ensure = present,
$owner = $name,
$encoding = 'UTF8',
$locale = 'en_US.UTF-8',
$template = 'template0',
) {
require postgresql::server
require postgresql::server

pg_user {$owner:
ensure => $ensure,
password => $password,
}
pg_user { $owner:
ensure => $ensure,
password => $password,
}

pg_database {$name:
ensure => $ensure,
owner => $owner,
require => Pg_user[$owner],
encoding => $encoding,
locale => $locale,
template => $template,
}
pg_database { $name:
ensure => $ensure,
owner => $owner,
require => Pg_user[$owner],
encoding => $encoding,
locale => $locale,
template => $template,
}
}

14 changes: 7 additions & 7 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# == Class postgresql
#
class postgresql (
$client_package = $postgresql::params::client_package,
$version = $postgresql::params::version

$version = $postgresql::params::version,
) inherits postgresql::params {

package { "postgresql-client-$version":
name => sprintf("%s-%s", $client_package, $version),
ensure => present,
package { "postgresql-client-${version}":
ensure => present,
name => sprintf('%s-%s', $client_package, $version),
}

}

16 changes: 14 additions & 2 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# == Class postgresql::params
#
class postgresql::params {
$locale = 'en_US.UTF-8'

$ssl = false
$ssl_ca_file = undef # the default is 'root.crt'
$ssl_cert_file = undef # the default is 'server.crt'
Expand All @@ -9,14 +10,25 @@

case $::operatingsystem {
/(Ubuntu|Debian)/: {
$version = '9.1'
$client_package = 'postgresql-client'
$server_package = 'postgresql'
$listen_address = 'localhost'
$port = 5432

$version = $::lsbdistcodename ? {
'squeeze' => '8.4',
default => '9.1',
}

$service_name = $::lsbdistcodename ? {
'wheezy' => 'postgresql',
default => "postgresql-system-${version}",
}
}

default: {
fail("Unsupported platform: ${::operatingsystem}")
}
}
}

59 changes: 31 additions & 28 deletions manifests/server.pp
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# == Class postgresql::server
#
class postgresql::server (
$server_package = $postgresql::params::server_package,
$locale = $postgresql::params::locale,
$version = $postgresql::params::version,
$listen = $postgresql::params::listen_address,
$port = $postgresql::params::port,
$ssl = $postgresql::params::ssl,
$ssl_ca_file = $postgresql::params::ssl_ca_file,
$ssl_cert_file = $postgresql::params::ssl_cert_file,
$ssl_crl_file = $postgresql::params::ssl_crl_file,
$ssl_key_file = $postgresql::params::ssl_key_file,
$preacl = [],
$acl = [],
$service_name = $postgresql::params::service_name,
$locale = $postgresql::params::locale,
$version = $postgresql::params::version,
$listen = $postgresql::params::listen_address,
$port = $postgresql::params::port,
$ssl = $postgresql::params::ssl,
$ssl_ca_file = $postgresql::params::ssl_ca_file,
$ssl_cert_file = $postgresql::params::ssl_cert_file,
$ssl_crl_file = $postgresql::params::ssl_crl_file,
$ssl_key_file = $postgresql::params::ssl_key_file,
$preacl = [],
$acl = [],
$manage_service = true
) inherits postgresql::params {

file { 'postgresql-server-policyrc.d':
ensure => present,
name => '/usr/sbin/policy-rc.d',
Expand All @@ -24,53 +26,54 @@
}

if ($manage_service) {

service { "postgresql-system-$version":
service { $service_name:
ensure => running,
name => 'postgresql',
enable => true,
ensure => running,
hasstatus => false,
hasrestart => true,
provider => 'debian',
subscribe => Package["postgresql-server-$version"],
subscribe => Package["postgresql-server-${version}"],
}

$notify_service = Service["postgresql-system-$version"]
$notify_service = Service[$service_name]
$package_require = []

} else {

$notify_service = []
$package_require = File['postgresql-server-policyrc.d']
}

package { "postgresql-server-${version}":
ensure => present,
name => sprintf('%s-%s', $server_package, $version),
require => $package_require,
}

package { "postgresql-server-$version":
name => sprintf("%s-%s", $server_package, $version),
package { "postgresql-server-dev-${version}":
ensure => present,
require => $package_require,
}

file { "postgresql-server-config-$version":
name => "/etc/postgresql/$version/main/postgresql.conf",
file { "postgresql-server-config-${version}":
ensure => present,
name => "/etc/postgresql/${version}/main/postgresql.conf",
content => template('postgresql/postgresql.conf.erb'),
owner => 'postgres',
group => 'postgres',
mode => '0644',
require => Package["postgresql-server-$version"],
require => Package["postgresql-server-${version}"],
notify => $notify_service,
}

file { "postgresql-server-hba-config-$version":
name => "/etc/postgresql/$version/main/pg_hba.conf",
file { "postgresql-server-hba-config-${version}":
ensure => present,
name => "/etc/postgresql/${version}/main/pg_hba.conf",
content => template('postgresql/pg_hba.conf.erb'),
owner => 'postgres',
group => 'postgres',
mode => '0640',
require => Package["postgresql-server-$version"],
require => Package["postgresql-server-${version}"],
notify => $notify_service,
}

}

4 changes: 2 additions & 2 deletions templates/pg_hba.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ local all postgres ident

# TYPE DATABASE USER ADDRESS METHOD
# site-specific pre access control list
<% preacl.each do |entry| -%>
<% @preacl.each do |entry| -%>
<%= entry %>
<% end -%>

Expand All @@ -98,7 +98,7 @@ host all all 127.0.0.1/32 md5
host all all ::1/128 md5

# site-specific access control list
<% acl.each do |entry| -%>
<% @acl.each do |entry| -%>
<%= entry %>
<% end -%>

Expand Down