我有一个名为drbd
的模块,我需要在另一个名为hacluster
模块中使用。 起初,我想这样分类drbd的东西在自己的class级:
modules/drbd/[stuff] # this is the DRBD module modules/hacluster/manifests/init.pp # class hacluster { include hacluster::drbd } modules/hacluster/manifests/drbd.pp # class hacluster::drbd
hacluster::drbd
类像这样安装和configurationDRBD:
class hacluster::drbd { class { 'drbd': service_ensure => undef, service_enable => false, } class { 'drbd::global_common': ...more stuff... } drbd::resource {'r0': ...stuff...} drbd::resource {'r1': ...stuff...} }
…但是Puppet不喜欢我从hacluster :: drbd类中调用drbd模块:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: Class[Hacluster::Drbd] is already declared; cannot redeclare on node mynode.blabla
我通过将我的类从hacluster::drbd
重命名为hacluster::drbd
来修复它,但我仍然想知道是否有方法从包含在不同模块中的同名子类调用模块。 我没有阅读文件,但找不到明确的答案。
Puppet更喜欢当前命名空间( hacluster::
的类,而不是回到根目录并从那里parsing。 在名称空间和自动加载的语言参考中有一个很好的描述。
解决方法是在类名之前用::
显式引用顶级命名空间:
class { '::drbd': service_ensure => undef, service_enable => false, }