Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

puppetlabs/postgresql examples not working

Tags:

puppet

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
like image 493
Abu Hamdan Avatar asked Aug 10 '13 03:08

Abu Hamdan


2 Answers

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.

like image 58
Miles Wilson Avatar answered Nov 15 '22 10:11

Miles Wilson


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.

like image 40
steveax Avatar answered Nov 15 '22 09:11

steveax