Merge pull request #634 from DavidS/add-plpython-docs-classes

Add plpython and postgresql-docs classes
This commit is contained in:
TP Honey 2015-05-29 11:21:30 +01:00
commit 2f39ccd484
8 changed files with 235 additions and 87 deletions

View file

@ -131,10 +131,12 @@ Classes:
* [postgresql::globals](#class-postgresqlglobals) * [postgresql::globals](#class-postgresqlglobals)
* [postgresql::lib::devel](#class-postgresqllibdevel) * [postgresql::lib::devel](#class-postgresqllibdevel)
* [postgresql::lib::java](#class-postgresqllibjava) * [postgresql::lib::java](#class-postgresqllibjava)
* [postgresql::lib::docs](#class-postgresqllibdocs)
* [postgresql::lib::perl](#class-postgresqllibperl) * [postgresql::lib::perl](#class-postgresqllibperl)
* [postgresql::lib::python](#class-postgresqllibpython) * [postgresql::lib::python](#class-postgresqllibpython)
* [postgresql::server](#class-postgresqlserver) * [postgresql::server](#class-postgresqlserver)
* [postgresql::server::plperl](#class-postgresqlserverplperl) * [postgresql::server::plperl](#class-postgresqlserverplperl)
* [postgresql::server::plpython](#class-postgresqlserverplpython)
* [postgresql::server::contrib](#class-postgresqlservercontrib) * [postgresql::server::contrib](#class-postgresqlservercontrib)
* [postgresql::server::postgis](#class-postgresqlserverpostgis) * [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` ####`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. 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` ####`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. 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` ####`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. 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` ####`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. 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` ####`plperl_package_name`
This sets the default package name for the PL/Perl extension. Defaults to utilising the operating system default. 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` ####`service_manage`
This setting selects whether Puppet should manage the service. Defaults to `true`. 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` ####`package_ensure`
The ensure parameter passed on to postgresql java package resource. 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 ###Class: postgresql::lib::perl
This class installs the postgresql Perl libraries. For customer requirements you can customise the following parameters: 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` ####`package_ensure`
The ensure parameter passed on to postgresql perl package resource. 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 ###Class: postgresql::lib::python
This class installs the postgresql Python libraries. For customer requirements you can customise the following parameters: 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 # Class for setting cross-class global overrides. See README.md for more
# details. # details.
class postgresql::globals ( class postgresql::globals (
$client_package_name = undef, $client_package_name = undef,
$server_package_name = undef, $server_package_name = undef,
$contrib_package_name = undef, $contrib_package_name = undef,
$devel_package_name = undef, $devel_package_name = undef,
$java_package_name = undef, $java_package_name = undef,
$perl_package_name = undef, $docs_package_name = undef,
$plperl_package_name = undef, $perl_package_name = undef,
$python_package_name = undef, $plperl_package_name = undef,
$postgis_package_name = undef, $plpython_package_name = undef,
$python_package_name = undef,
$postgis_package_name = undef,
$service_name = undef, $service_name = undef,
$service_provider = undef, $service_provider = undef,
$service_status = undef, $service_status = undef,
$default_database = undef, $default_database = undef,
$validcon_script_path = undef, $validcon_script_path = undef,
$initdb_path = undef, $initdb_path = undef,
$createdb_path = undef, $createdb_path = undef,
$psql_path = undef, $psql_path = undef,
$pg_hba_conf_path = undef, $pg_hba_conf_path = undef,
$pg_ident_conf_path = undef, $pg_ident_conf_path = undef,
$postgresql_conf_path = undef, $postgresql_conf_path = undef,
$recovery_conf_path = undef, $recovery_conf_path = undef,
$pg_hba_conf_defaults = undef, $pg_hba_conf_defaults = undef,
$datadir = undef, $datadir = undef,
$confdir = undef, $confdir = undef,
$bindir = undef, $bindir = undef,
$xlogdir = undef, $xlogdir = undef,
$logdir = undef, $logdir = undef,
$user = undef, $user = undef,
$group = undef, $group = undef,
$version = undef, $version = undef,
$postgis_version = undef, $postgis_version = undef,
$needs_initdb = undef, $needs_initdb = undef,
$encoding = undef, $encoding = undef,
$locale = undef, $locale = undef,
$manage_pg_hba_conf = undef, $manage_pg_hba_conf = undef,
$manage_pg_ident_conf = undef, $manage_pg_ident_conf = undef,
$manage_recovery_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 # We are determining this here, because it is needed by the package repo
# class. # 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]}" $package_version = "${version_parts[0]}${version_parts[1]}"
if $version == $postgresql::globals::default_version { if $version == $postgresql::globals::default_version {
$client_package_name = pick($client_package_name, 'postgresql') $client_package_name = pick($client_package_name, 'postgresql')
$server_package_name = pick($server_package_name, 'postgresql-server') $server_package_name = pick($server_package_name, 'postgresql-server')
$contrib_package_name = pick($contrib_package_name,'postgresql-contrib') $contrib_package_name = pick($contrib_package_name,'postgresql-contrib')
$devel_package_name = pick($devel_package_name, 'postgresql-devel') $devel_package_name = pick($devel_package_name, 'postgresql-devel')
$java_package_name = pick($java_package_name, 'postgresql-jdbc') $java_package_name = pick($java_package_name, 'postgresql-jdbc')
$plperl_package_name = pick($plperl_package_name, 'postgresql-plperl') $docs_package_name = pick($docs_package_name, 'postgresql-docs')
$service_name = pick($service_name, 'postgresql') $plperl_package_name = pick($plperl_package_name, 'postgresql-plperl')
$bindir = pick($bindir, '/usr/bin') $plpython_package_name = pick($plpython_package_name, 'postgresql-plpython')
$datadir = $::operatingsystem ? { $service_name = pick($service_name, 'postgresql')
$bindir = pick($bindir, '/usr/bin')
$datadir = $::operatingsystem ? {
'Amazon' => pick($datadir, '/var/lib/pgsql9/data'), 'Amazon' => pick($datadir, '/var/lib/pgsql9/data'),
default => pick($datadir, '/var/lib/pgsql/data'), default => pick($datadir, '/var/lib/pgsql/data'),
} }
$confdir = pick($confdir, $datadir) $confdir = pick($confdir, $datadir)
} else { } else {
$client_package_name = pick($client_package_name, "postgresql${package_version}") $client_package_name = pick($client_package_name, "postgresql${package_version}")
$server_package_name = pick($server_package_name, "postgresql${package_version}-server") $server_package_name = pick($server_package_name, "postgresql${package_version}-server")
$contrib_package_name = pick($contrib_package_name,"postgresql${package_version}-contrib") $contrib_package_name = pick($contrib_package_name,"postgresql${package_version}-contrib")
$devel_package_name = pick($devel_package_name, "postgresql${package_version}-devel") $devel_package_name = pick($devel_package_name, "postgresql${package_version}-devel")
$java_package_name = pick($java_package_name, "postgresql${package_version}-jdbc") $java_package_name = pick($java_package_name, "postgresql${package_version}-jdbc")
$plperl_package_name = pick($plperl_package_name, "postgresql${package_version}-plperl") $docs_package_name = pick($docs_package_name, "postgresql${package_version}-docs")
$service_name = pick($service_name, "postgresql-${version}") $plperl_package_name = pick($plperl_package_name, "postgresql${package_version}-plperl")
$bindir = pick($bindir, "/usr/pgsql-${version}/bin") $plpython_package_name = pick($plpython_package_name, "postgresql${package_version}-plpython")
$datadir = $::operatingsystem ? { $service_name = pick($service_name, "postgresql-${version}")
$bindir = pick($bindir, "/usr/pgsql-${version}/bin")
$datadir = $::operatingsystem ? {
'Amazon' => pick($datadir, "/var/lib/pgsql9/${version}/data"), 'Amazon' => pick($datadir, "/var/lib/pgsql9/${version}/data"),
default => pick($datadir, "/var/lib/pgsql/${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_status = $service_status
$service_reload = "service ${service_name} reload" $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 # Archlinux doesn't have a client-package but has a libs package which
# pulls in postgresql server # pulls in postgresql server
$client_package_name = pick($client_package_name, 'postgresql') $client_package_name = pick($client_package_name, 'postgresql')
$server_package_name = pick($server_package_name, 'postgresql-libs') $server_package_name = pick($server_package_name, 'postgresql-libs')
$java_package_name = pick($java_package_name, 'postgresql-jdbc') $java_package_name = pick($java_package_name, 'postgresql-jdbc')
# Archlinux doesn't have develop packages # 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 # 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 # Archlinux postgresql package provides plperl
$plperl_package_name = pick($plperl_package_name, 'undef') $plperl_package_name = pick($plperl_package_name, 'undef')
$service_name = pick($service_name, 'postgresql') $plpython_package_name = pick($plpython_package_name, 'undef')
$bindir = pick($bindir, '/usr/bin') $service_name = pick($service_name, 'postgresql')
$datadir = pick($datadir, '/var/lib/postgres/data') $bindir = pick($bindir, '/usr/bin')
$confdir = pick($confdir, $datadir) $datadir = pick($datadir, '/var/lib/postgres/data')
$psql_path = pick($psql_path, "${bindir}/psql") $confdir = pick($confdir, $datadir)
$psql_path = pick($psql_path, "${bindir}/psql")
$service_status = $service_status $service_status = $service_status
$service_reload = "service ${service_name} reload" $service_reload = "service ${service_name} reload"
$python_package_name = pick($python_package_name, 'python-psycopg2') $python_package_name = pick($python_package_name, 'python-psycopg2')
# Archlinux does not have a perl::DBD::Pg package # 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': { 'Debian': {
@ -126,31 +131,32 @@ class postgresql::params inherits postgresql::globals {
} }
} }
$client_package_name = pick($client_package_name, "postgresql-client-${version}") $client_package_name = pick($client_package_name, "postgresql-client-${version}")
$server_package_name = pick($server_package_name, "postgresql-${version}") $server_package_name = pick($server_package_name, "postgresql-${version}")
$contrib_package_name = pick($contrib_package_name, "postgresql-contrib-${version}") $contrib_package_name = pick($contrib_package_name, "postgresql-contrib-${version}")
if versioncmp($postgis_version, '2') < 0 { if versioncmp($postgis_version, '2') < 0 {
$postgis_package_name = pick($postgis_package_name, "postgresql-${version}-postgis") $postgis_package_name = pick($postgis_package_name, "postgresql-${version}-postgis")
} else { } else {
$postgis_package_name = pick($postgis_package_name, "postgresql-${version}-postgis-${postgis_version}") $postgis_package_name = pick($postgis_package_name, "postgresql-${version}-postgis-${postgis_version}")
} }
$devel_package_name = pick($devel_package_name, 'libpq-dev') $devel_package_name = pick($devel_package_name, 'libpq-dev')
$java_package_name = pick($java_package_name, 'libpostgresql-jdbc-java') $java_package_name = pick($java_package_name, 'libpostgresql-jdbc-java')
$perl_package_name = pick($perl_package_name, 'libdbd-pg-perl') $perl_package_name = pick($perl_package_name, 'libdbd-pg-perl')
$plperl_package_name = pick($plperl_package_name, "postgresql-plperl-${version}") $plperl_package_name = pick($plperl_package_name, "postgresql-plperl-${version}")
$python_package_name = pick($python_package_name, 'python-psycopg2') $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") $bindir = pick($bindir, "/usr/lib/postgresql/${version}/bin")
$datadir = pick($datadir, "/var/lib/postgresql/${version}/main") $datadir = pick($datadir, "/var/lib/postgresql/${version}/main")
$confdir = pick($confdir, "/etc/postgresql/${version}/main") $confdir = pick($confdir, "/etc/postgresql/${version}/main")
if $::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '8.0') >= 0 { if $::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '8.0') >= 0 {
# Jessie uses systemd # Jessie uses systemd
$service_status = pick($service_status, "/usr/sbin/service ${service_name}@*-main status") $service_status = pick($service_status, "/usr/sbin/service ${service_name}@*-main status")
} else { } else {
$service_status = pick($service_status, "/etc/init.d/${service_name} status | /bin/egrep -q 'Running clusters: .+|online'") $service_status = pick($service_status, "/etc/init.d/${service_name} status | /bin/egrep -q 'Running clusters: .+|online'")
} }
$service_reload = "service ${service_name} reload" $service_reload = "service ${service_name} reload"
$psql_path = pick($psql_path, '/usr/bin/psql') $psql_path = pick($psql_path, '/usr/bin/psql')
} }
'FreeBSD': { 'FreeBSD': {

View file

@ -7,6 +7,7 @@ class postgresql::server (
$package_ensure = $postgresql::params::package_ensure, $package_ensure = $postgresql::params::package_ensure,
$plperl_package_name = $postgresql::params::plperl_package_name, $plperl_package_name = $postgresql::params::plperl_package_name,
$plpython_package_name = $postgresql::params::plpython_package_name,
$service_ensure = $postgresql::params::service_ensure, $service_ensure = $postgresql::params::service_ensure,
$service_enable = $postgresql::params::service_enable, $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