From 49ecb872fab4a6fa43622963e3567d5ee70b46ac Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 20 Feb 2013 17:52:41 +0100 Subject: [PATCH 1/2] Add support for the REPLICATION flag when creating roles --- manifests/database_user.pp | 12 +++++++----- manifests/role.pp | 26 ++++++++++++++------------ 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/manifests/database_user.pp b/manifests/database_user.pp index aa71bf9..8620413 100644 --- a/manifests/database_user.pp +++ b/manifests/database_user.pp @@ -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, } } diff --git a/manifests/role.pp b/manifests/role.pp index 37b465a..e868b2b 100644 --- a/manifests/role.pp +++ b/manifests/role.pp @@ -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}'", From e74360c805d08b5864ada8bc40322e97e26406c3 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Mon, 25 Feb 2013 18:46:31 +0000 Subject: [PATCH 2/2] Add documentation for replication flag for postgresql::role Signed-off-by: Ken Barber --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index d89778e..3c1e952 100644 --- a/README.md +++ b/README.md @@ -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: