|
1 | 1 | # Class for creating the PuppetDB postgresql database. See README.md for more |
2 | 2 | # information. |
3 | 3 | class puppetdb::database::postgresql( |
4 | | - $listen_addresses = $puppetdb::params::database_host, |
5 | | - $database_name = $puppetdb::params::database_name, |
6 | | - $database_username = $puppetdb::params::database_username, |
7 | | - $database_password = $puppetdb::params::database_password, |
8 | | - $database_port = $puppetdb::params::database_port, |
9 | | - $manage_database = $puppetdb::params::manage_database, |
10 | | - $manage_server = $puppetdb::params::manage_dbserver, |
11 | | - $manage_package_repo = $puppetdb::params::manage_pg_repo, |
12 | | - $postgres_version = $puppetdb::params::postgres_version, |
| 4 | + $listen_addresses = $puppetdb::params::database_host, |
| 5 | + $database_name = $puppetdb::params::database_name, |
| 6 | + $database_username = $puppetdb::params::database_username, |
| 7 | + $database_password = $puppetdb::params::database_password, |
| 8 | + $database_port = $puppetdb::params::database_port, |
| 9 | + $manage_database = $puppetdb::params::manage_database, |
| 10 | + $manage_server = $puppetdb::params::manage_dbserver, |
| 11 | + $manage_package_repo = $puppetdb::params::manage_pg_repo, |
| 12 | + $postgres_version = $puppetdb::params::postgres_version, |
| 13 | + $postgresql_ssl_on = $puppetdb::params::postgresql_ssl_on, |
| 14 | + $postgresql_ssl_key_path = $puppetdb::params::postgresql_ssl_key_path, |
| 15 | + $postgresql_ssl_cert_path = $puppetdb::params::postgresql_ssl_cert_path, |
| 16 | + $postgresql_ssl_ca_cert_path = $puppetdb::params::postgresql_ssl_ca_cert_path |
13 | 17 | ) inherits puppetdb::params { |
14 | 18 |
|
15 | 19 | if $manage_server { |
|
24 | 28 | port => scanf($database_port, '%i')[0], |
25 | 29 | } |
26 | 30 |
|
| 31 | + # configure PostgreSQL communication with Puppet Agent SSL certificates if |
| 32 | + # postgresql_ssl_on is set to true |
| 33 | + if $postgresql_ssl_on { |
| 34 | + file {'postgres private key': |
| 35 | + ensure => present, |
| 36 | + path => "${postgresql::params::datadir}/server.key", |
| 37 | + source => $postgresql_ssl_key_path, |
| 38 | + owner => 'postgres', |
| 39 | + mode => '0600', |
| 40 | + require => Package['postgresql-server'], |
| 41 | + } |
| 42 | + |
| 43 | + concat {'postgres cert bundle': |
| 44 | + ensure => present, |
| 45 | + path => "${postgresql::params::datadir}/server.crt", |
| 46 | + owner => 'postgres', |
| 47 | + require => Package['postgresql-server'], |
| 48 | + } |
| 49 | + |
| 50 | + concat::fragment {'agent cert': |
| 51 | + target => 'postgres cert bundle', |
| 52 | + source => $postgresql_ssl_cert_path, |
| 53 | + order => '1', |
| 54 | + } |
| 55 | + |
| 56 | + concat::fragment {'CA bundle': |
| 57 | + target => 'postgres cert bundle', |
| 58 | + source => $postgresql_ssl_ca_cert_path, |
| 59 | + order => '2', |
| 60 | + } |
| 61 | + |
| 62 | + postgresql::server::config_entry {'ssl': |
| 63 | + ensure => present, |
| 64 | + value => 'on', |
| 65 | + require => [File['postgres private key'], Concat['postgres cert bundle']] |
| 66 | + } |
| 67 | + |
| 68 | + postgresql::server::config_entry {'ssl_key_file': |
| 69 | + ensure => present, |
| 70 | + value => "${postgresql::params::datadir}/server.key", |
| 71 | + require => [File['postgres private key'], Concat['postgres cert bundle']] |
| 72 | + } |
| 73 | + |
| 74 | + postgresql::server::config_entry {'ssl_cert_file': |
| 75 | + ensure => present, |
| 76 | + value => "${postgresql::params::datadir}/server.crt", |
| 77 | + require => [File['postgres private key'], Concat['postgres cert bundle']] |
| 78 | + } |
| 79 | + |
| 80 | + # postgresql::server::config_entry {'ssl_ca_file': |
| 81 | + # ensure => present, |
| 82 | + # value => $postgresql_ssl_ca_cert_path, |
| 83 | + # require => [File['postgres private key'], Concat['postgres cert bundle']] |
| 84 | + # } |
| 85 | + } |
| 86 | + |
27 | 87 | # Only install pg_trgm extension, if database it is actually managed by the module |
28 | 88 | if $manage_database { |
29 | 89 |
|
|
0 commit comments