1 # Define: postgresql::tablespace
3 # This module creates tablespace
6 # [*title*] - the name of a tablespace to be created. The name cannot begin with pg_, as such names are reserved for system tablespaces.
7 # [*owner*] - the name of the user who will own the tablespace. If omitted, defaults to the user executing the command.
8 # Only superusers can create tablespaces, but they can assign ownership of tablespaces to non-superusers.
9 # [*location*] - The directory that will be used for the tablespace. The directory should be empty and must be owned by the PostgreSQL
10 # system user. The directory must be specified by an absolute path name.
16 # class postgresql::server
20 # postgresql::tablespace { 'dbspace':
21 # location => '/data/dbs',
25 define postgresql::tablespace(
30 include postgresql::params
33 psql_user => $postgresql::params::user,
34 psql_group => $postgresql::params::group,
35 psql_path => $postgresql::params::psql_path,
38 if ($owner == undef) {
42 $owner_section = "OWNER \"${owner}\""
45 $create_tablespace_command = "CREATE TABLESPACE \"${spcname}\" ${owner_section} LOCATION '${location}'"
49 owner => $postgresql::params::user,
50 group => $postgresql::params::group,
54 postgresql_psql { "Create tablespace '${spcname}'":
55 command => $create_tablespace_command,
56 unless => "SELECT spcname FROM pg_tablespace WHERE spcname='${spcname}'",
57 require => [Class['postgresql::server'], File[$location]],