1 # This module creates tablespace. See README.md for more details.
2 define postgresql::server::tablespace(
6 $connect_settings = $postgresql::server::default_connect_settings,
8 $user = $postgresql::server::user
9 $group = $postgresql::server::group
10 $psql_path = $postgresql::server::psql_path
11 $module_workdir = $postgresql::server::module_workdir
13 # If the connection settings do not contain a port, then use the local server port
14 if $connect_settings != undef and has_key( $connect_settings, 'PGPORT') {
17 $port = $postgresql::server::port
23 psql_path => $psql_path,
25 connect_settings => $connect_settings,
26 cwd => $module_workdir,
34 seluser => 'system_u',
35 selrole => 'object_r',
36 seltype => 'postgresql_db_t',
37 require => Class['postgresql::server'],
40 postgresql_psql { "CREATE TABLESPACE \"${spcname}\"":
41 command => "CREATE TABLESPACE \"${spcname}\" LOCATION '${location}'",
42 unless => "SELECT 1 FROM pg_tablespace WHERE spcname = '${spcname}'",
43 require => [Class['postgresql::server'], File[$location]],
47 postgresql_psql { "ALTER TABLESPACE \"${spcname}\" OWNER TO \"${owner}\"":
48 unless => "SELECT 1 FROM pg_tablespace JOIN pg_roles rol ON spcowner = rol.oid WHERE spcname = '${spcname}' AND rolname = '${owner}'",
49 require => Postgresql_psql["CREATE TABLESPACE \"${spcname}\""],
52 if defined(Postgresql::Server::Role[$owner]) {
53 Postgresql::Server::Role[$owner]->Postgresql_psql["ALTER TABLESPACE \"${spcname}\" OWNER TO \"${owner}\""]