Skip to main content

Setup little kitchen using Chef 11 server on CentOS 6

To setup little kitchen (development environment), I created 2 win2k8 R2 VMs one for workstation and another for node. For chef server I downloaded the CentOS 6.4 and installed on my box using virtualbox.

To configure network between CentOS VM and the 2 windows VMs; I selected adapter 1 as Host-only Adapter and Adapter 2 as NAT for each of VMs network settings in VirtualBox.

Steps I followed to install Chef 11 server

1. Download the relevant platform package from the opscode site; you can use curl/wget. If you don't have wget then you can install by running #yum install -y wget"

#wget https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chef-server-11.0.4-1.el6.x86_64.rpm

2. Install the downloaded package using rpm or yum

#rpm -Uvh chef-server-11.0.4-1.el6.x86_64.rpm

3. Please add the hostname and the ip address of your chef server to the /etc/hosts file, to know your hostname run the #hostname.
4. After installation configure the chef server.

#chef-server-ctl reconfigure

5. Check if all the required services are running

#chef-server-ctl status

Setup workstation

6. Create .chef folder in the below location in your workstation

mkdir c:/users/administrator/.chef

7. Copy the admin.pem and chef-validator.pem from your chef server using below commands to your workstation .chef folder. (You may need to install git bash on your workstation to run these below commands and also install openssh-clients on your chef server)

scp root@:/etc/chef-server/admin.pem .
scp root@:/etc/chef-server/chef-validator.pem .

8. Download the chef client and install on your workstation

https://opscode-omnibus-packages.s3.amazonaws.com/windows/2008r2/x86_64/chef-client-11.4.0-1.windows.msi


9. After installation chef-client configure knife.

