Skip to content
This repository

Cook with Chef without a Chef Server

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 tests
Octocat-spinner-32 .gitignore
Octocat-spinner-32 CHANGELOG
Octocat-spinner-32 LICENSE Rename fabfile.py to littlechef.py October 26, 2010
Octocat-spinner-32 MANIFEST.in
Octocat-spinner-32 NOTICE
Octocat-spinner-32 README.textile
Octocat-spinner-32 cook
Octocat-spinner-32 littlechef.py
Octocat-spinner-32 setup.py
README.textile

LitteChef

With LittleChef you will be able to get started more quickly cooking with Chef, the excellent Configuration Management System.

Overview

You may think of this like a pocket Chef. You don’t need to worry about installation, repository syncing, nor Chef Server authentication. You also won’t have to remotely edit cookbooks, or commit little changes just to test things.

Installing LittleChef to your work computer is all you need to get you started.

How it all works

It all starts in the kitchen, your deployment directory, which you should keep under version control:
auth.cfg: Authentication information needed to be able to connect to the nodes
nodes/: After recipes are run on nodes, their configuration is stored here
cookbooks/: This will be your cookbooks repository
site-cookbooks/: Here you can override upstream cookbooks (Opscode’s, for example)
roles/: Where Chef roles are defined

Whenever you apply a recipe to a node, all needed cookbooks (including dependencies) and all roles are gzipped and uploaded to that node, to the /tmp/chef-solo/ directory. A node.json file gets created on the fly and uploaded, and Chef Solo gets executed at the remote node, using node.json as the node configuration and the pre-installed solo.rb for Chef Solo configuration.

The result is that you can play as often with your recipes and nodes as you want, without having to worry about repositories, central servers nor anything else. Once you are satisfied with a new feature in a cookbook, you can commit the cookbooks/ directory to your repository. LittleChef brings back sanity to cookbook development.

Installation

Requirements

  • Python 2.6+
  • Setuptools
  • Fabric 1.0.1+

All needed packages are installed by typing:
sudo apt-get install python-pip python-fabric for Debian and Ubuntu
or
yum install python-pip fabric for RHEL and CentOS

Note: If your distribution doesn’t have an up-to-date version of Fabric, don’t install the distribution package: the installation step will take care of that dependency.

Installation

You can install Little Chef directly from the PyPI:
pip install littlechef

Note: your distribution may have a cook package that also provides a cook executable. If you have installed it, you need to remove it to avoid collisions with Little Chef’s executable.

Usage

Disclaimer

Careful what you do with your nodes!:

A certain famous Chef: What do I always say? Anyone can cook.
Little Chef: Yeah. Anyone can, that doesn’t mean that anyone should.

Setup

cook new_deployment will create inside the current directory a few files and directories for LittleChef to be able to cook. You can create and have as many deployment directories (kitchens) as you like on your computer.

To be able to issue commands to remote nodes, you need to enter a user and a password with sudo rights. new_deployment will have created a file named auth.cfg. You can edit it now to enter a username and password or a keypair-file.

Deploying

For convenience, there is a command that allows you to deploy chef-solo to a node.

The best way is to use the packages from the Opscode repository:
cook node:MYNODE deploy_chef

Little Chef will try to autodetect the distro type and version of that node, and will use the appropriate installation method and packages.

You can also install Chef Solo with gems and/or without asking for confirmation:
cook node:MYNODE deploy_chef:gems=yes,ask=no

Currently supported Linux distributions include Ubuntu, Debian Lenny and Squeeze, CentOS, RHEL and Scientific Linux.

Note that if you already have Chef Solo installed on your nodes, you won’t need this. Also, if you previously installed Chef using the Gem procedure, please don’t use the deploy_chef package installation method. Installing Opscode’s packages on top of it could be a mess.

Cooking

Note: Don’t cook outside of a kitchen!

  • cook -l: Show a list of all available orders
  • cook node:MYNODE recipe:MYRECIPE: Cook a recipe on a particular node by giving its hostname or IP. nginx::source “subrecipes” are supported.
    Note that the first time this is run for a node, a configuration file will be created at nodes/myhostname.json. You can then edit this file to override recipe attributes, for example. Further runs of this command will not overwrite this configuration file.
    You can force the saving of the run with cook node:MYNODE recipe:MYRECIPE,save=True
  • cook node:MYNODE role:MYROLE: The same as above but role-based
  • cook node:MYNODE configure: Configures a particular pre-configured node
  • cook node:all configure: It will apply all roles, recipes and attributes defined for each and every node in nodes/
  • cook debug node:MYNODE configure: You can start all your commands with cook debug to see all Chef Solo debugging information

Once a node has a configfile, the command you will be using most often is cook node:MYNODE configure, which allows you to repeatedly tweak the recipes and attributes for a node and rerun the configuration.

Consulting the inventory

  • cook list_nodes: Lists all configured nodes, showing its associated recipes, roles and attributes
  • cook list_nodes_with_recipe:MYRECIPE: The same as above but it only lists nodes which have associated the recipe MYRECIPE
  • cook list_nodes_with_role:MYROLE: The same as above but it only lists nodes which have associated the role MYROLE
  • cook list_recipes: Lists all available recipes
  • cook list_recipes_detailed: Same as above, but shows description, version, dependencies and attributes
  • cook list_roles: Lists all available roles
  • cook list_roles_detailed: Same as above, but shows description and attributes

Using Little Chef as a library

You can import littlechef.py into your own Python project. The following script is equivalent to using the cook orders:

import littlechef
littlechef.env.user = 'MyUsername'
littlechef.env.password = 'MyPassword'
littlechef.env.host_string = 'MyHostnameOrIP'
littlechef.deploy_chef(gems='yes', ask='no')
littlechef.recipe('MYRECIPE')#Applies <MYRECIPE> to <MyHostnameOrIP>
littlechef.configure()#Applies again the saved nodes/MyHostnameOrIP.json configuration

Other tutorial material

Getting help

For help regarding the use of Little Chef, or to share any ideas or suggestions you may have, please post on Little Chef’s discussion group

Reporting bugs

If you find bugs please report it on https://github.com/tobami/littlechef/issues

Happy cooking!

Something went wrong with that request. Please try again.