Skip to content

Commit 10992e1

Browse files
committed
Merge branch 'replication_support'
* replication_support: Add documentation for replication flag for postgresql::role Add support for the REPLICATION flag when creating roles
2 parents 8df74b9 + e74360c commit 10992e1

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ Weither to grant login capability for the new role. Defaults to `false`.
343343
####`superuser`
344344
Weither to grant super user capability for the new role. Defaults to `false`.
345345

346+
####`replication`
347+
If `true` provides replication capabilities for this role. Defaults to `false`.
348+
346349
###Resource: postgresql::tablespace
347350
This defined type can be used to create a tablespace. For example:
348351

manifests/database_user.pp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@
3939

4040
define postgresql::database_user(
4141
$password_hash,
42-
$createdb = false,
43-
$createrole = false,
44-
$db = $postgresql::params::user,
45-
$superuser = false,
46-
$user = $title
42+
$createdb = false,
43+
$createrole = false,
44+
$db = $postgresql::params::user,
45+
$superuser = false,
46+
$replication = false,
47+
$user = $title
4748
) {
4849
postgresql::role { $user:
4950
db => $db,
@@ -52,5 +53,6 @@
5253
createdb => $createdb,
5354
superuser => $superuser,
5455
createrole => $createrole,
56+
replication => $replication,
5557
}
5658
}

manifests/role.pp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818

1919
define postgresql::role(
2020
$password_hash,
21-
$createdb = false,
22-
$createrole = false,
23-
$db = 'postgres',
24-
$login = false,
25-
$superuser = false,
26-
$username = $title
21+
$createdb = false,
22+
$createrole = false,
23+
$db = 'postgres',
24+
$login = false,
25+
$superuser = false,
26+
$replication = false,
27+
$username = $title
2728
) {
2829
include postgresql::params
2930

@@ -33,13 +34,14 @@
3334
psql_path => $postgresql::params::psql_path,
3435
}
3536

36-
$login_sql = $login ? { true => 'LOGIN' , default => 'NOLOGIN' }
37-
$createrole_sql = $createrole ? { true => 'CREATEROLE', default => 'NOCREATEROLE' }
38-
$createdb_sql = $createdb ? { true => 'CREATEDB' , default => 'NOCREATEDB' }
39-
$superuser_sql = $superuser ? { true => 'SUPERUSER' , default => 'NOSUPERUSER' }
37+
$login_sql = $login ? { true => 'LOGIN' , default => 'NOLOGIN' }
38+
$createrole_sql = $createrole ? { true => 'CREATEROLE' , default => 'NOCREATEROLE' }
39+
$createdb_sql = $createdb ? { true => 'CREATEDB' , default => 'NOCREATEDB' }
40+
$superuser_sql = $superuser ? { true => 'SUPERUSER' , default => 'NOSUPERUSER' }
41+
$replication_sql = $replication ? { true => 'REPLICATION' , default => '' }
4042

41-
# TODO: FIXME: Will not correct the superuser / createdb / createrole / login status of a role that already exists
42-
postgresql_psql {"CREATE ROLE \"${username}\" ENCRYPTED PASSWORD '${password_hash}' ${login_sql} ${createrole_sql} ${createdb_sql} ${superuser_sql}":
43+
# TODO: FIXME: Will not correct the superuser / createdb / createrole / login / replication status of a role that already exists
44+
postgresql_psql {"CREATE ROLE \"${username}\" ENCRYPTED PASSWORD '${password_hash}' ${login_sql} ${createrole_sql} ${createdb_sql} ${superuser_sql} ${replication_sql}":
4345
db => $db,
4446
psql_user => $postgresql::params::user,
4547
unless => "SELECT rolname FROM pg_roles WHERE rolname='${username}'",

0 commit comments

Comments
 (0)