Puppet Class: pg_profile::database::db_init
- Inherits:
- pg_profile
- Defined in:
- manifests/database/db_init.pp
Summary
This class implements the steps to initialize the database for the foirst time.Overview
pg_profile::database::db_init
See the file “LICENSE” for the full license governing this code.
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'manifests/database/db_init.pp', line 22
class pg_profile::database::db_init(
Array[Stdlib::Absolutepath]
$data_dirs,
Array[Stdlib::Absolutepath]
$log_dirs,
Stdlib::Absolutepath
$data_dir,
Stdlib::Absolutepath
$log_dir,
) inherits pg_profile {
echo {'Ensure Postgres initial setup':
withpath => false,
}
easy_type::debug_evaluation() # Show local variable on extended debug
if $facts.dig('os','family') == 'RedHat' and $facts.dig('os','selinux','enabled') == true {
$data_dir_type = 'postgresql_db_t'
$log_dir_type = 'postgresql_log_t'
}
else {
$data_dir_type = undef
$log_dir_type = undef
}
#
# Create all data directories with correct settings
#
$data_dirs.each |$dir| {
unless defined(File[$dir]) {
file{$dir:
ensure => directory,
owner => $pg_profile::os_user,
group => $pg_profile::os_group,
seltype => $data_dir_type,
mode => '0700',
before => Exec['Initialize Postgres Database']
}
}
}
#
# Create all data directories with correct settings
#
$log_dirs.each |$dir| {
unless defined(File[$dir]) {
file{$dir:
ensure => directory,
owner => $pg_profile::os_user,
group => $pg_profile::os_group,
seltype => $log_dir_type,
mode => '0700',
before => Exec['Initialize Postgres Database']
}
}
}
exec { 'Initialize Postgres Database':
command => "/usr/pgsql-${pg_profile::version}/bin/initdb -D ${data_dir} -X ${log_dir}",
creates => "${data_dir}/PG_VERSION",
user => $pg_profile::os_user,
group => $pg_profile::os_group,
logoutput => 'on_failure',
}
pg_register { 'localhost':
os_user => $pg_profile::os_user,
database => 'postgres',
daemonized => false,
default => true,
}
}
|