Puppet Class: pg_profile::database::db_definition

Inherits:
pg_profile
Defined in:
manifests/database/db_definition.pp

Summary

This class contains the actual database definition using the `pg_database` type.

Overview

--

pg_profile::database::db_definition

Here you add additiona databases to your system.

When these customizations aren’t enough, you can replace the class with your own class. See [pg_profile::database](./database.html) for an explanation on how to do this.

–++–

Parameters:

  • list (Hash)

    A list of database profiles to define. The default value is: ‘{}` This is a simple way to get started. It is easy to get started, but soon your hiera yaml become a nigtmare. Our advise is when you need to let puppet manage your database, to override this class and add your own puppet implementation. This is much better maintainable and adds more consistency.



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/database/db_definition.pp', line 16

class pg_profile::database::db_definition(
  Hash $list,
) inherits pg_profile {

  easy_type::debug_evaluation() # Show local variable on extended debug

  if $list.keys.size > 0 {
    echo {"Ensure Postgres database(s) ${list.keys.join(',')}":
      withpath => false,
    }
  }
  #
  # This is a simple way to get started. It is easy to get started, but
  # soon your hiera yaml becomes a nigtmare. Our advise is when you need
  # to let Puppet manage your Postgres resources, to override this class and 
  # add your own Puppet implementation. This is a much better, more
  # maintainable, and adds more consistency.
  #
  ensure_resources(pg_database, $list)
  #
  # To be able to manage the contents with the pg_config types, we need to regeister it.
  #
  $list.keys.each |$full_name| {
    $db_name = split($full_name, '@')[0]
    pg_register { $db_name:
      os_user    => $pg_profile::os_user,
      daemonized => false,
      database   => $db_name,
      default    => 'false',
    }
  }
}