While working on Chef, I came across multiple errors. After spending lot
of time, I was able to find solutions. So, I came up with an idea of this post
which is focused on errors related to chef and their solutions.
Error 1 : Error while installing knife ec2 gem
ERROR: Error installing
knife-ec2:
ERROR: Failed to build gem native
extension.
/usr/bin/ruby extconf.rb
checking for libxml/parser.h… no
——-
libxml2 is missing. please
visit http://nokogiri.org/tutorials/installing_nokogiri.html for
help with installing dependencies.
——-
*** extconf.rb failed ***
Solution :
yum install libxslt libxslt-devel
This command will install all necessary dependencies for knife ec2 gem.
——————————————————————————————————————————————
Error 2 : EDITOR environment variable error
ERROR: RuntimeError: Please set EDITOR environment variable
Solution :
This error can be resolved by issuing command “export EDITOR=$(which
vi)”.
But this environment variable will lost on system restart. For
persistance, please add this above command to .bashrc or .bash_profile file.
Another alternative solution(suggested by Mohit - check first comment)
for this error is by defining editor in knife.rb file.
Add knife[:editor] = ‘`which vim`’ in knife.rb file.
——————————————————————————————————————————————
Error 3 : Error while downloading cookbooks to your local laptop/PC
from Chef Server (which is hosted on AWS EC2)
nameless@Nameless:~$ knife cookbook
download apache
Downloading apache cookbook version
0.1.0
Downloading resources
Downloading providers
Downloading recipes
ERROR: Network Error: Error
connecting to https://ip-10-190-87-80.ec2.internal/bookshelf/organization-00000000000000000000000000000000/checksum-9084de40dd574612517c5c00a2a502bb?AWSAccessKeyId=145e4345cadce32e88d7cd21dfd7808460e15146&Expires=1369139721&Signature=/36/gcGdqdT3EBzDTQv5unEVHdw%3D-
getaddrinfo: Name or service not known
Check your knife configuration and network settings
Solution :
We face this error because the s3_url which is set to EC2 private dns
address is used by erchef to talk to bookshelf and used to generate URLs that
are given to clients that they use to access cookbook content.
To fix this, we need to add :
erchef[‘s3_url’] = https://<AWS-EIP>
to /etc/chef-server/chef-server.rb file. If the file is
not present, please create that. Once done, please issue “chef-server-ctl
reconfigure” command. [Thanks to Gionn and JB for highlighting this - see
comments]
Another solution (Less Suggested) :
PATH : /var/opt/chef-server/erchef/etc/app.config
Modify s3_url from EC2 private dns address to EC2
EIP/Public DNS i.e., modify {s3_url, “https://ip-10-190-87-80.ec2.internal”} to
{s3_url, “https://<AWS-EIP>”}.
After that, please perform a system restart. If you issue,
chef-server-ctl reconfigure command, it will set s3_url value to original
value.
——————————————————————————————————————————————
Error 4 : HTTPServerException : 403 “Forbidden”
FATAL: Net::HTTPServerException: template[/etc/httpd/conf/httpd.conf]
(apache::default line 20) had an error: Net::HTTPServerException: 403
“Forbidden”
Problem: Objects from cookbooks (templates, cookbook_files)
are lazily-loaded by default. If it's a very long run, deployment time
runs out of time(15 min by default).
Solution : This error is encountered
when we have large chef recipes whose deployment time on clients is large than
15 minutes. In order to avoid this error, please increase “s3_url_ttl"
value from 900 seconds to required time interval.To increase this value, please
add
erchef[‘s3_url_ttl’] = 3600in
/etc/chef-server/chef-server.rb file. Once done, please issue “chef-server-ctl
reconfigure" command. (Thanks Gionn and JB for highlighting this - see
comments).
Another Solution: Don't have
access to chef server then:
You can turn off lazy loading on the client by adding
no_lazy_load true
Another Solution (Less Suggested) :
We can find this value in app.config file under
path “/var/opt/chef-server/erchef/etc”
After that, please perform a system restart. If you issue,
chef-server-ctl reconfigure command, it will set s3_url value to original
value.
——————————————————————————————————————————————
Error 5 : RabbitMQ does not start on Oracle or Amazon Linux
RabbitMQ doesn’t start when “chef-server-ctl reconfigure” command
issued.
Solution : This error is encountered on
Amazon Linux because amazon linux platform is not definited in runit chef
recipe for chef server.
To fix this issue, navigate to
“/opt/chef-server/embedded/cookbooks/runit/recipes/default.rb” and add below
mentioned line after ubuntu platform description :
when "amazon"
include_recipe
"runit::upstart"
After that, the default.rb will look like :
case node["platform"]
when "ubuntu"
include_recipe
"runit::upstart"
when "amazon"
include_recipe
"runit::upstart"
when "redhat","centos","rhel","scientific"
if node['platform_version'] =~
/^6/
include_recipe
"runit::upstart"
else
include_recipe
"runit::upstart"
end
Once done, please issue “chef-server-ctl reconfigure” command again.
——————————————————————————————————————————————
Error 6 : Error when uploading - NameError: uninitialized constant
Chef::CookbookUploader::Queue
Solution : This error is mainly
encountered on Amazon Linux while uploading cookbooks.
To fix this issue, navigate to
“/usr/lib/ruby/gems/1.8/gems/chef-11.8.2/lib/chef/cookbook_uploader.rb” and add
below mentioned line on top.
require 'threads'
——————————————————————————————————————————————
No comments:
Post a Comment