2013-08-27 22:43:47 +02:00
# PRIVATE CLASS : do not use directly
class postgresql: : params inherits postgresql: : globals {
2013-09-18 23:25:51 +02:00
$e nsure = true
2013-08-27 22:43:47 +02:00
$ version = $ globals_version
$ listen_addresses = 'localhost'
$ ip_mask_deny_postgres_user = '0.0.0.0/0'
$ ip_mask_allow_all_users = '127.0.0.1/32'
$ ipv4acls = [ ]
$ ipv6acls = [ ]
$ user = pick( $ user, 'postgres' )
$ group = pick( $ group, 'postgres' )
$e ncoding = pick( $e ncoding, 'UTF8' )
2013-09-19 17:30:15 +02:00
$ locale = $ locale
$ service_provider = $ service_provider
$ manage_firewall = $ manage_firewall
2012-12-04 05:42:20 +01:00
2012-11-25 15:28:13 +01:00
# Amazon Linux's OS Family is ' Linux', operating system ' Amazon' .
2012-06-08 22:37:21 +02:00
case $ : : osfamily {
2012-11-25 15:28:13 +01:00
'RedHat' , 'Linux' : {
2013-09-03 20:46:07 +02:00
$ needs_initdb = pick( $ needs_initdb, true )
$f irewall_supported = pick( $f irewall_supported, true )
2013-08-27 22:43:47 +02:00
2013-09-03 20:46:07 +02:00
if $ version = = $defa ult_version {
$c lient_package_name = pick( $c lient_package_name, 'postgresql' )
$ server_package_name = pick( $ server_package_name, 'postgresql-server' )
$c ontrib_package_name = pick( $c ontrib_package_name, 'postgresql-contrib' )
$de vel_package_name = pick( $de vel_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' )
$b indir = pick( $b indir, '/usr/bin' )
$da tadir = pick( $da tadir, '/var/lib/pgsql/data' )
$c onfdir = pick( $c onfdir, $da tadir)
2012-12-04 05:42:20 +01:00
} else {
2013-09-03 20:46:07 +02:00
$ version_parts = split( $ version, '[.]' )
$ package_version = "${version_parts[0]}${version_parts[1]}"
$c lient_package_name = pick( $c lient_package_name, "postgresql${package_version}" )
$ server_package_name = pick( $ server_package_name, "postgresql${package_version}-server" )
$c ontrib_package_name = pick( $c ontrib_package_name, "postgresql${package_version}-contrib" )
$de vel_package_name = pick( $de vel_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}" )
$b indir = pick( $b indir, "/usr/pgsql-${version}/bin" )
$da tadir = pick( $da tadir, "/var/lib/pgsql/${version}/data" )
$c onfdir = pick( $c onfdir, $da tadir)
2012-12-04 05:42:20 +01:00
}
2013-08-27 22:43:47 +02:00
$ service_status = $ service_status
$ python_package_name = pick( $ python_package_name, 'python-psycopg2' )
2012-06-08 22:37:21 +02:00
}
2012-12-04 05:42:20 +01:00
2012-06-08 22:37:21 +02:00
'Debian' : {
2012-06-08 23:00:24 +02:00
2013-04-26 17:35:09 +02:00
if $ manage_package_repo = = true {
2013-08-27 22:43:47 +02:00
$ needs_initdb = pick( $ needs_initdb, true )
$ service_name = pick( $ service_name, 'postgresql' )
2013-04-26 17:35:09 +02:00
} else {
2013-08-27 22:43:47 +02:00
$ needs_initdb = pick( $ needs_initdb, false )
$ service_name = $ : : operatingsystem ? {
'Debian' = > pick( $ service_name, 'postgresql' ) ,
'Ubuntu' = > $ : : lsbmajdistrelease ? {
'10' = > pick( $ service_name, "postgresql-${version}" ) ,
default = > pick( $ service_name, 'postgresql' ) ,
} ,
default = > undef
2012-12-04 05:42:20 +01:00
}
}
2013-08-27 22:43:47 +02:00
$c lient_package_name = pick( $c lient_package_name, "postgresql-client-${version}" )
$ server_package_name = pick( $ server_package_name, "postgresql-${version}" )
$c ontrib_package_name = pick( $c ontrib_package_name, "postgresql-contrib-${version}" )
$de vel_package_name = pick( $de vel_package_name, 'libpq-dev' )
$ java_package_name = pick( $ java_package_name, 'libpostgresql-jdbc-java' )
$ plperl_package_name = pick( $ plperl_package_name, "postgresql-plperl-${version}" )
$ python_package_name = pick( $ python_package_name, 'python-psycopg2' )
2013-06-06 20:39:00 +02:00
2013-08-27 22:43:47 +02:00
$b indir = pick( $b indir, "/usr/lib/postgresql/${version}/bin" )
$da tadir = pick( $da tadir, "/var/lib/postgresql/${version}/main" )
$c onfdir = pick( $c onfdir, "/etc/postgresql/${version}/main" )
$ service_status = pick( $ service_status, "/etc/init.d/${service_name} status | /bin/egrep -q 'Running clusters: .+|online'" )
2013-06-06 20:39:00 +02:00
2013-08-27 22:43:47 +02:00
$f irewall_supported = pick( $f irewall_supported, true )
}
2013-06-06 20:39:00 +02:00
2013-08-27 22:43:47 +02:00
default : {
# Based on the existing version of the firewall module, this is normally
# false for other OS, but this allows an escape hatch to override it.
$f irewall_supported = pick( $f irewall_supported, false )
# Since we can' t determine defaults on our own, we rely on users setting
# parameters with the postgresql: : globals class . Here we are checking
# that the mandatory minimum is set for the module to operate.
$e rr_prefix = "Module ${module_name} does not provide defaults for osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}; please specify a value for ${module_name}::globals::"
if ( $ needs_initdb = = undef) { fail("${err_prefix} needs_initdb" ) }
if ( $ service_name = = undef) { fail("${err_prefix} service_name" ) }
if ( $c lient_package_name = = undef) { fail("${err_prefix} client_package_name" ) }
if ( $ server_package_name = = undef) { fail("${err_prefix} server_package_name" ) }
if ( $b indir = = undef) { fail("${err_prefix} bindir" ) }
if ( $da tadir = = undef) { fail("${err_prefix} datadir" ) }
if ( $c onfdir = = undef) { fail("${err_prefix} confdir" ) }
2012-06-08 22:37:21 +02:00
}
}
2012-12-04 05:42:20 +01:00
2013-08-27 22:43:47 +02:00
$ initdb_path = pick( $ initdb_path, "${bindir}/initdb" )
$c reatedb_path = pick( $c reatedb_path, "${bindir}/createdb" )
$ psql_path = pick( $ psql_path, "${bindir}/psql" )
$ pg_hba_conf_path = pick( $ pg_hba_conf_path, "${confdir}/pg_hba.conf" )
$ pg_hba_conf_defaults = pick( $ pg_hba_conf_defaults, true )
$ postgresql_conf_path = pick( $ postgresql_conf_path, "${confdir}/postgresql.conf" )
2012-06-08 22:37:21 +02:00
}