X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;ds=sidebyside;f=3rdparty%2Fmodules%2Fpostgresql%2Fmanifests%2Ftablespace.pp;fp=3rdparty%2Fmodules%2Fpostgresql%2Fmanifests%2Ftablespace.pp;h=152e0cfbadddb5d3820b4868827136c08271e254;hb=a29c0d1b4d2420aeb3ef6acf66feb00709dd2652;hp=0000000000000000000000000000000000000000;hpb=d98d8ae49a60547132c555f3669f3b9ae6a666bd;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/postgresql/manifests/tablespace.pp b/3rdparty/modules/postgresql/manifests/tablespace.pp new file mode 100644 index 000000000..152e0cfba --- /dev/null +++ b/3rdparty/modules/postgresql/manifests/tablespace.pp @@ -0,0 +1,59 @@ +# Define: postgresql::tablespace +# +# This module creates tablespace +# +# Parameters: +# [*title*] - the name of a tablespace to be created. The name cannot begin with pg_, as such names are reserved for system tablespaces. +# [*owner*] - the name of the user who will own the tablespace. If omitted, defaults to the user executing the command. +# Only superusers can create tablespaces, but they can assign ownership of tablespaces to non-superusers. +# [*location*] - The directory that will be used for the tablespace. The directory should be empty and must be owned by the PostgreSQL +# system user. The directory must be specified by an absolute path name. +# +# Actions: +# +# Requires: +# +# class postgresql::server +# +# Sample Usage: +# +# postgresql::tablespace { 'dbspace': +# location => '/data/dbs', +# } +# +# +define postgresql::tablespace( + $location, + $owner = undef, + $spcname = $title) +{ + include postgresql::params + + Postgresql_psql { + psql_user => $postgresql::params::user, + psql_group => $postgresql::params::group, + psql_path => $postgresql::params::psql_path, + } + + if ($owner == undef) { + $owner_section = '' + } + else { + $owner_section = "OWNER \"${owner}\"" + } + + $create_tablespace_command = "CREATE TABLESPACE \"${spcname}\" ${owner_section} LOCATION '${location}'" + + file { $location: + ensure => directory, + owner => $postgresql::params::user, + group => $postgresql::params::group, + mode => '0700', + } + + postgresql_psql { "Create tablespace '${spcname}'": + command => $create_tablespace_command, + unless => "SELECT spcname FROM pg_tablespace WHERE spcname='${spcname}'", + require => [Class['postgresql::server'], File[$location]], + } +}