e97c8338c9
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
40 lines
1.1 KiB
Puppet
40 lines
1.1 KiB
Puppet
# This defined types creates database schemas. See README.md for more details.
|
|
define postgresql::server::schema(
|
|
$db,
|
|
$owner = undef,
|
|
$schema = $title,
|
|
) {
|
|
$user = $postgresql::server::user
|
|
$group = $postgresql::server::group
|
|
$port = $postgresql::server::port
|
|
$psql_path = $postgresql::server::psql_path
|
|
$version = $postgresql::server::_version
|
|
|
|
Postgresql_psql {
|
|
db => $db,
|
|
psql_user => $user,
|
|
psql_group => $group,
|
|
psql_path => $psql_path,
|
|
port => $port,
|
|
}
|
|
|
|
$schema_title = "Create Schema '${schema}'"
|
|
$authorization = $owner? {
|
|
undef => '',
|
|
default => "AUTHORIZATION \"${owner}\"",
|
|
}
|
|
|
|
$schema_command = "CREATE SCHEMA \"${schema}\" ${authorization}"
|
|
$unless = "SELECT nspname FROM pg_namespace WHERE nspname='${schema}'"
|
|
|
|
postgresql_psql { $schema_title:
|
|
command => $schema_command,
|
|
unless => $unless,
|
|
require => Class['postgresql::server'],
|
|
}
|
|
|
|
if($owner != undef and defined(Postgresql::Server::Role[$owner])) {
|
|
Postgresql::Server::Role[$owner]->Postgresql_psql[$schema_title]
|
|
}
|
|
}
|