【导读】html

puppet在运维管理是个自动化的工具,做用很是明显,可是苦于puppet 中文资料很少,puppet学习难度node

大,在puppet使用过程当中,碰到不少各类奇怪的问题,这里是 sky的我的总结的一些puppet常见错误,以mysql

及相应的解决方法,也感谢部分群友的分享:坚持创新和Ninjaweb

以及再一年等QQ好友,也但愿更多的人分享puppet知识,共同进步。sql

【puppet 常见错误列表】shell

1.Failed to retrieve current state of resource: Could not retrieve information from source(s)数据库

err: //test/File[/tmp/sky]: Failed to retrieve current state of resource: Could not retrieve information from source(s) puppet:///test/foo at /etc/puppet/modules/test/manifests/init.pp:6ubuntu

解决方法:这是通常大多人犯的问题,这个问题通常是出如今puppetmaster上,大部分是source这个路径没有写对。能够查看init.pp的第6行,ruby

通常正确的写法是source => “puppet:///test/sky”,关于文件服务器的写法,能够参阅以前的sky的文档.服务器

2.Could not retrieve information from environment production source(s) puppet://server.puppet.com/plugins

 

解决方法:这是通常都是经过yum或者apt-get安装了puppet,在puppetmaster和客户端的配置文件 里有pluginsync=true ,

把两端/etc/puppet.conf里pluginsync=true ,改为pluginsync=false,并重启puppetmaster便可解决。

再补充一种方法,若是不设置pluginsync=false,那么就须要到少要建个插件。

3.Could not request certificate: undefined method `closed?’

err: Could not request certificate: undefined method `closed?' for nil:NilClass Exiting;

failed to retrieve certificate and watiforcert is disabled

解决方法:a.确保puppet的运行用户是否有权限读ssl认证文件。

b.确认防火墙是否打开8140端口。

4.Change from absent to file failed

err: //test/File[/tmp/sky/www.mysqlops.com]/ensure: change from absent to file failed: Could not set file on ensure: No such file or directory

解决方法:很明显,多是没有/tmp/sky这个目录,若是没有,请使用 mkdir -p /tmp/sky.

5.Run of Puppet configuration client already in progress

解决方法,很明显,a.能够经过ps -axf|grep puppet是否有puppet进程在运行。若是有,则停掉puppet,再运行,便可。

b.没有进程,那有可能puppetdlock存在,则删除之,使用 rm -rf /var/puppet/state/puppetdlock

6.Change failed ... Could not find server

err: //test/File[/tmp/sky]/content: change from {md5}068008008418dff20750a94336318974 to {md5}8db2d67767577c70b1251fd80ad32943 failed: Could not find server puppet

解决方法:这是设置了filebucket, 名称为puppet,但并不没有使用真名。在配置文件/etc/puppet.conf里设置以下:

filebucket {
puppetmaster: server => "www.mysqlops.com" # server后面要用全名,即fqdn.
}

 

7.

err: Could not retrieve catalog: can't convert nil into String at /etc/puppet/modules/test/manifests/init.pp:29 on node web-01.test.com

解决方法:确认模板文件是否存在。通常都是文件不存在的时候报的。

8.undefined method `closed?’ for nil:NilClass

err: Could not retrieve catalog from remote server: undefined method `closed?' for nil:NilClas

解决方法:常常多是语法错误,少了双引号或者 大概号什么的。

9.certificate verify failed

err: /File[/var/lib/puppet/lib]: Failed to generate additional resources using 'eval_generate': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
err: /File[/var/lib/puppet/lib]: Failed to retrieve current state of resource: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed Could not retrieve file metadata for puppet://puppet.example.com/plugins: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
err: Could not retrieve catalog from remote server: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

解决方法:这多是换了不一样的两台puppetmaster服务器引发的。解决方法,删除现有ssl证书。find /var/lib/puppet -type f -print0 |xargs -0r rm

10.Could not retrieve catalog from remote server

err: Could not retrieve catalog from remote server: No such file or directory - /var/lib/puppet/client_yaml/catalog

