Created
November 21, 2016 08:04
-
-
Save zduymz/155d9a75b9bac236365ac2c9998c2110 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Chef Solo or Chef Server? | |
Chef comes in two flavors: Chef Solo and Chef Server. Chef Solo is a basically a simpler version of Chef Server because it’s designed to be used with a small number of servers. With Chef Solo, you write your recipes on your local computer, upload them to your server(s), and Chef Solo is then called to run them. (A recipe, by the way, is a file containing the commands that will run to provision your server.) | |
With Chef Server, you still write your recipes on your local computer, but instead of uploading them to the server you want provisioned, you upload them to a server that’s specifically dedicated to Chef. This server acts as the main repository of all your recipes. The servers you want provisioned will then have a program running on them (referred to as a Chef client) that is in constant communication with your Chef server, and whenever you upload your recipes to Chef server, Chef client will notice this and run them automatically. (Chef Solo is also Chef client; it just doesn’t need a Chef server to do its job.) | |
Working with Chef Solo | |
One nice thing about Chef Server is you get to use a command-line tool called Knife that allows you to easily communicate with Chef Server right from your local computer. It gives you commands to easily upload your recipes, for example, among many other things. Unfortunately, it doesn’t offer similar commands for Chef Solo, but there is a Knife plugin called knife-solo that does just this. Since it’s a packaged gem, all we need to do is add it to our app’s Gemfile on our local computer, and the commands we need will be available automatically: | |
Gemfile | |
group :development do | |
gem 'knife-solo', '~> 0.4.2' | |
end | |
When you run bundle to install it, the Chef gem will be installed as well. If you then go into your app’s root directory and run knife, you’ll see a list of the commands available to you through Knife, including those provided by knife-solo, which will start with knife solo .... | |
DIVING IN | |
Having that installed, we’re now ready to start working with Chef Solo. The first thing we’ll do is create a configuration file for Knife on our local computer: | |
knife configure -r . --defaults | |
This will create a new ~/.chef directory with a file called knife.rb containing some default configurations. This file is used by Chef Server, so we actually won’t need it, but Knife will keep complaining if we don’t create it. | |
Next, go into your app’s /config directory and run the following: | |
knife solo init chef | |
cd chef | |
This will create a standard Chef directory structure (referred to as a “kitchen”) inside a directory called /chef. It’ll look like this: | |
chef/ | |
├── cookbooks | |
├── data_bags | |
├── environments | |
├── nodes | |
├── roles | |
└── site-cookbooks | |
Here is a brief description of each one: | |
/cookbooks: holds recipes written by the community | |
/data_bags: stores sensitive configuration for your infrastructure | |
/environments: contains the environments defined for Chef Server | |
/nodes: stores server-specific information | |
/roles: contains the roles defined for Chef Server | |
/site-cookbooks: holds recipes written by you | |
Note that some of these directories are only for Chef Server, but they’re created anyway because they’re part of the standard Chef directory structure. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment