File: database_grant.pp

package info (click to toggle)
puppet-module-puppetlabs-postgresql 10.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 940 kB
  • sloc: ruby: 731; sh: 66; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 2,177 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# @summary Manage a database grant.
#
# @param privilege Specifies comma-separated list of privileges to grant. Valid options: 'ALL', 'CREATE', 'CONNECT', 'TEMPORARY', 'TEMP'.
# @param db Specifies the database to which you are granting access.
# @param role Specifies the role or user whom you are granting access to.
# @param ensure Specifies whether to grant or revoke the privilege. Revoke or 'absent' works only in PostgreSQL version 9.1.24 or later.
# @param psql_db Defines the database to execute the grant against. This should not ordinarily be changed from the default
# @param psql_user Specifies the OS user for running psql. Default value: The default user for the module, usually 'postgres'.
# @param psql_group Overrides the default postgres user group to be used for related files in the file system.
# @param connect_settings Specifies a hash of environment variables used when connecting to a remote server.
# @param port Port to use when connecting.
# @param instance The name of the Postgresql database instance.
define postgresql::server::database_grant (
  Enum['ALL', 'CREATE', 'CONNECT', 'TEMPORARY', 'TEMP', 'all', 'create', 'connect', 'temporary', 'temp'] $privilege,
  String[1]                           $db,
  String[1]                           $role,
  Optional[Enum['present', 'absent']] $ensure           = undef,
  Optional[String[1]]                 $psql_db          = undef,
  String[1]                           $psql_user        = $postgresql::server::user,
  Hash $connect_settings = $postgresql::server::default_connect_settings,
  String[1] $psql_group = $postgresql::server::group,
  Stdlib::Port $port = $postgresql::server::port,
  String[1] $instance = 'main',
) {
  postgresql::server::grant { "database:${name}":
    ensure           => $ensure,
    role             => $role,
    db               => $db,
    privilege        => $privilege,
    object_type      => 'DATABASE',
    object_name      => $db,
    psql_db          => $psql_db,
    psql_user        => $psql_user,
    group            => $psql_group,
    port             => $port,
    connect_settings => $connect_settings,
    instance         => $instance,
  }
}