Skip to content

Commit 95922a8

Browse files
mooreandrewsmortex
authored andcommitted
Role Valid Until Date
This allows for the valid until attribute to be set on roles.
1 parent b996aef commit 95922a8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

manifests/server/role.pp

+7
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
Boolean $inherit = true,
3636
Boolean $superuser = false,
3737
Boolean $replication = false,
38+
Optional[String[1]] $valid_until = undef,
3839
String[1] $connection_limit = '-1',
3940
String[1] $username = $title,
4041
Hash $connect_settings = $postgresql::server::default_connect_settings,
@@ -126,6 +127,12 @@
126127
unless => "SELECT 1 FROM pg_roles WHERE rolname = '${username}' AND rolinherit = ${inherit}",
127128
}
128129

130+
if $valid_until {
131+
postgresql_psql { "ALTER ROLE \"${username}\" VALID UNTIL '${valid_until}'":
132+
unless => "SELECT 1 FROM pg_roles WHERE rolname = '${username}' AND rolvaliduntil = '${valid_until}'",
133+
}
134+
}
135+
129136
if(versioncmp($version, '9.1') >= 0) {
130137
if $replication_sql == '' {
131138
postgresql_psql { "ALTER ROLE \"${username}\" NOREPLICATION":

0 commit comments

Comments
 (0)