2013-08-27 22:43:47 +02:00
# PRIVATE CLASS : do not use directly
class postgresql: : params inherits postgresql: : globals {
2015-01-11 05:27:57 +01:00
$ version = $ postgresql: : globals: : globals_version
$ postgis_version = $ postgresql: : globals: : globals_postgis_version
2013-08-27 22:43:47 +02:00
$ listen_addresses = 'localhost'
2014-04-17 21:09:07 +02:00
$ port = 5 4 3 2
2013-08-27 22:43:47 +02:00
$ ip_mask_deny_postgres_user = '0.0.0.0/0'
$ ip_mask_allow_all_users = '127.0.0.1/32'
$ ipv4acls = [ ]
$ ipv6acls = [ ]
2015-01-11 05:27:57 +01:00
$e ncoding = $ postgresql: : globals: : encoding
$ locale = $ postgresql: : globals: : locale
2014-07-02 16:45:07 +02:00
$ service_ensure = 'running'
$ service_enable = true
2014-12-04 14:26:37 +01:00
$ service_manage = true
2015-09-29 10:11:28 +02:00
$ service_restart_on_change = true
2013-09-19 17:30:15 +02:00
$ service_provider = $ service_provider
2013-10-02 14:43:21 +02:00
$ manage_pg_hba_conf = pick( $ manage_pg_hba_conf, true )
2014-07-30 22:55:20 +02:00
$ manage_pg_ident_conf = pick( $ manage_pg_ident_conf, true )
2015-02-07 07:28:54 +01:00
$ manage_recovery_conf = pick( $ manage_recovery_conf, false )
2014-07-02 16:45:07 +02:00
$ package_ensure = 'present'
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' : {
2014-11-21 05:09:28 +01:00
$ link_pg_config = true
2014-03-07 13:12:02 +01:00
$ user = pick( $ user, 'postgres' )
$ group = pick( $ group, 'postgres' )
2013-09-03 20:46:07 +02:00
$ needs_initdb = pick( $ needs_initdb, true )
2014-04-08 16:40:49 +02:00
$ version_parts = split( $ version, '[.]' )
$ package_version = "${version_parts[0]}${version_parts[1]}"
2013-08-27 22:43:47 +02:00
2015-01-11 05:27:57 +01:00
if $ version = = $ postgresql: : globals: : default_version {
2015-03-04 12:58:15 +01:00
$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' )
$d ocs_package_name = pick( $d ocs_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' )
$b indir = pick( $b indir, '/usr/bin' )
$da tadir = $ : : operatingsystem ? {
2015-11-19 20:06:19 +01:00
'Amazon' = > pick( $da tadir, "/var/lib/pgsql${package_version}/data" ) ,
2013-10-02 21:38:20 +02:00
default = > pick( $da tadir, '/var/lib/pgsql/data' ) ,
}
2015-03-04 12:58:15 +01:00
$c onfdir = pick( $c onfdir, $da tadir)
2012-12-04 05:42:20 +01:00
} else {
2015-03-04 12:58:15 +01:00
$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" )
$d ocs_package_name = pick( $d ocs_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" )
2015-11-19 20:06:19 +01:00
$ service_name = $ : : operatingsystem ? {
'Amazon' = > pick( $ service_name, "postgresql${version}" ) ,
default = > pick( $ service_name, "postgresql-${version}" ) ,
}
$b indir = $ : : operatingsystem ? {
'Amazon' = > pick( $b indir, '/usr/bin' ) ,
default = > pick( $b indir, "/usr/pgsql-${version}/bin" ) ,
}
2015-03-04 12:58:15 +01:00
$da tadir = $ : : operatingsystem ? {
2015-11-19 20:06:19 +01:00
'Amazon' = > pick( $da tadir, "/var/lib/pgsql${package_version}/data" ) ,
2013-10-02 21:38:20 +02:00
default = > pick( $da tadir, "/var/lib/pgsql/${version}/data" ) ,
}
2015-03-04 12:58:15 +01:00
$c onfdir = pick( $c onfdir, $da tadir)
2012-12-04 05:42:20 +01:00
}
2015-03-04 12:58:15 +01:00
$ psql_path = pick( $ psql_path, "${bindir}/psql" )
2012-12-04 05:42:20 +01:00
2013-08-27 22:43:47 +02:00
$ service_status = $ service_status
2014-09-11 01:29:48 +02:00
$ service_reload = "service ${service_name} reload"
2014-04-02 23:52:07 +02:00
$ perl_package_name = pick( $ perl_package_name, 'perl-DBD-Pg' )
2013-08-27 22:43:47 +02:00
$ python_package_name = pick( $ python_package_name, 'python-psycopg2' )
2013-10-16 21:46:50 +02:00
2016-01-28 00:08:47 +01:00
if $ postgresql: : globals: : postgis_package_name {
$ postgis_package_name = $ postgresql: : globals: : postgis_package_name
} elsif $ : : operatingsystemrelease = ~ / ^ 5 \ . / {
$ postgis_package_name = 'postgis'
} elsif $ postgis_version and versioncmp( $ postgis_version, '2' ) < 0 {
$ postgis_package_name = "postgis${package_version}"
} else {
$ postgis_package_name = "postgis2_${package_version}"
}
2012-06-08 22:37:21 +02:00
}
2012-12-04 05:42:20 +01:00
2013-09-21 16:48:03 +02:00
'Archlinux' : {
2014-11-21 05:09:28 +01:00
$ link_pg_config = true
2013-09-21 16:48:03 +02:00
$ needs_initdb = pick( $ needs_initdb, true )
2014-03-07 13:12:02 +01:00
$ user = pick( $ user, 'postgres' )
$ group = pick( $ group, 'postgres' )
2013-09-21 16:48:03 +02:00
# Archlinux doesn' t have a client- package but has a libs package which
# pulls in postgresql server
2015-03-04 12:58:15 +01:00
$c lient_package_name = pick( $c lient_package_name, 'postgresql' )
$ server_package_name = pick( $ server_package_name, 'postgresql-libs' )
$ java_package_name = pick( $ java_package_name, 'postgresql-jdbc' )
2013-09-21 16:48:03 +02:00
# Archlinux doesn' t have develop packages
2015-03-04 12:58:15 +01:00
$de vel_package_name = pick( $de vel_package_name, 'postgresql-devel' )
2013-09-21 16:48:03 +02:00
# Archlinux does have postgresql- contrib but it isn' t maintained
2015-03-04 12:58:15 +01:00
$c ontrib_package_name = pick( $c ontrib_package_name, 'undef' )
2013-09-21 16:48:03 +02:00
# Archlinux postgresql package provides plperl
2015-03-04 12:58:15 +01:00
$ plperl_package_name = pick( $ plperl_package_name, 'undef' )
$ plpython_package_name = pick( $ plpython_package_name, 'undef' )
$ service_name = pick( $ service_name, 'postgresql' )
$b indir = pick( $b indir, '/usr/bin' )
$da tadir = pick( $da tadir, '/var/lib/postgres/data' )
$c onfdir = pick( $c onfdir, $da tadir)
$ psql_path = pick( $ psql_path, "${bindir}/psql" )
2013-09-21 16:48:03 +02:00
2015-03-04 12:58:15 +01:00
$ service_status = $ service_status
$ service_reload = "service ${service_name} reload"
$ python_package_name = pick( $ python_package_name, 'python-psycopg2' )
2014-04-02 23:52:07 +02:00
# Archlinux does not have a perl: : DBD: : Pg package
2015-03-04 12:58:15 +01:00
$ perl_package_name = pick( $ perl_package_name, 'undef' )
2013-09-21 16:48:03 +02:00
}
2012-06-08 22:37:21 +02:00
'Debian' : {
2014-11-21 05:09:28 +01:00
$ link_pg_config = false
2014-03-07 13:12:02 +01:00
$ user = pick( $ user, 'postgres' )
$ group = pick( $ group, 'postgres' )
2012-06-08 23:00:24 +02:00
2015-01-11 05:27:57 +01:00
if $ postgresql: : globals: : 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 ? {
2014-08-27 16:16:42 +02:00
/ ^ 1 0 / = > pick( $ service_name, "postgresql-${version}" ) ,
2013-08-27 22:43:47 +02:00
default = > pick( $ service_name, 'postgresql' ) ,
} ,
default = > undef
2012-12-04 05:42:20 +01:00
}
}
2015-03-04 12:58:15 +01: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}" )
2016-01-28 00:08:47 +01:00
if $ postgis_version and versioncmp( $ postgis_version, '2' ) < 0 {
2015-02-25 13:50:32 +01:00
$ postgis_package_name = pick( $ postgis_package_name, "postgresql-${version}-postgis" )
} else {
$ postgis_package_name = pick( $ postgis_package_name, "postgresql-${version}-postgis-${postgis_version}" )
}
2015-03-04 12:58:15 +01:00
$de vel_package_name = pick( $de vel_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' )
2013-06-06 20:39:00 +02:00
2015-03-04 12:58:15 +01: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" )
2015-03-18 01:12:31 +01:00
if $ : : operatingsystem = = 'Debian' and versioncmp( $ : : operatingsystemrelease, '8.0' ) > = 0 {
2015-03-17 15:55:53 +01:00
# 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'" )
}
2015-03-04 12:58:15 +01:00
$ service_reload = "service ${service_name} reload"
$ psql_path = pick( $ psql_path, '/usr/bin/psql' )
2013-08-27 22:43:47 +02:00
}
2013-06-06 20:39:00 +02:00
2013-12-08 09:15:21 +01:00
'FreeBSD' : {
2014-11-21 05:09:28 +01:00
$ link_pg_config = true
2014-03-07 13:12:02 +01:00
$ user = pick( $ user, 'pgsql' )
$ group = pick( $ group, 'pgsql' )
2013-12-08 09:15:21 +01:00
$c lient_package_name = pick( $c lient_package_name, "databases/postgresql${version}-client" )
$ server_package_name = pick( $ server_package_name, "databases/postgresql${version}-server" )
$c ontrib_package_name = pick( $c ontrib_package_name, "databases/postgresql${version}-contrib" )
$de vel_package_name = pick( $de vel_package_name, 'databases/postgresql-libpqxx3' )
$ java_package_name = pick( $ java_package_name, 'databases/postgresql-jdbc' )
2014-04-02 23:52:07 +02:00
$ perl_package_name = pick( $ plperl_package_name, 'databases/p5-DBD-Pg' )
2013-12-08 09:15:21 +01:00
$ plperl_package_name = pick( $ plperl_package_name, "databases/postgresql${version}-plperl" )
$ python_package_name = pick( $ python_package_name, 'databases/py-psycopg2' )
$ service_name = pick( $ service_name, 'postgresql' )
$b indir = pick( $b indir, '/usr/local/bin' )
$da tadir = pick( $da tadir, '/usr/local/pgsql/data' )
2014-03-07 15:39:21 +01:00
$c onfdir = pick( $c onfdir, $da tadir)
2015-01-24 01:07:29 +01:00
$ service_status = pick( $ service_status, "/usr/local/etc/rc.d/${service_name} onestatus" )
2014-09-11 01:29:48 +02:00
$ service_reload = "service ${service_name} reload"
$ psql_path = pick( $ psql_path, "${bindir}/psql" )
$ needs_initdb = pick( $ needs_initdb, true )
}
'OpenBSD' : {
$ user = pick( $ user, '_postgresql' )
$ group = pick( $ group, '_postgresql' )
$c lient_package_name = pick( $c lient_package_name, 'postgresql-client' )
$ 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-client' )
$ java_package_name = pick( $ java_package_name, 'postgresql-jdbc' )
$ perl_package_name = pick( $ perl_package_name, 'databases/p5-DBD-Pg' )
$ plperl_package_name = undef
$ python_package_name = pick( $ python_package_name, 'py-psycopg2' )
$ service_name = pick( $ service_name, 'postgresql' )
$b indir = pick( $b indir, '/usr/local/bin' )
$da tadir = pick( $da tadir, '/var/postgresql/data' )
$c onfdir = pick( $c onfdir, $da tadir)
$ service_status = pick( $ service_status, "/etc/rc.d/${service_name} check" )
$ service_reload = "/etc/rc.d/${service_name} reload"
2013-12-08 09:15:21 +01:00
$ psql_path = pick( $ psql_path, "${bindir}/psql" )
$ needs_initdb = pick( $ needs_initdb, true )
}
2014-06-27 15:30:17 +02:00
'Suse' : {
2014-11-21 05:09:28 +01:00
$ link_pg_config = true
2014-06-27 15:30:17 +02:00
$ user = pick( $ user, 'postgres' )
$ group = pick( $ group, 'postgres' )
$c lient_package_name = pick( $c lient_package_name, "postgresql${version}" )
$ server_package_name = pick( $ server_package_name, "postgresql${version}-server" )
$c ontrib_package_name = pick( $c ontrib_package_name, "postgresql${version}-contrib" )
$de vel_package_name = pick( $de vel_package_name, "postgresql${version}-devel" )
2015-04-26 00:25:48 +02:00
$ java_package_name = pick( $ java_package_name, "postgresql${version}-jdbc" )
$ perl_package_name = pick( $ plperl_package_name, 'perl-DBD-Pg' )
$ plperl_package_name = pick( $ plperl_package_name, "postgresql${version}-plperl" )
$ python_package_name = pick( $ python_package_name, 'python-psycopg2' )
2014-06-27 15:30:17 +02:00
$ service_name = pick( $ service_name, 'postgresql' )
$b indir = pick( $b indir, "/usr/lib/postgresql${version}/bin" )
$da tadir = pick( $da tadir, '/var/lib/pgsql/data' )
2014-08-21 19:22:21 +02:00
$c onfdir = pick( $c onfdir, $da tadir)
2014-06-27 15:30:17 +02:00
$ service_status = pick( $ service_status, "/etc/init.d/${service_name} status" )
2014-09-11 01:29:48 +02:00
$ service_reload = "/etc/init.d/${service_name} reload"
2014-06-27 15:30:17 +02:00
$ psql_path = pick( $ psql_path, "${bindir}/psql" )
$ needs_initdb = pick( $ needs_initdb, true )
}
2013-08-27 22:43:47 +02:00
default : {
2014-11-21 05:09:28 +01:00
$ link_pg_config = true
2013-10-25 03:01:02 +02:00
$ psql_path = pick( $ psql_path, "${bindir}/psql" )
2013-08-27 22:43:47 +02:00
# 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
2014-04-30 14:30:03 +02:00
$ validcon_script_path = pick( $ validcon_script_path, '/usr/local/bin/validate_postgresql_connection.sh' )
2013-08-27 22:43:47 +02:00
$ initdb_path = pick( $ initdb_path, "${bindir}/initdb" )
$ pg_hba_conf_path = pick( $ pg_hba_conf_path, "${confdir}/pg_hba.conf" )
$ pg_hba_conf_defaults = pick( $ pg_hba_conf_defaults, true )
2014-07-24 22:04:02 +02:00
$ pg_ident_conf_path = pick( $ pg_ident_conf_path, "${confdir}/pg_ident.conf" )
2013-08-27 22:43:47 +02:00
$ postgresql_conf_path = pick( $ postgresql_conf_path, "${confdir}/postgresql.conf" )
2015-02-07 07:28:54 +01:00
$ recovery_conf_path = pick( $ recovery_conf_path, "${datadir}/recovery.conf" )
2013-10-27 02:50:05 +02:00
$defa ult_database = pick( $defa ult_database, 'postgres' )
2012-06-08 22:37:21 +02:00
}