Saturday, June 29, 2013

Common Opscode Chef errors and their solutions

This article is syndicated from Sanket's Blog :http://sanketdangi.com/post/50897416859/chef-errors-and-their-solutions
Sanket is a cloud engineer @ 8K Miles. We use Chef for automating deployments in many customer cases. Sanket has compiled his basic experience on dealing with errors while working on Chef deployments. I hope it will be useful for the AWS & Chef community. 
"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. I’ll be updating this post regularly with all the errors I have faced and their solutions." - Sanket
---------------------------------------------------------------------------------------------
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.
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"
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. 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.

No comments:

Need Consulting help ?

Name

Email *

Message *

DISCLAIMER
All posts, comments, views expressed in this blog are my own and does not represent the positions or views of my past, present or future employers. The intention of this blog is to share my experience and views. Content is subject to change without any notice. While I would do my best to quote the original author or copyright owners wherever I reference them, if you find any of the content / images violating copyright, please let me know and I will act upon it immediately. Lastly, I encourage you to share the content of this blog in general with other online communities for non-commercial and educational purposes.

Followers