我正在尝试使用puppet模块puppetlabs / postgresql。我很困惑如何使用它。有谁可以举个例子?文档告诉创建具有设置的类但我不知道在哪里创建类,我的印象是使用site.pp但是当我在site.pp中创建一个类时。安装模块后,我将以下块放在site.pp中
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',
}
}
我收到很多错误。
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
答案 0 :(得分:5)
在您发布的代码中,您既包括并声明使用该类:
include postgresql::server
class { 'postgresql::server':
您不需要同时执行这两项操作 - 因为您希望将配置应用于服务器,我删除了包含行。
答案 1 :(得分:3)
裸骨配置(安装模块后):
node default {
include postgresql::server
postgresql::db { 'testdb':
user => 'testdbuser',
password => 'testdbuser',
}
}
puppet parser validate
是你的朋友: - )
Puppet博客上有一篇帖子walks through the postgresql module可能会有所帮助。