Skip to content

Allow to set connection limit for new role #142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ 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`.

####`connection_limit`
Specifies how many concurrent connections the role can make. Defaults to `-1` meaning no limit.

###Resource: postgresql::tablespace
This defined type can be used to create a tablespace. For example:

Expand Down
28 changes: 15 additions & 13 deletions manifests/database_user.pp
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,22 @@

define postgresql::database_user(
$password_hash,
$createdb = false,
$createrole = false,
$db = $postgresql::params::user,
$superuser = false,
$replication = false,
$user = $title
$createdb = false,
$createrole = false,
$db = $postgresql::params::user,
$superuser = false,
$replication = false,
$connection_limit = -1,
$user = $title
) {
postgresql::role { $user:
db => $db,
password_hash => $password_hash,
login => true,
createdb => $createdb,
superuser => $superuser,
createrole => $createrole,
replication => $replication,
db => $db,
password_hash => $password_hash,
login => true,
createdb => $createdb,
superuser => $superuser,
createrole => $createrole,
replication => $replication,
connection_limit => $connection_limit,
}
}
19 changes: 10 additions & 9 deletions manifests/role.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@

define postgresql::role(
$password_hash,
$createdb = false,
$createrole = false,
$db = 'postgres',
$login = false,
$superuser = false,
$replication = false,
$username = $title
$createdb = false,
$createrole = false,
$db = 'postgres',
$login = false,
$superuser = false,
$replication = false,
$connection_limit = -1,
$username = $title
) {
include postgresql::params

Expand All @@ -40,8 +41,8 @@
$superuser_sql = $superuser ? { true => 'SUPERUSER' , default => 'NOSUPERUSER' }
$replication_sql = $replication ? { true => 'REPLICATION' , default => '' }

# 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}":
# TODO: FIXME: Will not correct the superuser / createdb / createrole / login / replication status nor the connection limit 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} CONNECTION LIMIT ${connection_limit}":
db => $db,
psql_user => $postgresql::params::user,
unless => "SELECT rolname FROM pg_roles WHERE rolname='${username}'",
Expand Down