3
0
Files
confdroid_postgresql/manifests/server/databases/db_df.pp

48 lines
1.8 KiB
Puppet

## postgresql_cd::server::databases::db_df
# Module name: postgresql_cd
# Author: Arne Teuke (arne_teuke@confdroid.com.com)
# @summary define manages databases
# @see https://www.postgresql.org/docs/9.6/static/managing-databases.html
# @param [String] pl_db_name the name of the database to be created.
# @param [String] pl_owner_name the name of the owner for the database
# (optional), if none specified, the postgresql defaults will apply.
# @param [String] pl_db_action whether to create or drop the database.
# 'CREATE DATABASE' creates it, 'DROP DATABASE' drops it.
# @param [String] pl_db_extension
##############################################################################
define postgresql_cd::server::databases::db_df (
Optional[String] $pl_db_name = undef,
Optional[String] $pl_owner_name = undef,
Optional[String] $pl_db_action = undef,
String $pl_db_extension = 'pg_trgm',
) {
$pl_manage_databases = $postgresql_cd::params::pl_manage_databases
if $pl_manage_databases == true {
# create databases
if $pl_db_action == 'CREATE DATABASE' {
exec { "create_database_${name}":
command => template('postgresql_cd/server/databases/db_create_sql.erb'),
user => 'postgres',
path => ['/usr/bin','/bin'],
cwd => '/tmp',
unless => template('postgresql_cd/server/databases/unless_db_sql.erb'),
}
}
# Drop databases
if $pl_db_action == 'DROP DATABASE' {
exec { "drop_database_${name}":
command => template('postgresql_cd/server/databases/db_drop_sql.erb'),
user => 'postgres',
path => ['/usr/bin','/bin'],
cwd => '/tmp',
onlyif => template('postgresql_cd/server/databases/unless_drop_sql.erb'),
}
}
}
}