Cookbooks
postgresql
documentation
Postgresql Role

postgresql_role

Back to resource list

Uses

Provides

  • :postgresql_role

Actions

  • :create
  • :update
  • :drop
  • :delete
  • :set_password

Properties

NameName?TypeDefaultDescriptionAllowed Values
sensitivetrue, false
rolenameStringThe name of the new role
superusertrue, falseDetermine whether the new role is a "superuser" who can override all access restrictions within the database
createdbtrue, falseDefine a role's ability to create databases
createroletrue, falseDetermine whether a role will be permitted to create new roles (that is, execute CREATE ROLE)
inherittrue, falseDetermine whether a role "inherits" the privileges of roles it is a member of
logintrue, falseDetermine whether a role is allowed to log in
replicationtrue, falseDetermine whether a role is a replication role
bypassrlstrue, falseDetermine whether a role bypasses every row-level security (RLS) policy
connection_limitInteger, StringIf role can log in, this specifies how many concurrent connections the role can make
unencrypted_passwordStringSets the role password via a plain text string
encrypted_passwordStringSets the role password via a pre-encrypted string
valid_untilStringSets a date and time after which the role password is no longer valid
in_roleString, ArrayLists one or more existing roles to which the new role will be immediately added as a new membe
roleString, ArrayLists one or more existing roles which are automatically added as members of the new role
adminString, ArrayLike ROLE, but the named roles are added to the new role WITH ADMIN OPTION, giving them the right to grant membership in this role to others
configHashRole config values as a Hash

Libraries

  • PostgreSQL::Cookbook::SqlHelpers::Role

Examples

Create a user user1 with a password, with createdb and set an expiration date to 2018, Dec 21.

postgresql_role 'user1' do
  unencrypted_password 'UserP4ssword'
  createdb true
  valid_until '2018-12-31'
end

Create a user user1 with a password, with createdb and set an expiration date to 2018, Dec 21.

postgresql_role 'user1' do
  unencrypted_password 'UserP4ssword'
  createdb true
  valid_until '2018-12-31'
end