With LittleChef you will be able to get started more quickly cooking with Chef, the excellent Configuration Management System.
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.
In a working deployment directory, the kitchen, there is:
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. You should put this under version control.
roles/: Where 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.
- Python 2.6+
- Fabric 0.9.1
All needed packages are installed by typing
sudo apt-get install python-pip python-fabric for Debian and Ubuntu
yum install python-pip fabric for RHEL and CentOS
You can install Little Chef directly from the PyPI:
pip install littlechef
Note: your distribution may have a package that also provides a
cook executable. If you have installed it, you need to remove it to avoid collisions with LittleChef’s executable.
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.
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.
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.
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:all configure: It will apply all roles, recipes and attributes defined in
nodes/MYNODE.jsonto ALL nodes present in
cook node:MYNODE configure: Configures a particular pre-configured node
cook debug node:MYNODE configure: You can start all your commands with
cook debugto 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.
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
cook list_nodes_with_role:MYROLE: The same as above but it only lists nodes which have associated the role
cook list_recipes: Lists all available recipes
cook list_recipes_detailed: Lists all available recipes, with associated information
cook list_roles: Lists all available roles, with associated information
You can import littlechef.py into your own Python project. The following script is equivalent to using the
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') littlechef.configure()
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
If you find any bug in Little Chef please report it on https://github.com/tobami/littlechef/issues