当我认为不应该时,我收到重复的声明错误。
我正在使用以下木偶版
puppet --version
4.3.2
这是目录结构
./manifests
./manifests/site.pp
./modules
./modules/main
./modules/main/manifests
./modules/main/manifests/init.pp
./modules/main/manifests/sub.pp
site.pp
node default {
include main
include main::sub
}
init.pp
class main {
notice("main")
}
sub.pp
class main::sub {
notice("sub")
}
我运行此命令
puppet apply --modulepath ./modules manifests/site.pp
它产生了这个输出:
Notice: Scope(Class[Main]): main
Notice: Scope(Class[Main::Sub]): sub
Notice: Compiled catalog for black-pearl.hsd1.il.comcast.net in environment production in 0.82 seconds
Error: Duplicate declaration: Class[Main] is already declared; cannot redeclare
答案 0 :(得分:0)
我不确定为什么会这样,也许木偶已经有了main
。当我将ryan
替换为main
时,一切都很顺利。
$ find .
.
./manifests
./manifests/site.pp
./modules
./modules/ryan
./modules/ryan/manifests
./modules/ryan/manifests/init.pp
./modules/ryan/manifests/sub.pp
site.pp
node default {
include ryan
include ryan::sub
}
答案 1 :(得分:0)
Puppet 4对名称更加严格,并且有许多保留名称,包括main
:
Reserved Class Names
The following are built-in namespaces used by Puppet and so must not be used as class names:
main — Puppet automatically creates a main class, which contains any resources not contained by any other class.
参见https://docs.puppetlabs.com/puppet/latest/reference/lang_reserved.html 更多