我正在尝试安装PuppetDB模块 。 其中的一部分捆绑了一个模块,用于安装我正在使用的一些必需的Postgres实例。
我们主要使用heira来configurationangular色并设置各种属性。
如果我添加,我的configuration足够长
roles: - role::postgresql_puppetdb
到主机名hiera yaml文件,它会被拿起,并得到一个基本的postgres实例推出。
我坚持要获取特定的postgresql.confvariables集。 例如,我试过了
roles: - role::postgresql_puppetdb - wal_level: hot_standby
然而,这被推到后续的代理运行。
我希望有人可能会尝试通过这种方式来模拟PuppetDBconfiguration,并指出我做错了什么。
对于Puppet来查找Hiera中的类参数(自3.0.0起,默认情况下),这些参数需要被指定为简单的键值对,而不是复杂的数据types。
这就是在puppetlabs-postgresql模块中指定postgresql::server类的datadir参数以指向Postgres的备用数据目录的方法:
#/etc/puppet/hieradata/foo.example.com.yaml --- 当应用类postgresql :: server时,Puppet会自动查找这里的参数 postgresql :: server :: datadir:/ srv / postgres / main
不过,我不认为这是你的情况。 你想指定Postgresconfiguration参数,你需要使用postgresql::server::config_entry定义的types。 目前没有办法在Hiera中查找types参数,只能用于类参数。
因此,要么你参数化你的role::postgresql_puppetdb类,所以你可以传递类参数给它,反过来得到馈送到postgresql::server::config_entry声明,或者使用create_resources()函数与hiera_array()或hiera_hash()查找要应用的Postgresconfiguration设置。
第一种方法的例子是:
类angular色:: postgresql_puppetdb(
wal_level =>'minimal'
...
){
class {'postgresql':
...
}
class {'puppetdb':
...
}
postgresql :: server :: config_entry {'wal_level':
值=> $angular色:: postgresql_puppetdb :: wal_level
}
}
然后在Hiera。
#/etc/puppet/hieradata/foo.example.com.yaml --- angular色:: postgresql_puppetdb :: wal_level:hot_standby
这显然有点不灵活,因为您需要公开每个可调参数和configuration,以及通过您的role::postgresql_puppetdb类设置postgresql类提供的configuration。 当然,如果你知道你只需要暴露这样的几个可调参数就足够了。
第二种方法的例子是:
类angular色:: postgresql_puppetdb {
class {'postgresql':
...
}
class {'puppetdb':
...
}
$ postgres_config_entries = hiera_hash('postgres_configs',{})
create_resources('postgresql :: server :: config_entry',$ postgres_config_entries)
}
然后在Hiera:
#/etc/puppet/hieradata/foo.example.com.yaml
---
postgres_configs:
wal_level:
值:hot_standby
authentication_timeout:
价值:120s
krb_server_keyfile:
值:/var/lib/postgresql/postgresql.keytab
等等。 这是更灵活的,并允许您在每个层次级别上设置任意的Postgres参数。 在这种情况下,Hiera只会在包含role::postgresql_puppetdb类的情况下才会被用于这些configuration设置,但是没有什么能够阻止将hiera_hash-create_resources组合放入其他angular色,可能是role::postgresql 。
我希望这是可以理解和连贯的。 上述当然是未经testing的张贴,但我们使用这个非常策略(create_resources,hiera_hash)来pipe理本地和系统帐户,回购,sudoers规则,Tomcat实例和其他。 明天当我不那么疲倦的时候,会再次回答这个问题。
但是请看看Puppet-Ask上的这个优秀问题: https : //ask.puppetlabs.com/question/1655/an-end-to-end-roleprofile-example-using-hiera/
它走过了一个基于HAproxy的类似的设置。 非常有用的理解。