执行人偶 script
时出现错误我在Puppet主site.pp
文件上编写了以下代码
node default {
class t {
package {'apache2':
ensure => installed,
}
}
}
在从属计算机上,当我使用puppet agent --test
执行它时,它会引发错误:
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Could not parse for environment production: Classes, definitions, and nodes may only appear at toplevel or inside other classes (file: /etc/puppet/code/environments/production/manifests/site.pp, line: 3, column: 1) on node slave.ec2.internal
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
在这方面,您能帮我吗?
答案 0 :(得分:2)
嗨,这是因为您不应该在site.pp
内定义类
具有这样定义的模块foo
(我更喜欢使用foo
而不是t
作为示例)
#modules/foo/manifests/init.pp
class foo {
package {'apache2':
ensure => installed,
}
}
并且您的site.pp中有一个节点条目,像这样
# site.pp
node default {
include 'foo'
}