Skip to content

Commit 5e4045d

Browse files
committed
Merge pull request puppetlabs#158 from harbulot/user_nopassword
Adding the ability to create users without a password.
2 parents 3804c93 + dd05232 commit 5e4045d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

manifests/database_user.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#
3939

4040
define postgresql::database_user(
41-
$password_hash,
41+
$password_hash = false,
4242
$createdb = false,
4343
$createrole = false,
4444
$db = $postgresql::params::user,

manifests/role.pp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# limitations under the License.
1818

1919
define postgresql::role(
20-
$password_hash,
20+
$password_hash = false,
2121
$createdb = false,
2222
$createrole = false,
2323
$db = 'postgres',
@@ -40,9 +40,14 @@
4040
$createdb_sql = $createdb ? { true => 'CREATEDB' , default => 'NOCREATEDB' }
4141
$superuser_sql = $superuser ? { true => 'SUPERUSER' , default => 'NOSUPERUSER' }
4242
$replication_sql = $replication ? { true => 'REPLICATION' , default => '' }
43+
if ($password_hash != false) {
44+
$password_sql = "ENCRYPTED PASSWORD '${password_hash}'"
45+
} else {
46+
$password_sql = ""
47+
}
4348

4449
# TODO: FIXME: Will not correct the superuser / createdb / createrole / login / replication status nor the connection limit of a role that already exists
45-
postgresql_psql {"CREATE ROLE \"${username}\" ENCRYPTED PASSWORD '${password_hash}' ${login_sql} ${createrole_sql} ${createdb_sql} ${superuser_sql} ${replication_sql} CONNECTION LIMIT ${connection_limit}":
50+
postgresql_psql {"CREATE ROLE \"${username}\" ${password_sql} ${login_sql} ${createrole_sql} ${createdb_sql} ${superuser_sql} ${replication_sql} CONNECTION LIMIT ${connection_limit}":
4651
db => $db,
4752
psql_user => $postgresql::params::user,
4853
unless => "SELECT rolname FROM pg_roles WHERE rolname='${username}'",

0 commit comments

Comments
 (0)