There's an official postgresql module that can be easily installed:
puppet module install puppetlabs-postgresql
or adding following to your Puppetfile
:
mod 'puppetlabs-postgresql'
The configuration might look like this:
class { 'postgresql::globals':
encoding => 'UTF-8',
locale => 'en_US.UTF-8',
version => '9.6',
}->
class { 'postgresql::server':
ip_mask_deny_postgres_user => '0.0.0.0/32',
ip_mask_allow_all_users => '0.0.0.0/0',
listen_addresses => '*',
version => '9.6',
}
postgresql::server::db { 'testdb':
user => 'test',
password => postgresql_password('test', 'testpassword'),
}
postgresql::server::pg_hba_rule { 'allow connection from ...':
description => "Open up PostgreSQL for access from test domain",
type => 'host',
database => 'testdb',
user => 'test',
address => '.testdomain.com',
auth_method => 'md5',
}