2012-06-08 22:37:21 +02:00
# Class : postgresql: : params
#
# The postgresql configuration settings.
#
# Parameters:
#
# Actions:
#
# Requires :
#
# Sample Usage:
#
2012-12-04 22:47:49 +01:00
# TODO: add real docs
# This class allows you to use a newer version of postgres, rather than your
# system' s default version.
#
# If you want to do that, note that it is important that you use the '->' ,
# or a before/ require metaparameter to make sure that the ` params`
# class is evaluated before any of the other classes in the module.
#
# Also note that this class includes the ability to automatically manage
# the yumrepo resource. If you' d prefer to manage the repo yourself, simply pass
# 'false' or omit the 'manage_repo' parameter- - it defaults to 'false' . You will
# still need to use the 'params' class to specify the postgres version
# number, though, in order for the other classes to be able to find the
# correct paths to the postgres dirs.
class postgresql: : params(
2013-02-24 22:06:37 +01:00
$ version = $ : : postgres_default_version,
$ manage_package_repo = false ,
$ package_source = undef,
$ locale = undef,
$c harset = 'UTF8' ,
$c ustom_datadir = undef,
$c ustom_confdir = undef,
$c ustom_bindir = undef,
$c ustom_client_package_name = undef,
$c ustom_server_package_name = undef,
$c ustom_contrib_package_name = undef,
$c ustom_devel_package_name = undef,
$c ustom_java_package_name = undef,
$c ustom_service_name = undef,
$c ustom_user = undef,
$c ustom_group = undef,
$ run_initdb = undef
2012-12-04 22:47:49 +01:00
) {
2013-02-07 14:20:53 +01:00
$ user = pick( $c ustom_user, 'postgres' )
$ group = pick( $c ustom_group, 'postgres' )
2012-06-09 18:23:11 +02:00
$ ip_mask_deny_postgres_user = '0.0.0.0/0'
$ ip_mask_allow_all_users = '127.0.0.1/32'
$ listen_addresses = 'localhost'
2012-10-22 07:27:35 +02:00
$ ipv4acls = [ ]
$ ipv6acls = [ ]
2012-06-08 23:00:24 +02:00
# TODO: figure out a way to make this not platform - specific
2012-06-09 18:23:11 +02:00
$ manage_redhat_firewall = false
2012-06-08 23:00:24 +02:00
2012-12-04 22:47:49 +01:00
if ( $ manage_package_repo) {
2013-02-18 16:06:44 +01:00
case $ : : osfamily {
'RedHat' : {
$ rh_pkg_source = pick( $ package_source, 'yum.postgresql.org' )
case $ rh_pkg_source {
'yum.postgresql.org' : {
class { 'postgresql::package_source::yum_postgresql_org' :
version = > $ version
2013-02-15 11:23:18 +01:00
}
2013-02-18 16:06:44 +01:00
}
2013-02-15 11:23:18 +01:00
2013-02-18 16:06:44 +01:00
default : {
fail( "Unsupported package source '${rh_pkg_source}' for ${::osfamily} OS family. Currently the only supported source is 'yum.postgresql.org'" )
2013-02-15 11:23:18 +01:00
}
2012-12-04 22:47:49 +01:00
}
2013-02-18 16:06:44 +01:00
}
2012-12-04 22:47:49 +01:00
2013-02-18 16:06:44 +01:00
'Debian' : {
class { 'postgresql::package_source::apt_postgresql_org': }
}
2013-01-11 22:52:30 +01:00
2013-02-18 16:06:44 +01:00
default : {
fail( "Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} currently only supports osfamily RedHat and Debian" )
2012-12-04 22:47:49 +01:00
}
}
2013-02-18 16:06:44 +01:00
}
2012-12-04 22:47:49 +01:00
2012-09-14 22:09:31 +02:00
# This is a bit hacky, but if the puppet nodes don' t have pluginsync enabled,
# they will fail with a not - so- helpful error message . Here we are explicitly
# verifying that the custom fact exists ( which implies that pluginsync is
# enabled and succeeded) . If not , we fail with a hint that tells the user
# that pluginsync might not be enabled. Ideally this would be handled directly
# in puppet.
if ( $ : : postgres_default_version = = undef) {
2013-02-07 10:51:33 +01:00
fail "No value for postgres_default_version facter fact; it's possible that you don't have pluginsync enabled."
2012-09-14 22:09:31 +02:00
}
2012-12-04 05:42:20 +01:00
case $ : : operatingsystem {
default : {
$ service_provider = undef
}
}
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-02-07 14:20:53 +01:00
$ needs_initdb = pick( $ run_initdb, true )
2012-06-08 23:00:24 +02:00
$f irewall_supported = true
2012-12-04 05:42:20 +01:00
$ persist_firewall_command = '/sbin/iptables-save > /etc/sysconfig/iptables'
if $ version = = $ : : postgres_default_version {
2013-02-24 22:06:37 +01:00
$c lient_package_name = pick( $c ustom_client_package_name, 'postgresql' )
$ server_package_name = pick( $c ustom_server_package_name, 'postgresql-server' )
$c ontrib_package_name = pick( $c ustom_contrib_package_name, 'postgresql-contrib' )
$de vel_package_name = pick( $c ustom_devel_package_name, 'postgresql-devel' )
$ java_package_name = pick( $c ustom_java_package_name, 'postgresql-jdbc' )
2013-02-07 14:20:53 +01:00
$ service_name = pick( $c ustom_service_name, 'postgresql' )
$b indir = pick( $c ustom_bindir, '/usr/bin' )
$da tadir = pick( $c ustom_datadir, '/var/lib/pgsql/data' )
$c onfdir = pick( $c ustom_confdir, $da tadir)
2012-12-04 05:42:20 +01:00
} else {
2013-02-24 22:06:37 +01:00
$ version_parts = split( $ version, '[.]' )
$ package_version = "${version_parts[0]}${version_parts[1]}"
$c lient_package_name = pick( $c ustom_client_package_name, "postgresql${package_version}" )
$ server_package_name = pick( $c ustom_server_package_name, "postgresql${package_version}-server" )
$c ontrib_package_name = pick( $c ustom_contrib_package_name, "postgresql${package_version}-contrib" )
$de vel_package_name = pick( $c ustom_devel_package_name, "postgresql${package_version}-devel" )
$ java_package_name = pick( $c ustom_java_package_name, "postgresql${package_version}-jdbc" )
2013-02-07 14:20:53 +01:00
$ service_name = pick( $c ustom_service_name, "postgresql-${version}" )
$b indir = pick( $c ustom_bindir, "/usr/pgsql-${version}/bin" )
$da tadir = pick( $c ustom_datadir, "/var/lib/pgsql/${version}/data" )
$c onfdir = pick( $c ustom_confdir, $da tadir)
2012-12-04 05:42:20 +01:00
}
$ service_status = undef
2013-01-17 10:52:46 +01:00
$ 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
$f irewall_supported = false
# TODO: not exactly sure yet what the right thing to do for Debian/ Ubuntu is .
# $ persist_firewall_command = '/sbin/iptables-save > /etc/iptables/rules.v4'
2013-04-26 17:35:09 +02:00
if $ manage_package_repo = = true {
$ needs_initdb = pick( $ run_initdb, true )
$ service_name = pick( $c ustom_service_name, 'postgresql' )
} else {
$ needs_initdb = pick( $ run_initdb, false )
case $ : : operatingsystem {
'Debian' : {
2013-02-07 14:20:53 +01:00
$ service_name = pick( $c ustom_service_name, 'postgresql' )
2013-02-15 11:23:18 +01:00
}
2013-04-26 17:35:09 +02:00
'Ubuntu' : {
# thanks, ubuntu
if( $ : : lsbmajdistrelease = = '10' ) {
$ service_name = pick( $c ustom_service_name, "postgresql-${version}" )
} else {
$ service_name = pick( $c ustom_service_name, 'postgresql' )
}
}
2012-12-04 05:42:20 +01:00
}
}
2013-02-24 22:06:37 +01:00
$c lient_package_name = pick( $c ustom_client_package_name, "postgresql-client-${version}" )
$ server_package_name = pick( $c ustom_server_package_name, "postgresql-${version}" )
$c ontrib_package_name = pick( $c ustom_contrib_package_name, "postgresql-contrib-${version}" )
$de vel_package_name = pick( $c ustom_devel_package_name, 'libpq-dev' )
$ java_package_name = pick( $c ustom_java_package_name, 'libpostgresql-jdbc-java' )
$b indir = pick( $c ustom_bindir, "/usr/lib/postgresql/${version}/bin" )
$da tadir = pick( $c ustom_datadir, "/var/lib/postgresql/${version}/main" )
$c onfdir = pick( $c ustom_confdir, "/etc/postgresql/${version}/main" )
$ service_status = "/etc/init.d/${service_name} status | /bin/egrep -q 'Running clusters: .+|online'"
2013-04-22 17:30:07 +02:00
$ python_package_name = "python-psycopg2"
2012-06-08 22:37:21 +02:00
}
default : {
fail( "Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} currently only supports osfamily RedHat and Debian" )
}
}
2012-12-04 05:42:20 +01:00
$ initdb_path = "${bindir}/initdb"
$c reatedb_path = "${bindir}/createdb"
$ psql_path = "${bindir}/psql"
$ pg_hba_conf_path = "${confdir}/pg_hba.conf"
$ postgresql_conf_path = "${confdir}/postgresql.conf"
2013-02-07 14:20:53 +01:00
2012-06-08 22:37:21 +02:00
}