【问题标题】:Puppet Error : Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Could not find classPuppet 错误:服务器上的错误 500:服务器错误:评估错误:评估函数调用时出错,找不到类
【发布时间】:2019-11-26 10:47:43
【问题描述】:

我正在对此进行测试并在 Puppet 代理节点上遇到错误

[root@pagent1 ~]# puppet agent -t
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: Evaluation Error: Error while evaluating a Function Call, Could not find class ::nginx for pagent1.testcentos7.com (file: /etc/puppetlabs/code/environments/production/manifests/site.pp, line: 3, column: 3) on node pagent1.testcentos7.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

来自 Puppet 服务器的这些类的内容:

[root@pmaster ~]# cat /etc/puppetlabs/code/environments/production/manifests/site.pp
node pagent1.testcentos7.com {
  class { 'nginx': }
}

[root@pmaster ~]# cat /etc/puppetlabs/code/environments/production/modules/nginx/manifests/manifests/init.pp
class nginx {
  contain nginx::install
}

[root@pmaster ~]# cat /etc/puppetlabs/code/environments/production/modules/nginx/manifests/install.pp
class nginx::install {
  package { 'install_nginx':
    name    => 'nginx',
    ensure  => 'present',
  }
}

语法检查显示此错误:

[root@pmaster ~]# puppet parser validate /etc/puppetlabs/code/environments/production/modules/nginx/manifests/manifests/init.pp
Error: Could not parse for environment production: Unacceptable location. The name 'nginx' is unacceptable in file '/etc/puppetlabs/code/environments/production/modules/nginx/manifests/manifests/init.pp' (file: /etc/puppetlabs/code/environments/production/modules/nginx/manifests/manifests/init.pp, line: 7, column: 1)

注意:使用 Puppet Development Kit (PDK) 创建模块“nginx”及其类。

这是一个错误还是什么,或者我的类名有误?

我找到的相关主题是https://groups.google.com/forum/embed/#!topic/puppet-users/nxbwCvWrgMI,但希望有人帮我简化一下

【问题讨论】:

  • 类的命名和排列似乎是正确的。在这种情况下,最可能的问题是访问控制问题。 puppetserver 通常不作为特权进程运行,因此它依赖于所有清单和数据的所有权和权限(以及 SELinux 上下文,...)来允许它访问。如果他们不这样做,那么就好像他们的内容不存在一样。
  • 谢谢。禁用 SELinux 和防火墙,仍然出现此错误。在此处的单独答案中找到了修复并提交了解决方案:)

标签: puppet


【解决方案1】:

通过将“init.pp”移动到安装类文件的路径 /etc/puppetlabs/code/environments/production/modules/nginx/manifests 解决了这个问题install.pp' 存在。

为了更清楚起见,我将文件 'init.pp' 和 'install.pp' 放在同一位置目录 /etc/puppetlabs/ code/environments/production/modules/nginx/manifests 来解决这个问题。

【讨论】:

  • 好吧,我猜是我的错。我不知何故没有认识到这两个清单位于不同的目录中,尽管我现在在问题中看到了它。很高兴你知道了。
  • 顺便说一句,这里修改你的问题的标题以表明它已解决是违反习惯和惯例的。因此,我回滚了该编辑。如果您愿意,您可以改为“接受”您的答案之一,包括您自己写的答案,方法是点击旁边的复选标记。
  • 谢谢@JohnBollinger
猜你喜欢
  • 1970-01-01
  • 2021-01-03
  • 1970-01-01
  • 2017-12-30
  • 1970-01-01
  • 2017-03-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多