解决方法:明显提示,/var/lib/puppet/client_yaml/可能不存在,没有则建立之。

11.no certificate found and waitforcert is disabled

warning: peer certificate won’t be verified in this SSL session
Exiting; no certificate found and waitforcert is disabled

解决方法: 这个是须要puppetmaster端给客户端ssl签名.

a.puppetca -l #列出等待签名的客户端

b.puppetca -s hostname # hostname 是客户端主机的名字。

12.Could not intern from pson: Could not convert from pson: Could not find relationship target ”

解决方法:这是一个bug, 针对版本0.25.1.在puppet0.25.5.1版本中能够在/etc/puppet/puppet.conf里添加

preferred_serialization_format = yaml 便可解决。

13.Error 400 on SERVER: No support for http method POST

err: Could not retrieve catalog from remote server: Error 400 on SERVER: No support for http method POST

解决方法:这个问题多是puppetmaster是2.6版本,puppet客户端版本是2.7。请记住 ,puppetmaster版本能够大于或者等于客户端的版本。

不能小于,互换下puppet角色,便可。

14.You cannot specify more than one of content, source, target

err: Could not run Puppet configuration client: You cannot specify more than one of content, source, target at /etc/puppet/modules/test/manifests/init.pp:10

解决方法:错误提示很显示,不能为一个文件指定多个来源。

15.Could not retrieve catalog from remote server: wrong header line format

解决方法,多是模板语法错误,请使用命令检查模板语法,示例:erb -x -T ‘-’ -P test/templates/cron/cron.erb |ruby -c

16.Cannot override local resource on node

err: Could not retrieve catalog from remote server: Error 400 on SERVER: Exported resource skyd[foo] cannot override local resource on node web-01.mysqlops.com

解决方法:这个问题,通常是在使用export 虚拟资源的时候会出现,多是有重复的定义。

这多是因为旧节点,运行puppet clean node。查看数据库。使用下面的sql

“select hosts.name from hosts,resources where restype=’skyd’ and title=’foo’ and hosts.id = resources.host_id;”

17.Could not render to pson: invalid utf8 byte

err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not render to pson: invalid utf8 byte:

解决方法:多是有无效的utf8字符,能够使用命令:od -c filename 进行检查。

18. 在安装dashboad的时候,报

RAILS_ENV=production db:migrate --trace
(in /usr/local/puppet-dashboard)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
** Invoke db:schema:dump (first_time)
** Invoke environment
** Execute db:schema:dump
rake aborted!
undefined method `reenable' for <Rake::Task db:schema:dump => [environment]>:Rake::Task
解决访问,多是gem版本不对,升级版本,请确认版本是否知足安装dashboad的要求。

19.在执行facter命令的时候报:

err: Could not run Puppet configuration client: Could not retrieve local facts: execution expired
解决方法,因为ubuntu升级致使的ec2.rb有新的改动,能够修改/usr/lib/ruby/1.8/facter这个目录下面的ec2.rb文件后重新启动后解决。
具体解决方法以下:1. cd /usr/lib/ruby/1.8/facter
                2. cp ec2.rb{,.`date -I`} #备份新的ec2.rb这个文件
                3. 从正常执行的主机复制ec2.rb这个文件进行覆盖。或者比较两个文件的不一样,进行修改。

20.在使用gem 安装的时候会报:

ERROR:  Could not find a valid gem 'rake' (>= 0) in any repository
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)

解决方法:多是没有gem源,或者没法访问源,大部分是网络问题。

能够多添加下几个gem 源来尝试解决:

使用命令:

?
1
2
3
4
gem sources -a http:  //gems  .rubyforge.org
gem sources -a http:  //gems  .rubyonrails.org
gem sources -a http:  //gemcutter  .org
gem sources -a http:  //rubygems  .org

 

添加了上面的四个gem源,但愿能解决,另外使用gem 安装的过程比较慢,须要你们耐心点等待提示。

【总结】

puppet在安装与配置过程当中,常常会遇到上面的问题,列出一些常见puppet错误,以供后面的同窗参考,感谢部分QQ 朋友的分享