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.
The following items are prerequisites for installing the chef-client on a workstation:
The following steps describe how to install the chef-client on a workstation.
The steps for installing the chef-client on a machine that runs Linux, UNIX, or Mac OS X are identical:
See the following sections for more information about each step.
The chef-client communicates with a server as part of the configuration process. Sign up for hosted Enterprise Chef, install Enterprise Chef, or install the open source server.
Ensure that the workstation meets all of the software prerequisites and that it has access to a server and to a machine that can host a node.
The bits for the chef-client omnibus installer are available as a download from Chef.
To download the omnibus installer for the chef-client:
To install the chef-client on a workstation, you must run the omnibus installer.
To run the omnibus installer:
Run the command that appears (for UNIX and Linux environments) or download the omnibus installer (for Microsoft Windows environments). For example, for the Mac OS X:
curl -L https://www.opscode.com/chef/install.sh | sudo bash
and then enter the password for the local machine.
As the chef-client is being installed, the command window will show something like the following:
Downloading Chef for mac_os_x... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 23.9M 100 23.9M 0 0 944k 0 0:00:26 0:00:26 --:--:-- 838k Installing Chef
When the installation is finished enter the following to verify that the chef-client was installed:
When the chef-client is installed correctly, the command shell will return a note that says the version of that was installed. For example:
After the chef-client has been installed, the following folder structure will be present on the local machine:
/opt /chef /bin /embedded /bin /include /lib /share /ssl
An open source distributed version control system called git must be installed before the chef-repo can be cloned to the workstation from github.
To install git:
It is not necessary to create or fork a repository in order to clone the chef-repo from github.
The chef-repo on github must be cloned to every workstation that will interact with a server.
To clone the chef-repo:
In a command window, enter the following:
$ git clone git://github.com/opscode/chef-repo.git
While the chef-repo is being cloned on the local machine, the command window will show something like the following:
Cloning into 'chef-repo'... remote: Counting objects: 199, done. remote: Compressing objects: 100% (119/119), done. remote: Total 199 (delta 71), reused 160 (delta 47) Receiving objects: 100% (199/199), 30.45 KiB, done. Resolving deltas: 100% (71/71), done.
After the chef-repo has been cloned, the following folder structure will be present on the local machine:
chef-repo/ certificates/ config/ cookbooks/ data_bags environments/ roles/
The server provides three files that must be in the chef-repo and are required when connecting to the server.
For a workstation that will interact with Enterprise Chef (including hosted Enterprise Chef), log on and download the following files:
Open Source Chef Server
For a workstation that will interact with the open source server, do the following:
These files will be moved into the .chef directory, which is a hidden directory that must be created in the chef-repo.
The chef-client includes a stable version of Ruby as part of the omnibus installer. The path to this version of Ruby must be added to the $PATH environment variable and saved in the configuration file for the command shell (Bash, Csh, and so on) that is used on the workstation. In a command window, type the following:
echo 'export PATH="/opt/chef/embedded/bin:$PATH"' >> ~/.configuration_file && source ~/.configuration_file
where configuration_file is the name of the configuration file for the specific command shell. For example, if Bash were the command shell and the configuration file were named bash_profile, the command would look something like the following:
echo 'export PATH="/opt/chef/embedded/bin:$PATH"' >> ~/.bash_profile && source ~/.bash_profile
A workstation is installed correctly when it is able to use Knife to communicate with the server.
To verify that a workstation can connect to the server:
In a command window, navigate to the chef-repo:
In a command window, enter the following:
knife client list
to return a list of clients (registered nodes and workstations) that have access to the server. For example: