cooking an omelette with chef

Post on 06-May-2015

463 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

A talk given at Rails Israel about getting value with Chef at your enterprise while minimizing the common errors that people make.

TRANSCRIPT

Cooking an Omelette with Chef

Case Taintor

Wednesday, October 9, 13

Survey

• Who has been manually configuring their machines?

• Who has been using a tool like Chef or Puppet?

• Who is an expert in Chef?

Wednesday, October 9, 13

Purpose

Wednesday, October 9, 13

Wednesday, October 9, 13

How did we work?

Wednesday, October 9, 13

Wednesday, October 9, 13

Infrastructure as Code

Wednesday, October 9, 13

Wednesday, October 9, 13

Wednesday, October 9, 13

Wednesday, October 9, 13

Wednesday, October 9, 13

Wednesday, October 9, 13

Wednesday, October 9, 13

Where do we start?

Wednesday, October 9, 13

Priorities

• Reproducibility

• Testability

• Traceability

• Keep It Simple, Stupid

Wednesday, October 9, 13

How does Chef work?

• Figures out which instructions to run

• Runs them in an idempotent way

Wednesday, October 9, 13

Cookbook

Everything to install & configure a component

Wednesday, October 9, 13

Cookbooks

attributesdefinitionsfileslibrariesprovidersrecipesresourcestemplates

attributesdefinitionsfileslibrariesprovidersrecipesresourcestemplatesmetadata.rb

$ ls -1 cookbook

Wednesday, October 9, 13

Cookbooks

attributesdefinitionsfileslibrariesprovidersrecipesresourcestemplatesmetadata.rb

$ ls -1 cookbook

Wednesday, October 9, 13

nginx cookbook

attributesdefinitionsfileslibrariesprovidersrecipesresourcestemplates

attributesattributes/default.rbattributes/source.rbdefinitionsfilesrecipesrecipes/default.rbrecipes/source.rbtemplatesmetadata.rb

$ ls -1 nginx

Wednesday, October 9, 13

Then What?

Wednesday, October 9, 13

run_list

{ ... "run_list": [ "recipe[rvm::system]", "recipe[nginx]", "recipe[user]" ] ...}

Wednesday, October 9, 13

How do I run Chef?

node1

chef-solo

all config

node2

chef-solo

all config

chef-solo

node1

chef-client

config

node2

chef-client

config

chef-server

chef-server

config

Wednesday, October 9, 13

Problems

Problem Solution

RepeatabilityReproducibilityIdempotence

Chef

Wednesday, October 9, 13

Problems

Problem Solution

RepeatabilityReproducibilityIdempotence

Chef

Versioning

Wednesday, October 9, 13

default rvm

default['rvm']['default_ruby'] = "ruby-1.9.3-p327"default['rvm']['rubies'] = []default[‘rvm][‘version’] = “head”

rvm/attributes/default.rb

Wednesday, October 9, 13

BerkshelfWednesday, October 9, 13

Problems

Problem Solution

RepeatabilityReproducibilityIdempotence

Chef

Versioning Berkshelf

Wednesday, October 9, 13

Problems

Problem Solution

RepeatabilityReproducibilityIdempotence

Chef

Versioning Berkshelf

Development

Wednesday, October 9, 13

Wednesday, October 9, 13

Problems

Problem Solution

RepeatabilityReproducibilityIdempotence

Chef

Versioning Berkshelf

Development Vagrant + VirtualBox

Wednesday, October 9, 13

Problems

Problem Solution

RepeatabilityReproducibilityIdempotence

Chef

Versioning Berkshelf

Development Vagrant + VirtualBox

KISS

Wednesday, October 9, 13

GusteauWednesday, October 9, 13

Problems

Problem Solution

RepeatabilityReproducibilityIdempotence

Chef

Versioning Berkshelf

Development Vagrant + VirtualBox

KISS Gusteau

Wednesday, October 9, 13

omelette-server• rvm • nginx • users

Wednesday, October 9, 13

Process

$ gusteau init omelette-cooker

Wednesday, October 9, 13

Berksfile

site :opscode

cookbook 'rvm', :github => 'fnichol/chef-rvm'cookbook 'nginx'cookbook 'user'

Wednesday, October 9, 13

.gusteau.yml

...environments: development: nodes: web: run_list: - recipe[rvm::system] - recipe[nginx] - recipe[user::data_bag] ...

Wednesday, October 9, 13

$ vagrant up development-web

$ gusteau converge development-web

Wednesday, October 9, 13

Wednesday, October 9, 13

Next Problems

Wednesday, October 9, 13

Share your stuff

• Inside your organization

• Outside your organization

Wednesday, October 9, 13

default rvm

default['rvm']['default_ruby'] = "ruby-1.9.3-p327"default['rvm']['rubies'] = []default[‘rvm][‘version’] = “head”

rvm/attributes/default.rb

Wednesday, October 9, 13

your rvm modifications

default['rvm']['default_ruby'] = "ruby-1.9.3-p448"default['rvm']['rubies'] = ["ruby-1.9.3-p448", "ruby-1.9.3-p327"]default[‘rvm][‘version’] = "1.21.4"

rvm/attributes/default.rb

Wednesday, October 9, 13

Wrapper Cookbooks

$ knife cookbook create wrapper-rvm -o site-cookbooks

normal[:rvm][:default_ruby] = "ruby-1.9.3-p448"normal[:rvm][:rubies] = ["ruby-1.9.3-p448", "ruby-1.9.3-p327"]normal[:rvm][:version] = "1.21.4"

include_recipe "rvm::system"

site-cookbooks/wrapper-rvm/attributes/default.rb

site-cookbooks/wrapper-rvm/recipes/default.rb

Wednesday, October 9, 13

Wrapper Cookbooks

place dependencies in metadata.rb

depends ‘rvm’, ‘0.9.1’

site-cookbooks/wrapper-rvm/metadata.rb

Wednesday, October 9, 13

.gusteau.yml

...environments: development: nodes: web: run_list: - recipe[wrapper-rvm] - recipe[nginx] - recipe[user::data_bag] ...

Wednesday, October 9, 13

$ vagrant up development-web

$ gusteau converge development-web

Wednesday, October 9, 13

Share

Wednesday, October 9, 13

Berksfile

site :opscode

cookbook 'rvm', :github => 'fnichol/chef-rvm'cookbook 'nginx'cookbook 'user'cookbook ‘wrapper-rvm’, :git => ‘...:wrapper-rvm.git, :branch => ‘0.1.0’

Wednesday, October 9, 13

Next Steps

• Sharing common setups

• Cookbook development

• Move to Chef Server

Wednesday, October 9, 13

Wrap Up

• Recognize what you want

• Use tools

• Iterate

Wednesday, October 9, 13

Questions?

More Info: @ctaintorWednesday, October 9, 13

Image References

Danley, Brent. "Crowded Beach." Flickr. Yahoo!, n.d. Web. 05 Oct. 2013. <http://www.flickr.com/photos/brentdanley/1086226020/>.

Goehring, David. "Does Not Work." Flickr. Yahoo!, n.d. Web. 04 Oct. 2013. <http://www.flickr.com/photos/carbonnyc/496721450/>.

Harber, Chris. "Food I Made 1." Flickr. Yahoo!, n.d. Web. 07 Oct. 2013. <http://www.flickr.com/photos/britishchris/4437265186/>.

Johnson, Darren. "Koh Ngai." Flickr. ShotHotspot.com, n.d. Web. 04 Oct. 2013. <http://www.flickr.com/photos/dazjohnson/7424536244/>.

Komulainen, Tommi. "Handlebar Is No More." Flickr. Yahoo!, n.d. Web. 05 Oct. 2013. <http://www.flickr.com/photos/tommikomulainen/137069098/>.

Reck, Bob. "My Motorcycle." Flickr. Yahoo!, n.d. Web. 05 Oct. 2013. <http://www.flickr.com/photos/u2sockmonkey/116641053/>.Used with permission.

Wednesday, October 9, 13

top related