6a29636155
Adds connection-settings (for remote DB support) when creating DB resources. Connection-settings allows a hash of options that can be used when connecting the a remote DB (such as PGHOST, PGPORT, PGPASSWORD PGSSLKEY) and a special option DBVERSION indicating the version of the remote database. Including - Puppet updates - Documentation updates - RSpec unit test updates - RSpec acceptance test updates - Some test coverage for connection-settings - Working acceptance test... Basic vagrant setup: * Two boxes, server and client * Runs puppet code to on server to setup a postgres server that allows all connections and md5 connections, creates db puppet to look at * Runs puppet code on client to make a server that a psql command can be run against puppet db on other server * Does some fancy stuff to get the fact of the IP from the first server to connect to - Backwards compatible, with deprecation warnings around old parameters
60 lines
1.6 KiB
Puppet
60 lines
1.6 KiB
Puppet
# = Type: postgresql::server::schema
|
|
#
|
|
# Create a new schema. See README.md for more details.
|
|
#
|
|
# == Requires:
|
|
#
|
|
# The database must exist and the PostgreSQL user should have enough privileges
|
|
#
|
|
# == Sample Usage:
|
|
#
|
|
# postgresql::server::schema {'private':
|
|
# db => 'template1',
|
|
# }
|
|
#
|
|
define postgresql::server::schema(
|
|
$db = $postgresql::server::default_database,
|
|
$owner = undef,
|
|
$schema = $title,
|
|
$connect_settings = $postgresql::server::default_connect_settings,
|
|
) {
|
|
$user = $postgresql::server::user
|
|
$group = $postgresql::server::group
|
|
$psql_path = $postgresql::server::psql_path
|
|
$version = $postgresql::server::_version
|
|
|
|
# If the connection settings do not contain a port, then use the local server port
|
|
if $connect_settings != undef and has_key( $connect_settings, 'PGPORT') {
|
|
$port = undef
|
|
} else {
|
|
$port = $postgresql::server::port
|
|
}
|
|
|
|
Postgresql_psql {
|
|
db => $db,
|
|
psql_user => $user,
|
|
psql_group => $group,
|
|
psql_path => $psql_path,
|
|
port => $port,
|
|
connect_settings => $connect_settings,
|
|
}
|
|
|
|
$schema_title = "Create Schema '${title}'"
|
|
$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]
|
|
}
|
|
}
|