我正在尝试完成类似以下的事情:
node 'basenode' {
class {
'puppet' :
disable => false,
}
}
node 'child' inherits 'basenode' {
class {
'puppet' :
disable => true,
}
}
这给了我:
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate definition: Class[Puppet] is already defined
我如何覆盖该单节点的设置,同时仍拥有参数化类?
答案1
事实证明这是一个已知问题:https://projects.puppetlabs.com/issues/5517
答案2
像这样进行节点继承通常不是好的设计。在 的不同文件中创建抽象“角色”层/etc/puppet/manifests/roles.pp
。然后将参数传递给这些类。
网站.pp
import "roles.pp"
import "nodes.pp"
节点.pp
node 'webserver1' {
class{"role::webserver":}
}
node 'webserver2' {
class{"role::webserver":
do_stuff => false,
}
}
node 'db' {
class{"role::db":}
}
角色.pp
class role($do_stuff) {
class{'foo': do_stuff => $do_stuff,}
}
class role::webserver($do_stuff=true) {
class{'role':
do_stuff => $do_stuff,
}
class{'apache':
other_stuff => 'foo',
}
}
class role::webserver($do_stuff=true) {
class{'role': do_stuff => $do_stuff,}
class{'apache': other_stuff => 'foo',}
}
class role::db($do_stuff=true) {
class{'role': do_stuff => $do_stuff,}
class{'postgres': other_stuff => 'foo',}
}