fuel-library/deployment/puppet/postgresql/manifests/server/initdb.pp
Matthew Mosesohn e97c8338c9 Rebase postgresql to puppetlabs-postgresql-4.0.0
Rebases to puppetlabs-postgresql commit id:
5d4a543a54df0c9c52a5c7c1f68e5ae51d862947

Older postgresql lacks capability to handle
bindir path changes in postgres 9.0 and newer.

Change-Id: If8265bcdd7144a44b97a9f2e7d72f8a4b263920a
Partial-Bug: #1386118
Related blueprint merge-openstack-puppet-modules
2014-10-27 14:26:40 +00:00

67 lines
2.0 KiB
Puppet

# PRIVATE CLASS: do not call directly
class postgresql::server::initdb {
$needs_initdb = $postgresql::server::needs_initdb
$initdb_path = $postgresql::server::initdb_path
$datadir = $postgresql::server::datadir
$xlogdir = $postgresql::server::xlogdir
$encoding = $postgresql::server::encoding
$locale = $postgresql::server::locale
$group = $postgresql::server::group
$user = $postgresql::server::user
# Make sure the data directory exists, and has the correct permissions.
file { $datadir:
ensure => directory,
owner => $user,
group => $group,
mode => '0700',
}
if($xlogdir) {
# Make sure the xlog directory exists, and has the correct permissions.
file { $xlogdir:
ensure => directory,
owner => $user,
group => $group,
mode => '0700',
}
}
if($needs_initdb) {
# Build up the initdb command.
#
# We optionally add the locale switch if specified. Older versions of the
# initdb command don't accept this switch. So if the user didn't pass the
# parameter, lets not pass the switch at all.
$ic_base = "${initdb_path} --encoding '${encoding}' --pgdata '${datadir}'"
$ic_xlog = $xlogdir ? {
undef => $ic_base,
default => "${ic_base} --xlogdir '${xlogdir}'"
}
# The xlogdir need to be present before initdb runs.
# If xlogdir is default it's created by package installer
if($xlogdir) {
$require_before_initdb = [$datadir, $xlogdir]
} else {
$require_before_initdb = [$datadir]
}
$initdb_command = $locale ? {
undef => $ic_xlog,
default => "${ic_xlog} --locale '${locale}'"
}
# This runs the initdb command, we use the existance of the PG_VERSION
# file to ensure we don't keep running this command.
exec { 'postgresql_initdb':
command => $initdb_command,
creates => "${datadir}/PG_VERSION",
user => $user,
group => $group,
logoutput => on_failure,
require => File[$require_before_initdb],
}
}
}