Cookbooks
postgresql
documentation
Postgresql Access

postgresql_access

Back to resource list

This resource uses the initialised accumulator pattern to manage the pg_hba.conf file. It fully supports load_current_value and will report changes during the run and fire notifications. The content of pg_hba.conf is loaded into the template variables upon the first call of the :postgresql_access resource, so, to remove an entry from the file the resource must be called with the :delete action.

Uses

Actions

  • :create - Create an access entry
  • :update - Update a pre-existing access entry
  • :delete - Remove an access entry
  • :grant - Alias of :create

Properties

NameName?TypeDefaultDescriptionAllowed Values
config_fileString
sourceString
typeStringAccess record type
databaseStringAccess record database
userStringAccess record user
addressStringAccess record address
auth_methodStringAccess record authentication method
auth_optionsString, HashAccess record authentication options
commentStringAccess record comment

Libraries

  • PostgreSQL::Cookbook::AccessHelpers::PgHbaTemplate

Examples

To grant access to the PostgreSQL user with ident authentication:

postgresql_access `local_postgres_superuser` do
  comment `Local postgres superuser access`
  type `local`
  database `all`
  user `postgres`
  auth_method `ident`
end

This generates the following line in the pg_hba.conf:

# Local postgres superuser access
local   all             postgres                                ident           # Local postgres superuser access