chef, devops, and you

39
Chef, Devops, and You Image from http://dev2ops.org/blog/2010/2/22/what-is- Bryan W. Berry, 18 November 2011

Upload: bryan-berry

Post on 07-May-2015

11.929 views

Category:

Technology


8 download

DESCRIPTION

An introduction and tutorial for Chef, a configuration management tool

TRANSCRIPT

Page 1: Chef, Devops, and You

Chef, Devops, and You

Image from http://dev2ops.org/blog/2010/2/22/what-is-devops.htmlBryan W. Berry, 18 November 2011

Page 2: Chef, Devops, and You

Who am I?

•Linux Geek for 7 years

•Python, Ruby coder

•Played with a lot of different configuration management tools and techniques

Page 3: Chef, Devops, and You

We need a new way to work

Infrastructure needs to beRepeatableTestableScalable

No Snowflakes!

Page 4: Chef, Devops, and You

Devops?

1) Agile Development Practices applied to infrastructure

2) New tooling to automate infrastructure3) Testing, testing, testing

Page 5: Chef, Devops, and You

Infrastructure as Code

http://www.flickr.com/photos/wonderlane/2306082998/

Page 6: Chef, Devops, and You

Chef is . . .

A library for Configuration ManagementA Configuration Management SystemA Systems Integration PlatformAn API for your entire infrastructure

Open-source!

Page 7: Chef, Devops, and You

How Chef works

Chef Server

PRODQADEV

Workstation VM

Cookbooks

Data Bags

Attributes

Page 8: Chef, Devops, and You

DEV, QA, PROD ServersSupposed to have the same

configuration

Is this humanly possible without Chef?I don’t think so

PRODQADEV == ==

Page 9: Chef, Devops, and You

Chef client runs on each Server

They talk to the Chef Server

Chef can also run without a server, chef-solo

Page 10: Chef, Devops, and You

We call each system you configure a Node

Page 11: Chef, Devops, and You
Page 12: Chef, Devops, and You

Attributes are Searchable

$ knife search node ‘jdk_version:1.7’# returns list of nodes with jdk 1.7

search(:node, ‘java_version:1.7’)

Page 13: Chef, Devops, and You

Nodes have run_list

“run_list”: {“recipe[java]”,

“recipe[jboss]”, “role[internal]”}

Page 14: Chef, Devops, and You

Nodes have Roles

Roles describe what a node should be

Page 15: Chef, Devops, and You

Roles are Searchable

$ knife search role ‘max_children:50’

search(:role, ‘max_children:50’)

Page 16: Chef, Devops, and You

Roles have a run_list

What roles or recipes to apply in order

Page 17: Chef, Devops, and You

Chef manages resources on nodes

Resources are specified in recipes, recipes are stored in cookbooks

A node’s run_list specifies which recipes(and thus resources) are applied

Page 18: Chef, Devops, and You
Page 19: Chef, Devops, and You

Client / Server

Chef Server

PRODQADEV

Nodes

Nodes report their attributes to the Chef-server with the ‘Node’ object

attributes

Chef Repository

Page 20: Chef, Devops, and You

Chef Server

PRODQADEV

Nodes

Server applies rolesand sends run_list, roles, and all cookbooksback to clients

run_list,roles,cookbooks

Chef Repository

Page 21: Chef, Devops, and You

Skinny Server, Fat Clients

No “builds” are done on the server

A Node configures itself based on its run_list and the

downloaded cookbooks

Page 22: Chef, Devops, and You

Back to Recipes!

Page 23: Chef, Devops, and You
Page 24: Chef, Devops, and You
Page 25: Chef, Devops, and You

Ruby, baby!

Chef configuration written in pure rubyDevops == Ruby

If you also learn Ruby, it will be helpful but is not requiredIf you are really curious why devops == Ruby, you read more here http://devopsanywhere.blogspot.com/2011/09/how-ruby-is-beating-python-in-battle.html

Page 26: Chef, Devops, and You

Cookbooks are packages for Recipes

Page 27: Chef, Devops, and You

Cookbook Components

AttributesRecipesMetadataAssets (files/templates)

Page 28: Chef, Devops, and You

Sharing is beautiful

200+ high-quality cookbooks on community.opscode.comand growing all the time

Easy to customize existing cookbooks

Chef’s real value is this collection of cookbooks

Page 29: Chef, Devops, and You

Data Bags

Data Bags are arbitrary stores of globally available JSON data

Think of them as global variables/data sctructures

for your infrastructure

Page 30: Chef, Devops, and You

Data Bags have Items

Data bag users/john{ "comment": “postgres Rul3z", "groups": [“"sysadmins", "postgres" ], "ssh_keys": "ssh-rsa …..", "id": “john", "shell": "/bin/bash"}

Page 31: Chef, Devops, and You

Data Bags are Searchable!

pg_users = search(:users, “groups:postgres”)

group “postgres” domembers pg_users

end

Page 32: Chef, Devops, and You

Code/data Split

Recipes

Templates

Attributes

Data Bags

Node Object Role

Cookbook

run_list

Node Object

Role

Environments

The fact that attributes are in cookbooks, roles, environments, And the node itself can be confusing

Page 33: Chef, Devops, and You

tl;dr How do I get Started?

Do the Quick start using hosted chef, free for 5 nodes

http://wiki.opscode.com/display/chef/Quick+Start

You can use Ubuntu, Mac OS X, and maybe Windows

Page 34: Chef, Devops, and You

Possible Corporate Setup

PROD-Chef Server

PRODQADEV

DEV-Chef Server

BarFoo

Dev Playground:Devs have full accessTo chef-server

Disposable nodes fortestingcookbooks

Only sysadminsHave chef access

Page 35: Chef, Devops, and You

Tools

•Chef web interface – Pretty!•Ohai – collects information about node•Knife – command-line tool•Shef – interpreter for working with cookbooks•git - not part of chef, but hard to use chef without also using git

Page 36: Chef, Devops, and You

A Very Simple Recipe

Page 37: Chef, Devops, and You

This should look familiar

Page 38: Chef, Devops, and You

How we can use Chef

•Sysadmins write cookbooks and maintain chef-server•Devs can also write cookbooks to help the sysadmin•Store of configuration information

Sysadmins will spend more time managing configurations and less time

managing individual servers

Page 39: Chef, Devops, and You

Questions?

Bryan Berry skype: berrdawg [email protected]

Portions of this presentations were taken liberally from Joshua Timberman’s Chef 101 presentation

Copyright Bryan W. Berry 2011Creative Commons 3.0 Unported CC-BY-SA