在节点默认情况下使用类运行Puppet Agent时出错

时间:2019-09-21 13:21:36

标签: puppet

执行人偶 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

在这方面,您能帮我吗?

1 个答案:

答案 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'
}