Cook like a Chef

32
Cook like a Chef Who? Ian Yang From? Intridea Inc. When? December 20, 2011

description

Demonstrate how to use chef, the open source system integration framework.

Transcript of Cook like a Chef

Page 1: Cook like a Chef

Cook like a Chef

Who? Ian Yang

From? Intridea Inc.

When? December 20, 2011

Page 2: Cook like a Chef

Contents1 What is Chef

2 How Chef Works

3 How to Use Chef

4 Example

Page 3: Cook like a Chef

Outline1 What is Chef

2 How Chef Works

3 How to Use Chef

4 Example

Page 4: Cook like a Chef

What is Chefa person who cooksprofessionally

an open-source systemintegration framework thatcooks your serversprofessionally

Page 5: Cook like a Chef

What is Chef

an open-source systemintegration framework thatcooks your serversprofessionally

Page 6: Cook like a Chef

Figure: What is Chef from Chef Wiki

Page 7: Cook like a Chef

Outline1 What is Chef

2 How Chef Works

3 How to Use Chef

4 Example

Page 9: Cook like a Chef

Components

chef Gem of client/solo run-timeand CLI tools.

chef-server Gem of server run-timeChef Repo Blank repo templateCommunity Cookbooks hosting site

Page 10: Cook like a Chef

Components

chef Gem of client/solo run-timeand CLI tools.

chef-server Gem of server run-time

Chef Repo Blank repo templateCommunity Cookbooks hosting site

Page 11: Cook like a Chef

Components

chef Gem of client/solo run-timeand CLI tools.

chef-server Gem of server run-timeChef Repo Blank repo template

Community Cookbooks hosting site

Page 12: Cook like a Chef

Components

chef Gem of client/solo run-timeand CLI tools.

chef-server Gem of server run-timeChef Repo Blank repo templateCommunity Cookbooks hosting site

Page 13: Cook like a Chef

Solo Workflow

1 Collect Node info (ohai)

2 Get Node configuration data3 Run specified Recipes with

Node info and configurationdata

Page 14: Cook like a Chef

Solo Workflow

1 Collect Node info (ohai)2 Get Node configuration data

3 Run specified Recipes withNode info and configurationdata

Page 15: Cook like a Chef

Solo Workflow

1 Collect Node info (ohai)2 Get Node configuration data3 Run specified Recipes with

Node info and configurationdata

Page 16: Cook like a Chef

Recipes

Recipes configuration steps byResources

Resources cross platform abstraction oftasks

Providers actually execute the Resources

Page 17: Cook like a Chef

Recipes

Recipes configuration steps byResources

Resources cross platform abstraction oftasks

Providers actually execute the Resources

Page 18: Cook like a Chef

Recipes

Recipes configuration steps byResources

Resources cross platform abstraction oftasks

Providers actually execute the Resources

Page 19: Cook like a Chef

Git Recipe1 case node[: platform] # node info

2 when "debian", "ubuntu"

3 # package is a resource

4 package "git -core"

5 else

6 package "git"

7 end

Page 20: Cook like a Chef

Outline1 What is Chef

2 How Chef Works

3 How to Use Chef

4 Example

Page 21: Cook like a Chef

Start from Chef Repo

1 gem install chef

2 gh clone opscode chef -repo

Page 22: Cook like a Chef

Read existingCookbooks

Figure: Opscode Community

http://community.opscode.com/

Page 23: Cook like a Chef

Cookbook

Definition Collection ofAttributes

RecipesFiles & TemplatesDefinitions & Providers

Page 24: Cook like a Chef

Cookbook

Definition Collection ofAttributesRecipes

Files & TemplatesDefinitions & Providers

Page 25: Cook like a Chef

Cookbook

Definition Collection ofAttributesRecipesFiles & Templates

Definitions & Providers

Page 26: Cook like a Chef

Cookbook

Definition Collection ofAttributesRecipesFiles & TemplatesDefinitions & Providers

Page 27: Cook like a Chef

Use knife

1 knife cookbook site search nginx

2 knife cookbook site install nginx

3 knife cookbook site download nginx

http://wiki.opscode.com/

display/chef/Cookbook+Site+Help

Page 28: Cook like a Chef

Wait... knife throwserrors

Create a knife config in chefrepoFollow gist 1501318

Page 29: Cook like a Chef

Try Chef usingchef-solo

1 chef -solo -c config -file -j configuration -data

.json

Page 30: Cook like a Chef

json sample1 {

2 "rbenv": {

3 "rubies": ["1.9.2- p290"],

4 "gems": ["bundler"]

5 },

6 "run_list": ["recipe[rbenv]",

7 "recipe[nodejs]"]

8 }

Page 31: Cook like a Chef

Outline1 What is Chef

2 How Chef Works

3 How to Use Chef

4 Example

Page 32: Cook like a Chef

cnintridea preview

Provision vbox using vagrantInstall git, rbenv, ruby, bundlerInstall and config nginxDaemonize and monit rakewatch