## confdroid_postgresql::server::databases::db_df # Module name: confdroid_postgresql # Author: 12ww1160 (12ww1160@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 confdroid_postgresql::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_content = $confdroid_postgresql::params::pl_manage_content if $pl_manage_content == true { # create databases if $pl_db_action == 'CREATE DATABASE' { exec { "create_database_${name}": command => template('confdroid_postgresql/server/databases/db_create_sql.erb'), user => 'postgres', path => ['/usr/bin','/bin'], cwd => '/tmp', unless => template('confdroid_postgresql/server/databases/unless_db_sql.erb'), } } # Drop databases if $pl_db_action == 'DROP DATABASE' { exec { "drop_database_${name}": command => template('confdroid_postgresql/server/databases/db_drop_sql.erb'), user => 'postgres', path => ['/usr/bin','/bin'], cwd => '/tmp', onlyif => template('confdroid_postgresql/server/databases/unless_drop_sql.erb'), } } } }