gpt4 book ai didi

class - Puppet: "Could not find class"在 list /模块更改后*经常*出现一次打嗝

转载 作者:行者123 更新时间:2023-12-02 09:22:00 27 4
gpt4 key购买 nike

我不知道这是一个错误还是某种误用/错误配置。希望有人能帮忙。谢谢!

如果我更改模块或 list 目录中的文件,通常会导致错误,大部分是以下类型

  • 无法找到节点上的类

  • 在节点上找不到定义类

当 Puppet 模块/ list 更改时,会发生这些错误 - 但只发生一次。如果发生这种情况,受影响的 puppet 代理将使用其缓存的目录一次。 下次这些代理请求目录时,它会完美地编译,一切都会像魅力一样工作 - 所有错误都消失了。问题是我们的代理商拥有大量目录。他们的目录运行可能需要长达一分钟多的时间,因此应用更改所需的时间将加倍,最多需要 2 甚至 3 分钟。

通常模块/ list 的更改是通过“git pull”执行的。但通过简单的“触摸”操作很容易重现这些错误消息。以下是一些有趣的日志观察及其[共性]。是的,AFAICS 它们总是以三胞胎的形式出现。很少有修改后完全没有这样的问题的。

>触摸/opt/xxx/dev/puppet/manifests/site.pp

[often] puppet-master[12498]: Could not find class <class> for <node> on <node>
[often] puppet-master[12498]: Could not find class <class> for <node> on <node>
[often] puppet-master[12498]: Could not find class <class> for <node> on <node>

>触摸/opt/xxx/dev/puppet/puppet.conf

[often] puppet-master[12498]: Could not find class <class> for <node> on <node>
[often] puppet-master[12498]: Could not find class <class> for <node> on <node>
[often] puppet-master[12498]: Could not find class <class> for <node> on <node>

[sometimes] puppet-master[12498]: Cannot find definition Class on node <node>
[sometimes] puppet-master[12498]: Cannot find definition Class on node <node>
[sometimes] puppet-master[12498]: Cannot find definition Class on node <node>

[rare] puppet-master[12498]: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type <own custom type> at <class file> on node <node>
[rare] puppet-master[12498]: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type <own custom type> at <class file> on node <node>
[rare] puppet-master[12498]: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type <own custom type> at <class file> on node <node>

>触摸/opt/xxx/dev/puppet/modules/dispatcher/manifests/init.pp

[often] puppet-master[12498]: Could not find class <class not even part of module dispatcher> for <node not even affected by module dispatcher> on <node not even...>
[often] puppet-master[12498]: Could not find class <class not even part of module dispatcher> for <node not even affected by module dispatcher> on <node not even...>
[often] puppet-master[12498]: Could not find class <class not even part of module dispatcher> for <node not even affected by module dispatcher> on <node not even...>

受影响的类和节点似乎是随机选择的。

运行环境:

> ll /etc/puppet
lrwxrwxrwx 1 root root 34 Mar 7 10:01 auth.conf -> /opt/xxx/dev/puppet/auth.conf
lrwxrwxrwx 1 root root 38 Mar 7 10:01 autosign.conf -> /opt/xxx/dev/puppet/autosign.conf
lrwxrwxrwx 1 root root 40 Mar 7 10:01 fileserver.conf -> /opt/xxx/dev/puppet/fileserver.conf
lrwxrwxrwx 1 root root 36 Mar 7 10:01 puppet.conf -> /opt/xxx/dev/puppet/puppet.conf

> ls -A /opt/xxx/dev/puppet/
auth.conf autosign.conf fileserver.conf .git .gitignore manifests modules .project puppet.conf scripts

> cat /etc/puppet/puppet.conf # on puppetmaster
[main]
logdir = /var/log/puppet
rundir = /var/run/puppet
ssldir = $vardir/ssl
modulepath = /opt/xxx/dev/puppet/modules
manifestdir = /opt/xxx/dev/puppet/manifests
manifest = /opt/xxx/dev/puppet/manifests/site.pp

[agent]
classfile = $vardir/classes.txt
localconfig = $vardir/localconfig
server = <puppetmaster host>
report = true
splaylimit = 0
runinterval = 30

[master]
certname=<puppetmaster host>
reports = http,log
reportdir = /var/lib/puppet/reports/upload
reporturl = http://<puppetmaster host>:3000/reports

> cat /opt/xxx/dev/puppet/manifests/site.pp
import 'nodes.pp'
$puppetserver = <puppetmaster host>

> rpm -qa | egrep "puppet|ruby"
rubygem-rake-0.8.7-2.1.el6.noarch
ruby-mysql-2.8.2-1.el6.x86_64
libselinux-ruby-2.0.94-5.3.el6.x86_64
puppet-3.1.0-1.el6.noarch
rubygem-fastthread-1.0.7-2.el6.x86_64
rubygem-mongrel-1.1.5-3.el6.x86_64
ruby-1.8.7.352-7.el6_2.x86_64
ruby-irb-1.8.7.352-7.el6_2.x86_64
ruby-augeas-0.4.1-1.el6.x86_64
ruby-shadow-1.4.1-13.el6.x86_64
puppetlabs-release-6-6.noarch
rubygems-1.3.7-1.el6.noarch
puppet-server-3.1.0-1.el6.noarch
rubygem-gem_plugin-0.2.3-3.el6.noarch
rubygem-daemons-1.0.10-2.el6.noarch
puppet-dashboard-1.2.22-1.el6.noarch
ruby-libs-1.8.7.352-7.el6_2.x86_64
ruby-rdoc-1.8.7.352-7.el6_2.x86_64
rubygem-json-1.4.6-1.el6.x86_64

最佳答案

当我重命名 Puppet 模块/类时,我就遇到过这种情况,结果是:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find class foo for example on node myhost.example.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

我在 Apache + Foreman 上使用 Passenger 提供 Puppet 服务,所以我找到的解决方案是重新启动 httpd 和 foreman-proxy:

sudo service httpd restart
sudo service foreman-proxy restart

此外,如果您使用代码版本控制系统(您应该这样做:)),例如 git 或 svn,请确保您确实将更新推送到了 puppet master。换句话说,检查您的模块是否确实存在于 Puppet 正在寻找的位置,例如/etc/puppet/modules/foo。我已经被这个问题绊倒过好几次了。

关于class - Puppet: "Could not find class"在 list /模块更改后*经常*出现一次打嗝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15289988/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com