2016-03-15 67 views
0

我得到重复声明错误,当我不认为我应该。puppet 4重复声明

我使用下面的木偶版本

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

我不知道为什么会这样,也许木偶有一个main已经。当我用main代替ryan时,一切都很好。

$ 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 
} 
0

木偶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 更多