[英]Error while running Puppet Agent using class in node default
I am getting error while executing puppet script执行 puppet脚本时出现错误
on Puppet master site.pp
file I wrote following code在 Puppet master site.pp
文件上,我编写了以下代码
node default {
class t {
package {'apache2':
ensure => installed,
}
}
}
On Slave machine when i execute it using puppet agent --test
, it throws the error:在从机器上,当我使用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
Can you please help me in this regard你能在这方面帮助我吗
Hi this is because you are not supposed to define classes inside site.pp
嗨,这是因为您不应该在site.pp
中定义类
Have a module foo
(as I prefer foo
for examples instead of t
) defined like this:有一个模块foo
(因为我更喜欢foo
作为示例而不是t
)定义如下:
#modules/foo/manifests/init.pp
class foo {
package {'apache2':
ensure => installed,
}
}
and you have a node entry in your site.pp like this并且您的 site.pp 中有一个节点条目,如下所示
# site.pp
node default {
include 'foo'
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.