dev/modules/sysconfig/manifests/postgresql.pp
author ymh <ymh.work@gmail.com>
Tue, 04 Mar 2014 13:28:35 +0100
changeset 590 e103299bccc0
parent 587 a1aa29e7809f
permissions -rw-r--r--
make django tests working again
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
class sysconfig::postgresql (
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
    $db_host    = hiera('sysconfig::params::db_host', $sysconfig::params::db_host),
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
    $db_port    = hiera('sysconfig::params::db_port', $sysconfig::params::db_port),
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
    $db_name    = hiera('sysconfig::params::db_name', $sysconfig::params::db_name),
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
    $db_user    = hiera('sysconfig::params::db_user', $sysconfig::params::db_user),
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
    $db_pw      = hiera('sysconfig::params::db_pw', $sysconfig::params::db_pw),
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
) inherits sysconfig::params {
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
    notify {'postgresql': name => "\$db_host : ${db_host}, \$db_port : ${db_port}, \$db_name : ${db_name}, \$db_user : ${db_user}, \$db_pw : ${db_pw}", withpath => true }
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
    if $sysconfig::params::db_is_local {
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
        class { 'postgresql::server': }
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
590
e103299bccc0 make django tests working again
ymh <ymh.work@gmail.com>
parents: 587
diff changeset
    15
        postgresql::server::role {"${db_user}_createdb":
e103299bccc0 make django tests working again
ymh <ymh.work@gmail.com>
parents: 587
diff changeset
    16
            username      => $db_user,
e103299bccc0 make django tests working again
ymh <ymh.work@gmail.com>
parents: 587
diff changeset
    17
            createdb      => true,
e103299bccc0 make django tests working again
ymh <ymh.work@gmail.com>
parents: 587
diff changeset
    18
            password_hash => postgresql_password($db_user, $db_pw)
e103299bccc0 make django tests working again
ymh <ymh.work@gmail.com>
parents: 587
diff changeset
    19
        }->
e103299bccc0 make django tests working again
ymh <ymh.work@gmail.com>
parents: 587
diff changeset
    20
        postgresql::server::database { $db_name:
e103299bccc0 make django tests working again
ymh <ymh.work@gmail.com>
parents: 587
diff changeset
    21
            owner    => $db_user,            
587
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
            encoding => 'UTF8',
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
        }
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
    }
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
    else {
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
        class { 'postgresql::client': }->
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
        postgresql::validate_db_connection { 'validate_postgres_connection':
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
            database_host           => $db_host,
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
            database_port           => $db_port,
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
            database_username       => $db_user,
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
            database_password       => $db_pw,
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
            database_name           => $db_name,
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
        }
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
    }
a1aa29e7809f add a vagrant profile + puppet config for dev box
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
}