How to install Chef Configuration Management Server Workstation and Node

February 7, 2014

This is a how to article on setting up Chef a configuration management system and its components (Server, Workstation, and Node) on CentOS 6.3 64-bit. Chef is a systems and cloud infrastructure automation framework that makes it easy to deploy servers and applications to any physical, virtual, or cloud location, no matter the size of the infrastructure.

The chef-client relies on abstract definitions (known as cookbooks and recipes) that are written in Ruby and are managed like source code. Each definition describes how a specific part of your infrastructure should be built and managed. The chef-client then applies those definitions to servers and applications, as specified, resulting in a fully automated infrastructure. When a new node is brought online, the only thing the chef-client needs to know is which cookbooks and recipes to apply.

Setup a Chef Server
The server acts as a hub for configuration data. The server stores cookbooks, the policies that are applied to nodes, and metadata that describes each registered node that is being managed by the chef-client. Nodes use the chef-client to ask the server for configuration details, such as recipes, templates, and file distributions. The chef-client then does as much of the configuration work as possible on the nodes themselves (and not on the server). This scalable approach distributes the configuration effort throughout the organization.

Make sure you have a fully qualified domain name as your hostname

bash-shell# vim /etc/sysconfig/network
 
NETWORKING=yes
HOSTNAME=your-fqdn-hostname.com
 
bash-shell# hostname your-fqdn-hostname.com

Install and configure chef server

bash-shell# wget https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chef-server-11.0.10-1.el6.x86_64.rpm
bash-shell# yum install -y chef-server-11.0.10-1.el6.x86_64.rpm
bash-shell# chef-server-ctl reconfigure

Verify your install

bash-shell# chef-server-ctl test

Go into your browser to your Chef server https://your-fqdn-hostname.com

The default userName/password is admin/p@ssw0rd1

Make sure you change the default password after login.

Setup a Chef Workstation
The Chef workstation is where you will be doing your work prior to uploading to the Chef Server which will be used by the nodes.

Install some dependencies

bash-shell# yum install -y git

Install Chef

bash-shell# curl -L https://www.opscode.com/chef/install.sh | bash

Verify Chef install

bash-shell# chef-client -v

Clone Chef repo

bash-shell# cd ~
bash-shell# git clone git://github.com/opscode/chef-repo.git

Configure Chef

bash-shell# cd chef-repo/
bash-shell# mkdir -p ~/chef-repo/.chef
bash-shell# echo '.chef' >> .gitignore
bash-shell# echo 'export PATH="/opt/chef/embedded/bin:$PATH"' >> ~/.bash_profile && source ~/.bash_profile
bash-shell# cd ~/chef-repo/.chef

Copy your chef-validator.pem and admin.pem Chef server /etc/chef-server to ~/chef-repo/.chef/

bash-shell# chmod 600 ~/chef-repo/.chef/*.pem

Create a knife.rb configuration file

bash-shell# knife configure --initial
 
WARNING: No knife configuration file found
Where should I put the config file? ~/chef-repo/.chef/knife.rb
Please enter the chef server URL: https://us-east-chef-server-01.givit.com:443
Please enter a name for the new user: knife
Please enter the existing admin name: [admin] 
Please enter the location of the existing admin's private key: ~/chef-repo/.chef/admin.pem
Please enter the validation clientname: [chef-validator] 
Please enter the location of the validation key: ~/chef-repo/.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: 
Created user[knife]
Configuration file written to ~/chef-repo/.chef/knife.rb

Verify your workstation install

bash-shell# knife client list
 
chef-validator
chef-webui
 
bash-shell# knife user list
 
admin
knife

Setup a Chef Node
A node is any physical, virtual, or cloud machine that is configured to be maintained by a chef-client.

Make sure you have a fully qualified domain name as your hostname

bash-shell# vim /etc/sysconfig/network
 
NETWORKING=yes
HOSTNAME=your-fqdn-hostname.com
 
bash-shell# hostname your-fqdn-hostname.com

Install Chef

bash-shell# curl -L https://www.opscode.com/chef/install.sh | bash
bash-shell# mkdir /etc/chef
bash-shell# cd /etc/chef/

Copy your chef-validator.pem from the Chef server /etc/chef-server to /etc/chef/

bash-shell# chmod 600 /etc/chef/*.pem

Register your Chef node

chef-client -S https://your-fqdn-hostname-of-chef-server.com -K /etc/chef/chef-validator.pem

Setup your Chef client.rb file

bash-shell# vim client.rb
 
log_level        :info
  log_location     STDOUT
  chef_server_url  'https://your-fqdn-hostname-of-chef-server.com'

Verify your Chef node install

bash-shell# chef-client

Your next step is to find and implement a recipe. Please read the next article in the series “How to install and configure Chef Cookbook: users to manage users” .

Hope this helps you get your Chef components setup for infrastructure as code fun.

Comments for “How to install Chef Configuration Management Server Workstation and Node”

Leave a Reply