# Defined Type: confdroid_postgresql::server::databases::db_df

Defined in:
  manifests/server/databases/db_df.pp

## Summary

define manages databases

## Overview

confdroid_postgresql::server::databases::db_df Module name: confdroid_postgresql Author: 12ww1160 (12ww1160@confdroid.com.com)

Parameters:

- pl_db_name (`Optional[String]`) (defaults to: `undef`) —

  the name of the database to be created.

- pl_owner_name (`Optional[String]`) (defaults to: `undef`) —

  the name of the owner for the database (optional), if none specified, the postgresql defaults will apply.

- pl_db_action (`Optional[String]`) (defaults to: `undef`) —

  whether to create or drop the database. ‘CREATE DATABASE’ creates it, ‘DROP DATABASE’ drops it.

- pl_db_extension (`String`) (defaults to: `'pg_trgm'`)

See Also:

- https://www.postgresql.org/docs/9.6/static/managing-databases.html

    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47

    # File 'manifests/server/databases/db_df.pp', line 13

    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'),
          }
        }
      }
    }