2013-08-10 5 views
7

Sto provando ad usare il modulo fantoccio puppetlabs/postgresql. Sono molto confuso su come usarlo. Qualcuno può darmi un esempio? la documentazione dice di creare la classe con le impostazioni ma non sono sicuro di dove creare la classe, ho avuto l'impressione di usare site.pp ma quando creo una classe nel sito.pp. Ho inserito il seguente blocco nel sito.pp dopo aver installato il modulopuppetlabs/postgresql esempi non funzionanti

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', 
    } 

} 

Ottengo un sacco di errori.

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 
+1

Nota: la struttura config_hash {} è stata rimossa ed è vecchia sintassi. Vedi: https://github.com/puppetlabs/puppetlabs-postgresql#config_hash-parameter-collapsed-for-the-postgresqlserver-class – r3cgm

risposta

3

Bare configurazione ossa (dopo aver installato il modulo):

node default { 
    include postgresql::server 

    postgresql::db { 'testdb': 
    user  => 'testdbuser', 
    password => 'testdbuser', 
    } 

} 

puppet parser validate è tuo amico :-)

C'è un post sul blog che Puppet walks through the postgresql module che potrebbe essere utile.

+5

Non è più 'postgresql :: db', ma è stato cambiato in' postgresql :: Server :: db'. – cevaris

5

Nel codice che hai postato, si sia compreso, e dichiarando un utilizzo della classe:

include postgresql::server 
class { 'postgresql::server': 

Non avete bisogno di fare entrambe le cose - come hai intenzione di applicare config al server, Rimuoverei la riga di inclusione.

+0

Questo ha fatto il trucco per me. :) – r3cgm