- add consul support - enable local script checks in consul agents - add a test DB/User for consult to verify the psql instance is running - manage the postgresql repo and gpg key
54 lines
1.9 KiB
Puppet
54 lines
1.9 KiB
Puppet
# configure the puppetdb sql service
|
|
class profiles::puppet::puppetdb_sql (
|
|
String $puppetdb_host = lookup('profiles::puppet::puppetdb::puppetdb_host'),
|
|
String $listen_address = $facts['networking']['ip'],
|
|
String $consul_test_db_pass = '',
|
|
) {
|
|
|
|
# disable the postgresql dnf module for el8+
|
|
if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] >= '8' {
|
|
# based on https://github.com/puppetlabs/puppetlabs-postgresql/blob/main/manifests/dnfmodule.pp
|
|
package { 'postgresql dnf module':
|
|
ensure => 'disabled',
|
|
name => 'postgresql',
|
|
provider => 'dnfmodule',
|
|
before => Class['puppetdb::database::postgresql'],
|
|
}
|
|
}
|
|
|
|
# Install and configure PostgreSQL for PuppetDB
|
|
class { 'puppetdb::database::postgresql':
|
|
listen_addresses => $listen_address,
|
|
postgres_version => '15',
|
|
puppetdb_server => $puppetdb_host,
|
|
manage_package_repo => false,
|
|
require => [ Yumrepo['postgresql-15'],Yumrepo['postgresql-common'] ],
|
|
}
|
|
|
|
contain ::puppetdb::database::postgresql
|
|
|
|
# create the postgresql::server::config_entry resources
|
|
$pg_config_entries = lookup('postgresql_config_entries', Hash[String, Data], 'hash', {})
|
|
$pg_config_entries.each |String $key, Data $value| {
|
|
postgresql::server::config_entry { $key:
|
|
ensure => 'present',
|
|
value => $value,
|
|
}
|
|
}
|
|
|
|
# create consul database + user to test the host is responsive
|
|
postgresql::server::db { 'consul_test_db':
|
|
user => 'consul_test_user',
|
|
password => postgresql::postgresql_password('consul_test_user', Sensitive($consul_test_db_pass) ),
|
|
}
|
|
|
|
file { '/usr/local/bin/check_consul_postgresql':
|
|
ensure => 'file',
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => '0755',
|
|
content => template('profiles/puppetdb/check_consul_postgresql.erb'),
|
|
before => Class['profiles::consul::client'],
|
|
}
|
|
}
|