Playing With Cookbooks, Recipes and Knives

Posted by Curtis Miller | 0 comments

Elon Flegenheimer of EMF Consulting LLC is a full time Ruby developer who's been using Chef for over a year. He's a little camera shy, so instead of a video, here's an overview of his presentation.

Chef Presentation

Slide 1

  • Open source sytems integration framework
  • Built with Ruby
  • Opscode is the company behind Chef
  • Runs solo, client/server, or a couple of other choices.

Slide 2

  • Why Chef?
  • Stick with Ruby
  • Automation reduces sys admin errors now and when you repeat it in 6 mos
  • Platform independent
  • Be a source of documentation

Slide 3

  • Chef Server
  • A web service with config data
  • Searchable - command line and recipes
  • A place to put things that is accessible to all of your machines

Terminology

Node - Run list of recipes or roles 

Attributes - Roles Consist of attributees and a run list 

Cookbooks - Collection of things. Ex: nginx, mysql 

Lots of publicly available cookbooks 

  • 37signals
  • EngineYard 
  • Write your own or use another, mix and match - but some dependencies makes mix and match bad

Recipes
level down in cookbook
define what happens in cookbook
use chef's dsl to configure a node
uise resources which use providers

Resources
cross platform abstractions of something

Provider
platform specific implementation of a resource
Focus on resources, not providers

Search
Allows you to query the data in the chef server
Knife uses search

databags
global data built around a cookbook

environments
one way to segment run list

Knife
Command line tool

Slide 4

  • Chef solo with VM
  • Bootstrap Chef
  • install ruby, ruby gems and chef
  • Config solo.rb
  • where is the cache
  • where are the cookbooks 
  • stored node.json
  • what we're going to run on this node
  • Cookbooks
  • Some way to upload the above

Slide 5

  • How does client server work
  • Chef client registers the node with Chef server
  • Synces server cookbooks to client
  • Node compiles and executes cookbooks
  • Chef client checks back in at regular interval (customizable)

Like Ruby code, there's code that defines what happens before you run code.
Most installations come with r-unit. Keeps it checking in every 30 minutes. runit allows you to set interval.

Coding Example

  • Execute bootstrap
  • knife node list
  • upload cookbooks
  • knife cookbook upload -a
  • Upload roles - rake roles
  • Upload application cookbook data bag
  • Edit node roles
  • Execute chef-client and test results

Questions

Q: Is there a management console or UI?
A: Yes. You can find it here: chef management console.

Q: Were there any other contenders when you first looked at using Chef
A: Compared Chef to Puppet

Q: observations on the community?
A: We had to do a lot of customization, but we haven't had to do anything from scratch.

Q: How about automated testing of recipes?
A: That's tricky. I recently did testing on a different server, outside of staging or dev server.

Q: Does Chef have support for environments?
A: Yes, that was a change from Chef 9 to 10. 

Q: Have you run into problems with hosting
A: We had some downtime once for about 3 hours. Cookbooks are hosted at Amazon S3. Management console is hosted on a local server at Opscode datacenter. So you are kinda tied in to their servers unless you choose to self-host, which has its own problems.

Q: How does Opscode make their money?
A: Chef server has free account, 2 users, up to 5 nodes. Then they have a tiered pricing plan. They also have a private server versus the hosted one. That's a flat fee that comes with support and allows for greater control of your server.

0 Comments

Leave a Reply

Leave a Reply

Send comment