I am trying to use the puppet module puppetlabs/postgresql. I am very confused as to how to use it. Anyone can give me an example ? the documentation tells to create the class with settings but i am not sure where to create the class, I was under the impression to use site.pp but when i create a class in the site.pp. I put the following block in the site.pp after installing the module
node default {
# This is where you can declare classes for all nodes.
# Example:
# class { 'my_class': }
include postgresql::server
class { 'postgresql::server':
config_hash => {
'ip_mask_deny_postgres_user' => '0.0.0.0/32',
'ip_mask_allow_all_users' => '0.0.0.0/0',
'listen_addresses' => '*',
'ipv4acls' => ['hostssl all johndoe 192.168.0.0/24 cert'],
'manage_redhat_firewall' => true,
'manage_pg_hba_conf' => false,
'postgres_password' => 'TPSrep0rt!',
},
}
postgresql::db { 'testdb':
user => 'testdbuser',
password => 'testdbuser'
}
postgresql::database_grant { 'testdbuser':
privilege => 'ALL',
db => 'testdbuser',
role => 'dbo',
}
}
I get alot of errors.
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: Class[Postgresql::Server] is already declared; cannot redeclare at /etc/puppetlabs/puppet/manifests/site.pp:55 on node caaers
warning: Not using cache on failed catalog
err: Could not retrieve catalog; skipping run
In the code that you posted, you are both including, and declaring a use of the class:
include postgresql::server
class { 'postgresql::server':
You dont need to do both - as you're wanting to apply config to the server, I'd remove the include line.
Bare bones configuration (after you've installed the module):
node default {
include postgresql::server
postgresql::db { 'testdb':
user => 'testdbuser',
password => 'testdbuser',
}
}
puppet parser validate
is your friend :-)
There's a post on the Puppet blog that walks through the postgresql module that might be helpful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With