Giter Site home page Giter Site logo

littlechef's Introduction

LitteChef

With LittleChef you will be able to get started more quickly cooking with Chef, the excelent 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

In a working deployment directory, the kitchen, there is:
auth.cfg: Authentication information is neede 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/ directoy. 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 0.9.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

Installation

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.

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 to enter a username and password.

Deploy

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 appropiate 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

Another option is to install ruby 1.9.1 and deploy chef through the integrated gems 1.9.1:
@cook node:MYNODE deploy_chef:ruby_191=yes

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.

Cook

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.json to ALL nodes present in nodes/
  • cook node:MYNODE configure: Configures a particular pre-configured node
  • cook debug node:MYNODE configure: You can start all your commands with cook debug to see all Chef Solo debbuging 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, with associated information
  • cook list_roles: Lists all available roles, with associated information

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')
littlechef.configure()

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 any bug in Little Chef please report it on https://github.com/tobami/littlechef/issues

Happy cooking!

littlechef's People

Contributors

oldpatricka avatar tobami avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.