我已经玩了几个星期的傀儡(真的是小孩玩),不知道如何实现一个名字是客户端的模块; 这个模块将被这样调用:
client { "client-name": "apache-node" => "name-of-apache-node", "tomcat-node" => "name-of-tomcat-node", "https" => true, # probably other parameters, and other nodes may be implied as well }
然后这将自动生成所有相关节点的configuration并分发configuration。
注意:我不希望使用外部来源(LDAP或其他),只适用于傀儡:我有足够的时间与傀儡,只有当我有足够的掌握(做几个月,可能…) 。
注2:木偶版本是2.6.12,因为版本是1.5.9。
这是可能的,还是一个梦想?
当然,这应该是可行的。
首先,你需要将它包含在适用于两个节点的地方,然后过滤掉需要应用到不同节点的configuration(可能是用一个大的case语句),或者为tomcat端拥有不同的类的应用程序和Apache的一面(这可能会更干净)。
这是我要采取的方法:
为您的客户端应用程序设置一个多级模块:
modules -> client-app -> manifests -> apache.pp -> tomcat.pp
用你需要的configuration设置这些类:
class client-app::apache ($tomcatnodes = undef, $https = true) { package { 'apache2': ensure => present, } # ... etc etc # use a template file that utilizes the $tomcatnodes and $https # variables to set the config that you need }
然后将这些附加到您的节点上:
node tomcatserver1 { class { 'client-app::tomcat': apachenode = 'apacheserver', https = true, } } node tomcatserver2 { class { 'client-app::tomcat': apachenode = 'apacheserver', https = true, } } node apacheserver { class { 'client-app::apache': tomcatnodes = [ 'tomcatserver1', 'tomcatserver2' ], https = true, } }
一些进一步阅读你的这个实现:看到这里和这里 。