我是木偶的新手,我在尝试做一些琐碎的事情时遇到了一些错误。
我一直收到双重声明错误,但我无法弄清楚原因。 我想我在这里遗漏了一些东西,欢迎所有的意见。
Puppet版本: 3.7.5 (我试图使用个人资料/角色设计模式)
以下是我的文件:
tomcat.pp
(它在... puppet/manifests/profile/manifests/tomcat.pp
)
class profile::tomcat(
$java_version,
$java_package,
$version,
$home,
$instance,
$user,
$group,
$java_opts,
$java_home,
$server_port = "XXXX",
$http_port = "XXXX",
$ajp_port = "XXXX",
) {
class { 'java':
version => $java_version,
package => $java_package,
}
## do stuffs
}
applicationserver.pp
(它在... puppet/manifests/role/manifests/applicationserver.pp
)
class role::applicationserver {
include profile::tomcatpackage
}
main.pp
(我用这个文件运行木偶申请)
node tomcatvm{
include role::applicationserver
}
最后我的hiera
文件:
profile::tomcat::java_version: '1.7.0_75-fcs'
profile::tomcat::java_package: 'jdk'
profile::tomcat::version: '7.0.57'
profile::tomcat::instance: 'ulg'
profile::tomcat::home: '/appli/tomcat'
profile::tomcat::user: 'tomcat-ulg'
profile::tomcat::group: 'tomcat-ulg'
profile::tomcat::java_opts: 'options'
profile::tomcat::java_home: '/usr/java/default'
我得到的错误:
Error: Duplicate declaration: Class[Profile::Tomcat] is already declared; cannot redeclare at /etc/puppet/modules/profile/manifests/tomcat.pp:39 on node tomcatvm.home
Error: Duplicate declaration: Class[Profile::Tomcat] is already declared; cannot redeclare at /etc/puppet/modules/profile/manifests/tomcat.pp:39 on node tomcatvm.home
我得到2次相同的错误并不奇怪吗? 无论如何,欢迎所有关于我的工作的答案或意见,
抱歉我的英文不好,谢谢
答案 0 :(得分:2)
当您通过重命名配置文件类来解决问题时,您很可能会发生范围冲突,即
class profile::tomcat {
include tomcat
}
应该包含tomcat
模块。但是,当在profile
模块的范围内使用时,它会将tomcat
解析为profile::tomcat
。
正确的解决方案是避免这种隐含的范围。
class profile::tomcat {
include ::tomcat
}
使用::tomcat
向Puppet表明您指的是tomcat
模块,而不是同名的本地类。