Merge branch 'replication_support'

* replication_support:
  Add documentation for replication flag for postgresql::role
  Add support for the REPLICATION flag when creating roles
This commit is contained in:
Ken Barber 2013-02-25 18:47:23 +00:00
commit 10992e115d
3 changed files with 24 additions and 17 deletions

View file

@ -343,6 +343,9 @@ Weither to grant login capability for the new role. Defaults to `false`.
####`superuser`
Weither to grant super user capability for the new role. Defaults to `false`.
####`replication`
If `true` provides replication capabilities for this role. Defaults to `false`.
###Resource: postgresql::tablespace
This defined type can be used to create a tablespace. For example:

View file

@ -39,11 +39,12 @@
define postgresql::database_user(
$password_hash,
$createdb = false,
$createrole = false,
$db = $postgresql::params::user,
$superuser = false,
$user = $title
$createdb = false,
$createrole = false,
$db = $postgresql::params::user,
$superuser = false,
$replication = false,
$user = $title
) {
postgresql::role { $user:
db => $db,
@ -52,5 +53,6 @@ define postgresql::database_user(
createdb => $createdb,
superuser => $superuser,
createrole => $createrole,
replication => $replication,
}
}

View file

@ -18,12 +18,13 @@
define postgresql::role(
$password_hash,
$createdb = false,
$createrole = false,
$db = 'postgres',
$login = false,
$superuser = false,
$username = $title
$createdb = false,
$createrole = false,
$db = 'postgres',
$login = false,
$superuser = false,
$replication = false,
$username = $title
) {
include postgresql::params
@ -33,13 +34,14 @@ define postgresql::role(
psql_path => $postgresql::params::psql_path,
}
$login_sql = $login ? { true => 'LOGIN' , default => 'NOLOGIN' }
$createrole_sql = $createrole ? { true => 'CREATEROLE', default => 'NOCREATEROLE' }
$createdb_sql = $createdb ? { true => 'CREATEDB' , default => 'NOCREATEDB' }
$superuser_sql = $superuser ? { true => 'SUPERUSER' , default => 'NOSUPERUSER' }
$login_sql = $login ? { true => 'LOGIN' , default => 'NOLOGIN' }
$createrole_sql = $createrole ? { true => 'CREATEROLE' , default => 'NOCREATEROLE' }
$createdb_sql = $createdb ? { true => 'CREATEDB' , default => 'NOCREATEDB' }
$superuser_sql = $superuser ? { true => 'SUPERUSER' , default => 'NOSUPERUSER' }
$replication_sql = $replication ? { true => 'REPLICATION' , default => '' }
# TODO: FIXME: Will not correct the superuser / createdb / createrole / login status of a role that already exists
postgresql_psql {"CREATE ROLE \"${username}\" ENCRYPTED PASSWORD '${password_hash}' ${login_sql} ${createrole_sql} ${createdb_sql} ${superuser_sql}":
# TODO: FIXME: Will not correct the superuser / createdb / createrole / login / replication status of a role that already exists
postgresql_psql {"CREATE ROLE \"${username}\" ENCRYPTED PASSWORD '${password_hash}' ${login_sql} ${createrole_sql} ${createdb_sql} ${superuser_sql} ${replication_sql}":
db => $db,
psql_user => $postgresql::params::user,
unless => "SELECT rolname FROM pg_roles WHERE rolname='${username}'",