4
5
6
7
8
9
10
11
12
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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'manifests/component/postgres.pp', line 4
class complyadm::component::postgres (
Complyadm::Config::Comply_postgres $config
) {
$container = $config['container']
$init_script = '/etc/puppetlabs/comply/initdb.sql'
file { $init_script:
ensure => 'file',
content => epp('complyadm/postgres/initdb.sql.epp',
{
'comply_db_username' => $config['comply_db_username'],
'comply_db_password' => $config['comply_db_password'],
'identity_db_username' => $config['identity_db_username'],
'identity_db_password' => $config['identity_db_password'],
}
),
owner => 'root',
group => 'root',
seltype => 'container_file_t',
}
$conf_file = '/etc/puppetlabs/comply/postgresql.conf'
file { $conf_file:
ensure => 'file',
content => epp('complyadm/postgres/postgresql.conf.epp', { log_level => $config['log_level'] }),
owner => 'root',
group => 'root',
seltype => 'container_file_t',
notify => Complyadm::Runtime::Run[$container['name']],
}
$hba_file = '/etc/puppetlabs/comply/pg_hba.conf'
file { $hba_file:
ensure => 'file',
source => 'puppet:///modules/complyadm/postgres/pg_hba.conf',
owner => 'root',
group => 'root',
seltype => 'container_file_t',
notify => Complyadm::Runtime::Run[$container['name']],
}
complyadm::runtime::volume { 'postgres':
ensure => 'present',
runtime => $container['runtime'],
}
$postgres_env = '/etc/puppetlabs/comply/postgres.env'
file { $postgres_env:
ensure => file,
owner => 'root',
group => 'root',
seltype => 'container_file_t',
show_diff => false,
content => epp('complyadm/comply_env.epp', {
env_vars => $container['env_vars'],
}),
notify => Complyadm::Runtime::Run[$container['name']],
}
$healthcheck_file = "/etc/puppetlabs/comply/${container['name']}-healthcheck.sh"
file { $healthcheck_file:
ensure => file,
owner => 'root',
group => 'root',
mode => '+x',
seltype => 'container_file_t',
show_diff => false,
content => epp('complyadm/runtime/service-watchdog.epp', { healthcheck => "${container['runtime']} exec ${container['name']} ${container['healthcheck']}" }),
notify => Complyadm::Runtime::Run[$container['name']],
}
$postgres_dir = '/bitnami/postgresql'
$pgconf = "${postgres_dir}/conf"
$pgdata = "${postgres_dir}/data"
complyadm::runtime::run { $container['name']:
runtime => $container['runtime'],
install_runtime => $container['install_runtime'],
image => $container['image'],
net => $container['net'],
ports => $container['ports'],
volumes => [
"postgres:${postgres_dir}",
"${init_script}:/docker-entrypoint-initdb.d/initdb.sql",
"${conf_file}:${pgconf}/postgresql.conf",
"${hba_file}:${pgconf}/pg_hba.conf",
],
pull_on_start => false,
env_file => [$postgres_env],
require => [
File[$init_script],
File[$conf_file],
File[$postgres_env],
File[$hba_file],
],
extra_parameters => "--platform=linux/amd64 ${container['extra_parameters']}",
before_start => "/usr/bin/${container['runtime']} exec ${container['name']} pg_ctl stop --mode=fast --pgdata=${pgdata}",
after_create => $healthcheck_file,
extra_systemd_parameters => $container['extra_systemd_parameters'],
before_stop => "/usr/bin/${container['runtime']} exec ${container['name']} pg_ctl stop --mode=fast --pgdata=${pgdata}",
}
}
|