$ knife configure -i
WARNING: No knife configuration file found
Where should I put the config file? [c:/Users/Administrator/.chef/knife.rb]
Please enter the chef server URL: [http://localhost:4000] https://192.168.210.5/
(The chef server url should be https and not http and port should be default i.e 80 and not 4000)
Please enter a name for the new user: [Administrator] chefuser
(The new user name should match regular express /^[a-z0-9\-_]+$/, which means user name should have lower case alphabets)
Please enter the existing admin name: [admin]
Please enter the location of the existing admin's private key: [/etc/chef/admin.pem] c:/users/administrator/.chef/admin.pem
Please enter the validation clientname: [chef-validator]
Please enter the location of the validation key: [/etc/chef/validation.pem] c:/users/administrator/.chef/chef-validator.pem
Please enter the path to a chef repository (or leave blank):
Creating initial API user...
Please enter a password for the new user:
(The password must be at least 6 characters)
Created user[chefuser]
Configuration file written to c:/Users/Administrator/.chef/knife.rb

10. Check if knife is working

#knife client list

11. Browse the chef server url(https://192.168.210.5/) from your workstation and check if the website comes up, if don’t see website coming up then go to your chef server and disable the iptables service. The default credentials are displayed on the right side panel. (username: admin password: p@ssw0rd1)

#service iptables stop
#chkconfig iptables off

Setup Node

12. i.  Install chef-client on the node
    ii. Create chef folder in the C drive.
   iii. Create a file client.rb
log_level   :info
log_location    STDOUT
chef_server_url 'https://192.168.121.5/'
validation_client_name "chef-validator"
validation_key  "c:/chef/chef-validator.pem"
client_key  "c:/chef/client.pem"
file_cache_path   "c:/chef/cache"
file_backup_path  "c:/chef/backup"
cache_options     ({:path => "c:/chef/cache/checksums", :skip_expires => true})

     iv. Copy chef-validator.pem from the workstation to the node c:\chef
      v. Run chef-client on the node, to register the node in chef server.

Issues faced

  1. While configuring chef server using “chef-server-ctl reconfigure”I encountered the below error, after searching I found that there is already bug `chef-server-ctl reconfigure` fails if the hostname does not resolve.

ERROR:
 Recipe: chef-server::bootstrap
  * execute[verify-system-status] action run
================================================================================

Error executing action `run` on resource 'execute[verify-system-status]'

================================================================================

Mixlib::ShellOut::ShellCommandFailed

------------------------------------
Expected process to exit with [0], but received '22'
---- Begin output of curl -sf http://localhost:8000/_status ----
STDOUT:
STDERR:
---- End output of curl -sf http://localhost:8000/_status ----
Ran curl -sf http://localhost:8000/_status returned 22
  
RESOLUTION:
Added the hostname and the ip address of chef server to the /etc/hosts file, as suggested in step no 3 

2. While configuring knife using “knife configure –i”.

ERROR:
ERROR: Connection refused connecting to :443 for /192.168.210.5:4000//users, retry 1/5
ERROR: Connection refused connecting to :443 for /192.168.210.5:4000//users, retry 2/5
ERROR: Connection refused connecting to :443 for /192.168.210.5:4000//users, retry 3/5
ERROR: Connection refused connecting to :443 for /192.168.210.5:4000//users, retry 4/5
ERROR: Connection refused connecting to :443 for /192.168.210.5:4000//users, retry 5/5
ERROR: Network Error: No connection could be made because the target machine actively refused it. - 
Connection refused connecting to :443 for /192.168.210.5:4000//users, giving up
Check your knife configuration and network settings

RESOLUTION:
The chef server url should be https and not http and also the port should be default i.e 80 and not 4000.


3. While configuring knife, it asks for new user name.

ERROR:

ERROR: Chef::Exceptions::ValidationFailed: Option name's value Administrator does not match regular expression /^[a-z0-9\-_]+$/

RESOLUTION:
The new user name should match regular express /^[a-z0-9\-_]+$/, which means user name should have lower case alphabets
    
4. While configuring knife, it asks for password

ERROR:
ERROR: The data in your request was invalid
Response: Password must have at least 6 characters

RESOLUTION:
The password must be at least 6 characters
5. Unable to browse chef server url from your workstation

RESOLUTION:
Disable iptables service, using following commands

#service iptables stop
#chkconfig iptables off


 

Comments

Post a Comment

Popular posts from this blog

Connection failed - user: chef - (Bunny::ProtocolError)

I was trying to setup chef server on my local box using Oracle Enterprise Linux 6.4. After sucessfully installing all the required serivces chef-server was not running, so when I tried to start the service below error was displayed. Chef-server dead but pid file exists I tried to find the cause of this issue in logs but no clues in the logs as well. Then I run the chef server in foreground using the below command, to debug the issue #chef-server -C /etc/chef/server.rb -L /var/log/chef/server.log -p 4000 -e production -a thin -P /var/run/chef/server.pid -u chef -G chef Below stack trace was displayed merb : chef-server (api) : worker (port 4000) ~ Connection failed - user: chef - (Bunny::ProtocolError) This issue was becuase chef server was unable to connect to rabbitmq using bunny protocal as user chef. I had already run the below rabbitmq server configuration which is recommended in opscode site, but still it was failing to connect to rabbitmq # rab

Check your knife configuration and network settings, unable to upload cookbooks

While uploading cookbook to chef 11 server (OEL), I was getting the below errors C:\Users\Administrator>knife cookbook upload testcookbook Uploading testcookbook [0.1.0] ERROR: Network Error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. - connect(2) Check your knife configuration and network settings C:\Users\Administrator>knife cookbook upload testcookbook Uploading testcookbook1 [0.1.0] ERROR: Network Error: getaddrinfo: No such host is known. Check your knife configuration and network settings To find what is causing this issue, I ran knife cookbook upload in debug mode C:\Users\Administrator>knife cookbook upload testcookbook -s https://192.168.56.11 -V Uploading testcookbook [0.1.0] INFO: Validating ruby files INFO: Validating templates INFO: Syntax OK INFO: Saving testcookbook INFO: Uploading files I