|
1 | 1 | $password = 'sensu' |
2 | 2 |
|
| 3 | +class { 'sensu': |
| 4 | + use_ssl => true, |
| 5 | + ssl_ca_source => '/etc/puppetlabs/puppet/ssl/ca/ca_crt.pem', |
| 6 | + api_host => 'sensu-backend', |
| 7 | +} |
| 8 | + |
3 | 9 | class { 'sensu::agent': |
4 | | - backends => ['sensu-backend:8081'], |
| 10 | + backends => ['sensu-backend:8081'], |
| 11 | + config_hash => { |
| 12 | + 'keepalive-interval' => 5, |
| 13 | + }, |
5 | 14 | } |
6 | 15 |
|
7 | 16 | class { 'postgresql::globals': |
8 | | - manage_package_repo => true, |
9 | | - version => '11', |
| 17 | + manage_package_repo => false, |
| 18 | +} |
| 19 | + |
| 20 | +# Ensure data directory is ready for initdb |
| 21 | +exec { 'clean_postgres_datadir_if_incomplete': |
| 22 | + command => '/bin/rm -rf /var/lib/pgsql/data/*', |
| 23 | + onlyif => '/bin/bash -c "[ -d /var/lib/pgsql/data ] && [ ! -f /var/lib/pgsql/data/PG_VERSION ]"', |
| 24 | + require => Class['postgresql::server::install'], |
| 25 | + before => Class['postgresql::server::initdb'], |
10 | 26 | } |
11 | 27 |
|
12 | 28 | class { 'postgresql::server': |
13 | 29 | listen_addresses => '*', |
14 | 30 | } |
15 | 31 |
|
| 32 | +# Copy SSL key for PostgreSQL to use with the default name |
| 33 | +# Must be created AFTER initdb but BEFORE service starts |
16 | 34 | file { 'postgresql_ssl_key_file': |
17 | | - ensure => 'file', |
18 | | - path => "${postgresql::server::datadir}/${trusted['certname']}.pem", |
19 | | - source => "/etc/puppetlabs/puppet/ssl/private_keys/${trusted['certname']}.pem", |
20 | | - owner => 'postgres', |
21 | | - group => 'postgres', |
22 | | - mode => '0600', |
23 | | -} |
24 | | - |
25 | | -postgresql::server::db { 'sensu': |
26 | | - user => 'sensu', |
27 | | - password => postgresql::postgresql_password('sensu', $password), |
28 | | -} |
29 | | - |
30 | | -postgresql::server::pg_hba_rule { 'allow access to sensu database': |
31 | | - description => 'Open up postgresql for access to sensu from 0.0.0.0/0', |
32 | | - type => 'host', |
33 | | - database => 'sensu', |
34 | | - user => 'sensu', |
35 | | - address => '0.0.0.0/0', |
36 | | - auth_method => 'password', |
| 35 | + ensure => 'file', |
| 36 | + path => "${postgresql::server::datadir}/server.key", |
| 37 | + source => '/etc/puppetlabs/puppet/ssl/private_keys/sensu-agent_key.pem', |
| 38 | + owner => 'postgres', |
| 39 | + group => 'postgres', |
| 40 | + mode => '0600', |
| 41 | + require => Class['postgresql::server::initdb'], |
| 42 | + before => Class['postgresql::server::service'], |
37 | 43 | } |
38 | 44 |
|
39 | 45 | postgresql::server::config_entry { 'ssl': |
40 | 46 | value => 'on', |
41 | 47 | } |
42 | 48 |
|
43 | 49 | postgresql::server::config_entry { 'ssl_cert_file': |
44 | | - value => "/etc/puppetlabs/puppet/ssl/certs/${trusted['certname']}.pem", |
| 50 | + value => '/etc/puppetlabs/puppet/ssl/ca/signed/sensu-agent.pem', |
45 | 51 | } |
46 | 52 |
|
47 | 53 | postgresql::server::config_entry { 'ssl_key_file': |
48 | | - value => "${trusted['certname']}.pem", |
| 54 | + value => 'server.key', |
49 | 55 | require => File['postgresql_ssl_key_file'], |
50 | 56 | } |
51 | 57 |
|
52 | 58 | postgresql::server::config_entry { 'ssl_ca_file': |
53 | | - value => '/etc/puppetlabs/puppet/ssl/certs/ca.pem', |
| 59 | + value => '/etc/puppetlabs/puppet/ssl/ca/ca_crt.pem', |
| 60 | +} |
| 61 | + |
| 62 | +postgresql::server::db { 'sensu': |
| 63 | + user => 'sensu', |
| 64 | + password => postgresql::postgresql_password('sensu', $password), |
54 | 65 | } |
55 | 66 |
|
56 | | -postgresql::server::config_entry { 'ssl_crl_file': |
57 | | - value => '/etc/puppetlabs/puppet/ssl/crl.pem', |
| 67 | +postgresql::server::pg_hba_rule { 'allow access to sensu database': |
| 68 | + description => 'Open up postgresql for access to sensu from 0.0.0.0/0', |
| 69 | + type => 'host', |
| 70 | + database => 'sensu', |
| 71 | + user => 'sensu', |
| 72 | + address => '0.0.0.0/0', |
| 73 | + auth_method => 'password', |
58 | 74 | } |
0 commit comments