Add classes to install PL/Python and the postgresql-docs

See the README for usage and provided parameters.
This commit is contained in:
deVIAntCode 2015-03-04 11:58:15 +00:00 committed by David Schmitt
parent 5dc78b7128
commit f9c0d91680
8 changed files with 235 additions and 87 deletions

View file

@ -131,10 +131,12 @@ Classes:
* [postgresql::globals](#class-postgresqlglobals)
* [postgresql::lib::devel](#class-postgresqllibdevel)
* [postgresql::lib::java](#class-postgresqllibjava)
* [postgresql::lib::docs](#class-postgresqllibdocs)
* [postgresql::lib::perl](#class-postgresqllibperl)
* [postgresql::lib::python](#class-postgresqllibpython)
* [postgresql::server](#class-postgresqlserver)
* [postgresql::server::plperl](#class-postgresqlserverplperl)
* [postgresql::server::plpython](#class-postgresqlserverplpython)
* [postgresql::server::contrib](#class-postgresqlservercontrib)
* [postgresql::server::postgis](#class-postgresqlserverpostgis)
@ -205,12 +207,18 @@ This setting can be used to override the default postgresql devel package name.
####`java_package_name`
This setting can be used to override the default postgresql java package name. If not specified, the module will use whatever package name is the default for your OS distro.
####`docs_package_name`
This setting can be used to override the default postgresql docs package name. If not specified, the module will use whatever package name is the default for your OS distro.
####`perl_package_name`
This setting can be used to override the default postgresql Perl package name. If not specified, the module will use whatever package name is the default for your OS distro.
####`plperl_package_name`
This setting can be used to override the default postgresql PL/perl package name. If not specified, the module will use whatever package name is the default for your OS distro.
####`plpython_package_name`
This setting can be used to override the default postgresql PL/python package name. If not specified, the module will use whatever package name is the default for your OS distro.
####`python_package_name`
This setting can be used to override the default postgresql Python package name. If not specified, the module will use whatever package name is the default for your OS distro.
@ -315,6 +323,9 @@ Value to pass through to the `package` resource when creating the server instanc
####`plperl_package_name`
This sets the default package name for the PL/Perl extension. Defaults to utilising the operating system default.
####`plpython_package_name`
This sets the default package name for the PL/Python extension. Defaults to utilising the operating system default.
####`service_manage`
This setting selects whether Puppet should manage the service. Defaults to `true`.
@ -456,6 +467,15 @@ The name of the postgresql java package.
####`package_ensure`
The ensure parameter passed on to postgresql java package resource.
###Class: postgresql::lib::docs
This class installs postgresql bindings for Postgres-Docs. Alter the following parameters if you have a custom version you would like to install (Note: don't forget to make sure to add any necessary yum or apt repositories if specifying a custom version):
####`package_name`
The name of the postgresql docs package.
####`package_ensure`
The ensure parameter passed on to postgresql docs package resource.
###Class: postgresql::lib::perl
This class installs the postgresql Perl libraries. For customer requirements you can customise the following parameters:
@ -466,6 +486,14 @@ The name of the postgresql perl package.
####`package_ensure`
The ensure parameter passed on to postgresql perl package resource.
###Class: postgresql::server::plpython
This class installs the PL/Python procedural language for postgresql.
####`package_name`
The name of the postgresql PL/Python package.
####`package_ensure`
The ensure parameter passed on to postgresql PL/Python package resource.
###Class: postgresql::lib::python
This class installs the postgresql Python libraries. For customer requirements you can customise the following parameters:

View file

@ -1,55 +1,57 @@
# Class for setting cross-class global overrides. See README.md for more
# details.
class postgresql::globals (
$client_package_name = undef,
$server_package_name = undef,
$contrib_package_name = undef,
$devel_package_name = undef,
$java_package_name = undef,
$perl_package_name = undef,
$plperl_package_name = undef,
$python_package_name = undef,
$postgis_package_name = undef,
$client_package_name = undef,
$server_package_name = undef,
$contrib_package_name = undef,
$devel_package_name = undef,
$java_package_name = undef,
$docs_package_name = undef,
$perl_package_name = undef,
$plperl_package_name = undef,
$plpython_package_name = undef,
$python_package_name = undef,
$postgis_package_name = undef,
$service_name = undef,
$service_provider = undef,
$service_status = undef,
$default_database = undef,
$service_name = undef,
$service_provider = undef,
$service_status = undef,
$default_database = undef,
$validcon_script_path = undef,
$validcon_script_path = undef,
$initdb_path = undef,
$createdb_path = undef,
$psql_path = undef,
$pg_hba_conf_path = undef,
$pg_ident_conf_path = undef,
$postgresql_conf_path = undef,
$recovery_conf_path = undef,
$initdb_path = undef,
$createdb_path = undef,
$psql_path = undef,
$pg_hba_conf_path = undef,
$pg_ident_conf_path = undef,
$postgresql_conf_path = undef,
$recovery_conf_path = undef,
$pg_hba_conf_defaults = undef,
$pg_hba_conf_defaults = undef,
$datadir = undef,
$confdir = undef,
$bindir = undef,
$xlogdir = undef,
$logdir = undef,
$datadir = undef,
$confdir = undef,
$bindir = undef,
$xlogdir = undef,
$logdir = undef,
$user = undef,
$group = undef,
$user = undef,
$group = undef,
$version = undef,
$postgis_version = undef,
$version = undef,
$postgis_version = undef,
$needs_initdb = undef,
$needs_initdb = undef,
$encoding = undef,
$locale = undef,
$encoding = undef,
$locale = undef,
$manage_pg_hba_conf = undef,
$manage_pg_ident_conf = undef,
$manage_recovery_conf = undef,
$manage_pg_hba_conf = undef,
$manage_pg_ident_conf = undef,
$manage_recovery_conf = undef,
$manage_package_repo = undef
$manage_package_repo = undef,
) {
# We are determining this here, because it is needed by the package repo
# class.

16
manifests/lib/docs.pp Normal file
View file

@ -0,0 +1,16 @@
# This class installs the postgresql-docs See README.md for more
# details.
class postgresql::lib::docs (
$package_name = $postgresql::params::docs_package_name,
$package_ensure = 'present',
) inherits postgresql::params {
validate_string($package_name)
package { 'postgresql-docs':
ensure => $package_ensure,
name => $package_name,
tag => 'postgresql',
}
}

View file

@ -30,35 +30,39 @@ class postgresql::params inherits postgresql::globals {
$package_version = "${version_parts[0]}${version_parts[1]}"
if $version == $postgresql::globals::default_version {
$client_package_name = pick($client_package_name, 'postgresql')
$server_package_name = pick($server_package_name, 'postgresql-server')
$contrib_package_name = pick($contrib_package_name,'postgresql-contrib')
$devel_package_name = pick($devel_package_name, 'postgresql-devel')
$java_package_name = pick($java_package_name, 'postgresql-jdbc')
$plperl_package_name = pick($plperl_package_name, 'postgresql-plperl')
$service_name = pick($service_name, 'postgresql')
$bindir = pick($bindir, '/usr/bin')
$datadir = $::operatingsystem ? {
$client_package_name = pick($client_package_name, 'postgresql')
$server_package_name = pick($server_package_name, 'postgresql-server')
$contrib_package_name = pick($contrib_package_name,'postgresql-contrib')
$devel_package_name = pick($devel_package_name, 'postgresql-devel')
$java_package_name = pick($java_package_name, 'postgresql-jdbc')
$docs_package_name = pick($docs_package_name, 'postgresql-docs')
$plperl_package_name = pick($plperl_package_name, 'postgresql-plperl')
$plpython_package_name = pick($plpython_package_name, 'postgresql-plpython')
$service_name = pick($service_name, 'postgresql')
$bindir = pick($bindir, '/usr/bin')
$datadir = $::operatingsystem ? {
'Amazon' => pick($datadir, '/var/lib/pgsql9/data'),
default => pick($datadir, '/var/lib/pgsql/data'),
}
$confdir = pick($confdir, $datadir)
$confdir = pick($confdir, $datadir)
} else {
$client_package_name = pick($client_package_name, "postgresql${package_version}")
$server_package_name = pick($server_package_name, "postgresql${package_version}-server")
$contrib_package_name = pick($contrib_package_name,"postgresql${package_version}-contrib")
$devel_package_name = pick($devel_package_name, "postgresql${package_version}-devel")
$java_package_name = pick($java_package_name, "postgresql${package_version}-jdbc")
$plperl_package_name = pick($plperl_package_name, "postgresql${package_version}-plperl")
$service_name = pick($service_name, "postgresql-${version}")
$bindir = pick($bindir, "/usr/pgsql-${version}/bin")
$datadir = $::operatingsystem ? {
$client_package_name = pick($client_package_name, "postgresql${package_version}")
$server_package_name = pick($server_package_name, "postgresql${package_version}-server")
$contrib_package_name = pick($contrib_package_name,"postgresql${package_version}-contrib")
$devel_package_name = pick($devel_package_name, "postgresql${package_version}-devel")
$java_package_name = pick($java_package_name, "postgresql${package_version}-jdbc")
$docs_package_name = pick($docs_package_name, "postgresql${package_version}-docs")
$plperl_package_name = pick($plperl_package_name, "postgresql${package_version}-plperl")
$plpython_package_name = pick($plpython_package_name, "postgresql${package_version}-plpython")
$service_name = pick($service_name, "postgresql-${version}")
$bindir = pick($bindir, "/usr/pgsql-${version}/bin")
$datadir = $::operatingsystem ? {
'Amazon' => pick($datadir, "/var/lib/pgsql9/${version}/data"),
default => pick($datadir, "/var/lib/pgsql/${version}/data"),
}
$confdir = pick($confdir, $datadir)
$confdir = pick($confdir, $datadir)
}
$psql_path = pick($psql_path, "${bindir}/psql")
$psql_path = pick($psql_path, "${bindir}/psql")
$service_status = $service_status
$service_reload = "service ${service_name} reload"
@ -84,26 +88,27 @@ class postgresql::params inherits postgresql::globals {
# Archlinux doesn't have a client-package but has a libs package which
# pulls in postgresql server
$client_package_name = pick($client_package_name, 'postgresql')
$server_package_name = pick($server_package_name, 'postgresql-libs')
$java_package_name = pick($java_package_name, 'postgresql-jdbc')
$client_package_name = pick($client_package_name, 'postgresql')
$server_package_name = pick($server_package_name, 'postgresql-libs')
$java_package_name = pick($java_package_name, 'postgresql-jdbc')
# Archlinux doesn't have develop packages
$devel_package_name = pick($devel_package_name, 'postgresql-devel')
$devel_package_name = pick($devel_package_name, 'postgresql-devel')
# Archlinux does have postgresql-contrib but it isn't maintained
$contrib_package_name = pick($contrib_package_name,'undef')
$contrib_package_name = pick($contrib_package_name,'undef')
# Archlinux postgresql package provides plperl
$plperl_package_name = pick($plperl_package_name, 'undef')
$service_name = pick($service_name, 'postgresql')
$bindir = pick($bindir, '/usr/bin')
$datadir = pick($datadir, '/var/lib/postgres/data')
$confdir = pick($confdir, $datadir)
$psql_path = pick($psql_path, "${bindir}/psql")
$plperl_package_name = pick($plperl_package_name, 'undef')
$plpython_package_name = pick($plpython_package_name, 'undef')
$service_name = pick($service_name, 'postgresql')
$bindir = pick($bindir, '/usr/bin')
$datadir = pick($datadir, '/var/lib/postgres/data')
$confdir = pick($confdir, $datadir)
$psql_path = pick($psql_path, "${bindir}/psql")
$service_status = $service_status
$service_reload = "service ${service_name} reload"
$python_package_name = pick($python_package_name, 'python-psycopg2')
$service_status = $service_status
$service_reload = "service ${service_name} reload"
$python_package_name = pick($python_package_name, 'python-psycopg2')
# Archlinux does not have a perl::DBD::Pg package
$perl_package_name = pick($perl_package_name, 'undef')
$perl_package_name = pick($perl_package_name, 'undef')
}
'Debian': {
@ -126,31 +131,32 @@ class postgresql::params inherits postgresql::globals {
}
}
$client_package_name = pick($client_package_name, "postgresql-client-${version}")
$server_package_name = pick($server_package_name, "postgresql-${version}")
$contrib_package_name = pick($contrib_package_name, "postgresql-contrib-${version}")
$client_package_name = pick($client_package_name, "postgresql-client-${version}")
$server_package_name = pick($server_package_name, "postgresql-${version}")
$contrib_package_name = pick($contrib_package_name, "postgresql-contrib-${version}")
if versioncmp($postgis_version, '2') < 0 {
$postgis_package_name = pick($postgis_package_name, "postgresql-${version}-postgis")
} else {
$postgis_package_name = pick($postgis_package_name, "postgresql-${version}-postgis-${postgis_version}")
}
$devel_package_name = pick($devel_package_name, 'libpq-dev')
$java_package_name = pick($java_package_name, 'libpostgresql-jdbc-java')
$perl_package_name = pick($perl_package_name, 'libdbd-pg-perl')
$plperl_package_name = pick($plperl_package_name, "postgresql-plperl-${version}")
$python_package_name = pick($python_package_name, 'python-psycopg2')
$devel_package_name = pick($devel_package_name, 'libpq-dev')
$java_package_name = pick($java_package_name, 'libpostgresql-jdbc-java')
$perl_package_name = pick($perl_package_name, 'libdbd-pg-perl')
$plperl_package_name = pick($plperl_package_name, "postgresql-plperl-${version}")
$plpython_package_name = pick($plpython_package_name, "postgresql-plpython-${version}")
$python_package_name = pick($python_package_name, 'python-psycopg2')
$bindir = pick($bindir, "/usr/lib/postgresql/${version}/bin")
$datadir = pick($datadir, "/var/lib/postgresql/${version}/main")
$confdir = pick($confdir, "/etc/postgresql/${version}/main")
$bindir = pick($bindir, "/usr/lib/postgresql/${version}/bin")
$datadir = pick($datadir, "/var/lib/postgresql/${version}/main")
$confdir = pick($confdir, "/etc/postgresql/${version}/main")
if $::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '8.0') >= 0 {
# Jessie uses systemd
$service_status = pick($service_status, "/usr/sbin/service ${service_name}@*-main status")
} else {
$service_status = pick($service_status, "/etc/init.d/${service_name} status | /bin/egrep -q 'Running clusters: .+|online'")
}
$service_reload = "service ${service_name} reload"
$psql_path = pick($psql_path, '/usr/bin/psql')
$service_reload = "service ${service_name} reload"
$psql_path = pick($psql_path, '/usr/bin/psql')
}
'FreeBSD': {

View file

@ -7,6 +7,7 @@ class postgresql::server (
$package_ensure = $postgresql::params::package_ensure,
$plperl_package_name = $postgresql::params::plperl_package_name,
$plpython_package_name = $postgresql::params::plpython_package_name,
$service_ensure = $postgresql::params::service_ensure,
$service_enable = $postgresql::params::service_enable,

View file

@ -0,0 +1,19 @@
# This class installs the PL/Python procedural language for postgresql. See
# README.md for more details.
class postgresql::server::plpython(
$package_ensure = 'present',
$package_name = $postgresql::server::plpython_package_name,
) {
package { 'postgresql-plpython':
ensure => $package_ensure,
name => $package_name,
tag => 'postgresql',
}
anchor { 'postgresql::server::plpython::start': }->
Class['postgresql::server::install']->
Package['postgresql-plpython']->
Class['postgresql::server::service']->
anchor { 'postgresql::server::plpython::end': }
}

View file

@ -0,0 +1,29 @@
require 'spec_helper'
describe 'postgresql::lib::docs', :type => :class do
describe 'on a redhat based os' do
let :facts do {
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6.4',
}
end
it { is_expected.to contain_package('postgresql-docs').with(
:name => 'postgresql-docs',
:ensure => 'present',
:tag => 'postgresql'
)}
describe 'when parameters are supplied' do
let :params do
{:package_ensure => 'latest', :package_name => 'somepackage'}
end
it { is_expected.to contain_package('postgresql-docs').with(
:name => 'somepackage',
:ensure => 'latest',
:tag => 'postgresql'
)}
end
end
end

View file

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