SlideShare a Scribd company logo
1 of 87
Download to read offline
Chef Fundamentals
training@getchef.com
Copyright (C) 2014 Chef Software, Inc.
Nathen Harvey
• Community Director
• Co-host of the Food Fight Show Podcast
• @nathenharvey
Webinar Objectives and Style
3
Multi-week Webinar Series
• After completing of this webinar series you will be
able to
• Automate common infrastructure tasks with Chef
• Describe Chef’s architecture
• Describe Chef’s various tools
• Apply Chef’s primitives to solve your problems
How to learn Chef
• You bring the domain expertise about your business
and infrastructure
• Chef provides a framework for automating your
infrastructure
• Our job is to work together to teach you how to
model and automate your infrastructure with Chef
Chef is a Language
• Learning Chef is like learning the basics of a
language
• 80% fluency will be reached very quickly
• The remaining 20% just takes practice
• The best way to learn Chef is to use Chef
Questions & Answers
• Ask questions in the chat
window when they come to
you
• We’ll answer as many
questions as we can at the
end of the session
Slides and Video
• This webinar is being recorded. The video will be
made available shortly after the session has ended.
• The slides used throughout this webinar will be
made available at the end of each webinar.
• Watch http://learnchef.com for updates.
Agenda
9
Topics
• Overview of Chef
• Workstation Setup
• Node Setup - Today
• Chef Resources and Recipes - Today
• Working with the Node object
• Common configuration with Data Bags
• Roles and Environments
• Community Cookbooks and Further Resources
Node Setup
Setup a Node to manage
11
Lesson Objectives
• After completing the lesson, you will be able to
• Login to the node in your Chef Training Lab
• Install Chef nodes using "knife bootstrap"
• Explain how knife bootstrap configures a node to
use the Organization created in the previous
section
• Explain the basic configuration needed to run chef-
client
12
Chef Infrastructure
Launch Chef Training Lab
14
Nodes
15
Nodes
• Nodes represent the servers in your infrastructure
these may be
• Physical or virtual servers
• Hardware that you own
• Compute instances in a public or private cloud
16
We Have No Nodes Yet
17
$ ssh root@<EXTERNAL_ADDRESS>
Lab - Login
The authenticity of host 'uvo1qrwls0jdgs3blvt.vm.cld.sr
(69.195.232.110)' can't be established.
RSA key fingerprint is d9:95:a3:b9:02:27:e9:cd:
74:e4:a2:34:23:f5:a6:8b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'uvo1qrwls0jdgs3blvt.vm.cld.sr,
69.195.232.110' (RSA) to the list of known hosts.
chef@uvo1qrwls0jdgs3blvt.vm.cld.sr's password:
Last login: Mon Jan 6 16:26:24 2014 from
host86-145-117-53.range86-145.btcentralplus.com
[chef@CentOS63 ~]$
18
Checkpoint
• At this point you should have
• One virtual machine (VM) or server that you’ll use
for the lab exercises
• The IP address or public hostname
• An application for establishing an ssh connection
• 'sudo' or 'root' permissions on the VM
19
Chef Infrastructure
$ knife bootstrap <EXTERNAL_ADDRESS> -x chef -P chef -N "module2"
"Bootstrap" the Target Instance
Bootstrapping Chef on uvo1qrwls0jdgs3blvt.vm.cld.sr
...
...
uvo1qrwls0jdgs3blvt.vm.cld.sr Creating a new client identity for
module2 using the validator key.
uvo1qrwls0jdgs3blvt.vm.cld.sr resolving cookbooks for run list: []
uvo1qrwls0jdgs3blvt.vm.cld.sr Synchronizing Cookbooks:
uvo1qrwls0jdgs3blvt.vm.cld.sr Compiling Cookbooks...
uvo1qrwls0jdgs3blvt.vm.cld.sr [2014-01-28T11:03:14-05:00] WARN: Node
node2 has an empty run list.
uvo1qrwls0jdgs3blvt.vm.cld.sr Converging 0 resources
uvo1qrwls0jdgs3blvt.vm.cld.sr Chef Client finished, 0 resources updated
21
Node
knife bootstrap
22
Workstation
Chef
Server
Node
knife bootstrap
23
Workstation
knife bootstrap HOSTNAME -x root -P PASSWORD -N module2
Chef
Server
Node
knife bootstrap
24
Workstation
knife bootstrap HOSTNAME -x root -P PASSWORD -N module2
ssh/scp
chef_server_url
validation_client_name
validation_client_key
Chef
Server
Node
knife bootstrap
25
Workstation
knife bootstrap HOSTNAME -x root -P PASSWORD -N module2
ssh/scp
chef_server_url
validation_client_name
validation_client_key
install chef-client
configure chef-client
run chef-client
Chef
Server
Node
knife bootstrap
26
Workstation
knife bootstrap HOSTNAME -x root -P PASSWORD -N module2
ssh/scp
chef_server_url
validation_client_name
validation_client_key
register node
save node details
install chef-client
configure chef-client
run chef-client
Chef
Server
Node
knife bootstrap
27
Workstation
knife bootstrap HOSTNAME -x root -P PASSWORD -N module2
ssh/scp
chef_server_url
validation_client_name
validation_client_key
register node
save node details
install chef-client
configure chef-client
run chef-client
Chef
Server
Node
knife bootstrap
28
Workstation
knife bootstrap HOSTNAME -x root -P PASSWORD -N module2
ssh/scp
chef_server_url
validation_client_name
validation_client_key
register node
save node details
install chef-client
configure chef-client
run chef-client
Chef
Server
Verify Your Target Instance’s Chef-Client is Configured Properly
$ ssh root@<EXTERNAL_ADDRESS>
root@CentOS63:~$ ls /etc/chef
client.pem client.rb first-boot.json validation.pem
root@CentOS63:~$ which chef-client
/usr/bin/chef-client
29
View Node on Chef Server
• Click the 'Details' tab
View Node on Chef Server
31
• Click the 'Attributes' tab
Node
• The node is registered with Chef Server
• The Chef Server displays information about the node
• This information comes from Ohai - we'll see Ohai
later.....
32
Checkpoint
Chef Resources and Recipes
Writing an Apache cookbook
34
Lesson Objectives
• After completing the lesson, you will be able to
• Describe in detail what a cookbook is
• Create a new cookbook
• Explain what a recipe is
• Describe how to use the package, service, and template
resources
• Upload a cookbook to the Chef Server
• Explain what a run list is, and how to set it for a node via
knife
• Explain the output of a chef-client run
35
What is a cookbook?
• A cookbook is like a “package” for Chef recipes.
• It contains all the recipes, files, templates, libraries,
etc. required to configure a portion of your
infrastructure
• Typically they map 1:1 to a piece of software or
functionality.
36
The Problem and the Success Criteria
• The Problem: We need a web server configured to
serve up our home page.
• Success Criteria: We can see the homepage in a
web browser.
37
Desired state: our policy
• Apache web server should be installed
• Apache should be running and configured to start when
the machine boots
• Our home page should be displayed
• Please note in this course we're teaching Chef
primitives, not web server management
• This is probably not the Apache HTTP server
configuration you would use in production
38
$ knife cookbook create apache
Exercise: Create a new Cookbook
** Creating cookbook apache
** Creating README for cookbook: apache
** Creating CHANGELOG for cookbook: apache
** Creating metadata for cookbook: apache
39
$ ls -la cookbooks/apache
Exercise: Explore the cookbook
total 24
drwxr-xr-x 13 opscode opscode 442 Jan 24 21:25 .
drwxr-xr-x 5 opscode opscode 170 Jan 24 21:25 ..
-rw-r--r-- 1 opscode opscode 412 Jan 24 21:25 CHANGELOG.md
-rw-r--r-- 1 opscode opscode 1447 Jan 24 21:25 README.md
drwxr-xr-x 2 opscode opscode 68 Jan 24 21:25 attributes
drwxr-xr-x 2 opscode opscode 68 Jan 24 21:25 definitions
drwxr-xr-x 3 opscode opscode 102 Jan 24 21:25 files
drwxr-xr-x 2 opscode opscode 68 Jan 24 21:25 libraries
-rw-r--r-- 1 opscode opscode 276 Jan 24 21:25 metadata.rb
drwxr-xr-x 2 opscode opscode 68 Jan 24 21:25 providers
drwxr-xr-x 3 opscode opscode 102 Jan 24 21:25 recipes
drwxr-xr-x 2 opscode opscode 68 Jan 24 21:25 resources
drwxr-xr-x 3 opscode opscode 102 Jan 24 21:25 templates
40
Exercise: Open a project drawer if you're using Sublime Text
• If you're using Sublime, then File>Open the chef-repo
directory you created earlier
41
Access the
cookbook files
from the left
menu
OPEN IN EDITOR: cookbooks/apache/recipes/default.rb
#
# Cookbook Name:: apache
# Recipe:: default
#
# Copyright 2013, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
Exercise: Edit the default recipe
42
SAVE FILE!
#
# Cookbook Name:: apache
# Recipe:: default
#
# Copyright 2013, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
package "httpd" do
action :install
end
Exercise: Add a package resource to install Apache to the default
recipe
OPEN IN EDITOR: cookbooks/apache/recipes/default.rb
43
package "httpd" do
action :install
end
So the resource we just wrote...
44
package "httpd" do
action :install
end
So the resource we just wrote...
• Is a package resource
45
package "httpd" do
action :install
end
So the resource we just wrote...
• Is a package resource
• Whose name is httpd
46
package "httpd" do
action :install
end
So the resource we just wrote...
• Is a package resource
• Whose name is httpd
• With an install action
47
Notice we didn’t say how to install the package
• Resources are declarative - that means we say what
we want to have happen, rather than how
• Resources take action through Providers - providers
perform the how
• Chef uses the platform the node is running to
determine the correct provider for a resource
48
Package Resource
package "git"
{
yum install git
apt-get install git
pacman sync git
pkg_add -r git
Providers aredetermined
by node's platform
49
SAVE FILE!
...
# All rights reserved - Do Not Redistribute
#
package "httpd" do
action :install
end
service "httpd" do
action [ :enable, :start ]
end
Exercise: Add a service resource to ensure the service is started
and enabled at boot
OPEN IN EDITOR: cookbooks/apache/recipes/default.rb
50
service "httpd" do
action [ :enable, :start ]
end
So the resource we just wrote...
51
service "httpd" do
action [ :enable, :start ]
end
So the resource we just wrote...
• Is a service resource
52
service "httpd" do
action [ :enable, :start ]
end
So the resource we just wrote...
• Is a service resource
• Whose name is httpd
53
service "httpd" do
action [ :enable, :start ]
end
So the resource we just wrote...
• Is a service resource
• Whose name is httpd
• With two actions:
• enable
• start
54
• Body Level One
• Body Level Two
• Body Level Three
• Body Level Four
• Body Level Five
Order Matters
package "haproxy" do
action :install
end
template "/etc/haproxy/haproxy.cfg" do
source "haproxy.cfg.erb"
owner "root"
group "root"
mode "0644"
notifies :restart, "service[haproxy]"
end
service "haproxy" do
supports :restart => :true
action [:enable, :start]
end
• Resources are
executed in order
1st
2nd
3rd
55
SAVE FILE!
...
service "httpd" do
action [ :enable, :start ]
end
template "/var/www/html/index.html" do
source "index.html.erb"
mode "0644"
end
Exercise: Add a cookbook_file resource to copy the home page in
place
OPEN IN EDITOR: cookbooks/apache/recipes/default.rb
56
So the resource we just wrote...
template "/var/www/html/index.html" do
source "index.html.erb"
mode "0644"
end
57
So the resource we just wrote...
• Is a template resource
template "/var/www/html/index.html" do
source "index.html.erb"
mode "0644"
end
58
So the resource we just wrote...
• Is a template resource
• Whose name is:
/var/www/html/index.html
template "/var/www/html/index.html" do
source "index.html.erb"
mode "0644"
end
59
So the resource we just wrote...
• Is a template resource
• Whose name is:
/var/www/html/index.html
• With two parameters:
• source of
index.html.erb
• mode of “0644”
template "/var/www/html/index.html" do
source "index.html.erb"
mode "0644"
end
60
Full contents of the apache recipe
#
# Cookbook Name:: apache
# Recipe:: default
#
# Copyright 2013, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
package "httpd" do
action :install
end
service "httpd" do
action [ :enable, :start ]
end
template "/var/www/html/index.html" do
source "index.html.erb"
mode "0644"
end
61
OPEN IN EDITOR:
SAVE FILE!
cookbooks/apache/templates/default/index.html.erb
<h1>Hello, world!</h1>
Exercise: Add index.html to your cookbook’s files/default directory
62
$ knife cookbook upload apache
Exercise: Upload the cookbook
Uploading apache [0.1.0]
Uploaded 1 cookbook.
63
Upload a cookbook
knife cookbook upload apache
Upload a cookbook
knife cookbook upload apache
Upload a cookbook
knife cookbook upload apache
Upload a cookbook
knife cookbook upload apache
The Run List
• The Run List is the ordered set of recipes and roles
that the Chef Client will execute on a node
• Recipes are specified by “recipe[name]”
68
$ knife node run_list add module2 "recipe[apache]"
Exercise: Add apache recipe to test node’s run list
module2:
run_list: recipe[apache]
69
Upload a cookbook
knife node run_list add module2 “recipe[apache]”
Upload a cookbook
knife node run_list add module2 “recipe[apache]”
recipe[apache]
Upload a cookbook
knife node run_list add module2 “recipe[apache]”
recipe[apache]
Upload a cookbook
knife node run_list add module2 “recipe[apache]”
recipe[apache]
Upload a cookbook
knife node run_list add module2 “recipe[apache]”
root@CentOS63:~$ sudo chef-client
Exercise: Run Chef Client
Starting Chef Client, version 11.10.4
resolving cookbooks for run list: ["apache"]
Synchronizing Cookbooks:
- apache
Compiling Cookbooks...
Converging 3 resources
Recipe: apache::default
* package[httpd] action install
- install version 2.2.15-29.el6.centos of package httpd
* service[httpd] action enable
- enable service service[httpd]
* service[httpd] action start
- start service service[httpd]
* template[/var/www/html/index.html] action create
- create new file /var/www/html/index.html
- update content in file /var/www/html/index.html from none to 17d291
75
Exercise: Verify that the home page works
• Open a web browser
• Type in the the URL for your test node
76
Congratulate yourself!
• You have just written your first Chef cookbook!
• (clap!)
77
Run List
Node
Enterprise
Chef chef-client
What policy should I follow?
78
Run List
Node
Enterprise
Chef chef-client
What policy should I follow?
"recipe[apache]"
79
Run List
Node
Enterprise
Chef chef-client
What policy should I follow?
"recipe[apache]"
80
Run List
Enterprise
Chef chef-client
What policy should I follow?
"recipe[apache]"
81
Run List
Enterprise
Chef chef-client
What policy should I follow?
"recipe[apache]"
82
Chef Fundamentals
Webinar Series
Six Week Series
• Module 1 - Overview of Chef
• Today - Node Setup, Chef Resources & Recipes
• June 3 - Working with the Node object
• June 10 - Common configuration data with Databags
• June 17 - Using Roles and Environments
• June 24 - Community Cookbooks and Further Resources
• * Topics subject to change, schedule unlikely to change
Sign-up for Webinar
• http://pages.getchef.com/
cheffundamentalsseries.html
Additional Resources
• Chef Fundamentals Webinar Series
• https://www.youtube.com/watch?
v=S5lHUpzoCYo&list=PL11cZfNdwNyPnZA9D1MbVqldGuOWqbum
Z
• Discussion group for webinar participants
• https://groups.google.com/d/forum/learnchef-fundamentals-webinar
102
Additional Resources
• Learn Chef
• http://learnchef.com
• Documentation
• http://docs.opscode.com
103

More Related Content

What's hot

Opscode Webinar: Managing Your VMware Infrastructure with Chef
Opscode Webinar: Managing Your VMware Infrastructure with ChefOpscode Webinar: Managing Your VMware Infrastructure with Chef
Opscode Webinar: Managing Your VMware Infrastructure with ChefChef Software, Inc.
 
Automating Infrastructure with Chef
Automating Infrastructure with ChefAutomating Infrastructure with Chef
Automating Infrastructure with ChefJennifer Davis
 
Introduction to Chef - Techsuperwomen Summit
Introduction to Chef - Techsuperwomen SummitIntroduction to Chef - Techsuperwomen Summit
Introduction to Chef - Techsuperwomen SummitJennifer Davis
 
Introduction to Chef - April 22 2015
Introduction to Chef - April 22 2015Introduction to Chef - April 22 2015
Introduction to Chef - April 22 2015Jennifer Davis
 
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...Chef Software, Inc.
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to ChefKnoldus Inc.
 
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In CodeIntroduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In CodeJosh Padnick
 
Overview of Chef - Fundamentals Webinar Series Part 1
Overview of Chef - Fundamentals Webinar Series Part 1Overview of Chef - Fundamentals Webinar Series Part 1
Overview of Chef - Fundamentals Webinar Series Part 1Chef
 
Chef-Zero & Local Mode
Chef-Zero & Local ModeChef-Zero & Local Mode
Chef-Zero & Local ModeMichael Goetz
 
Compliance Automation Workshop
Compliance Automation WorkshopCompliance Automation Workshop
Compliance Automation WorkshopChef
 
Orchestration with Chef
Orchestration with ChefOrchestration with Chef
Orchestration with ChefMayank Gaikwad
 
Automating your infrastructure with Chef
Automating your infrastructure with ChefAutomating your infrastructure with Chef
Automating your infrastructure with ChefJohn Ewart
 
Chef, Devops, and You
Chef, Devops, and YouChef, Devops, and You
Chef, Devops, and YouBryan Berry
 
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...Edureka!
 
Chef Tutorial for DEVOPS Newbies
Chef Tutorial for DEVOPS NewbiesChef Tutorial for DEVOPS Newbies
Chef Tutorial for DEVOPS NewbiesMamun Rashid, CCDH
 

What's hot (20)

Opscode Webinar: Managing Your VMware Infrastructure with Chef
Opscode Webinar: Managing Your VMware Infrastructure with ChefOpscode Webinar: Managing Your VMware Infrastructure with Chef
Opscode Webinar: Managing Your VMware Infrastructure with Chef
 
Automating Infrastructure with Chef
Automating Infrastructure with ChefAutomating Infrastructure with Chef
Automating Infrastructure with Chef
 
Introduction to Chef - Techsuperwomen Summit
Introduction to Chef - Techsuperwomen SummitIntroduction to Chef - Techsuperwomen Summit
Introduction to Chef - Techsuperwomen Summit
 
Introduction to Chef - April 22 2015
Introduction to Chef - April 22 2015Introduction to Chef - April 22 2015
Introduction to Chef - April 22 2015
 
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In CodeIntroduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
 
Chef fundamentals
Chef fundamentalsChef fundamentals
Chef fundamentals
 
Overview of Chef - Fundamentals Webinar Series Part 1
Overview of Chef - Fundamentals Webinar Series Part 1Overview of Chef - Fundamentals Webinar Series Part 1
Overview of Chef - Fundamentals Webinar Series Part 1
 
Chef-Zero & Local Mode
Chef-Zero & Local ModeChef-Zero & Local Mode
Chef-Zero & Local Mode
 
Compliance Automation Workshop
Compliance Automation WorkshopCompliance Automation Workshop
Compliance Automation Workshop
 
Orchestration with Chef
Orchestration with ChefOrchestration with Chef
Orchestration with Chef
 
Automating your infrastructure with Chef
Automating your infrastructure with ChefAutomating your infrastructure with Chef
Automating your infrastructure with Chef
 
Chef, Devops, and You
Chef, Devops, and YouChef, Devops, and You
Chef, Devops, and You
 
Chef introduction
Chef introductionChef introduction
Chef introduction
 
The unintended benefits of Chef
The unintended benefits of ChefThe unintended benefits of Chef
The unintended benefits of Chef
 
Introduction to chef
Introduction to chefIntroduction to chef
Introduction to chef
 
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
 
Chef Tutorial for DEVOPS Newbies
Chef Tutorial for DEVOPS NewbiesChef Tutorial for DEVOPS Newbies
Chef Tutorial for DEVOPS Newbies
 
Understand Chef
Understand ChefUnderstand Chef
Understand Chef
 

Similar to Node setup, resource, and recipes - Fundamentals Webinar Series Part 2

Introduction To Continuous Compliance & Remediation
Introduction To Continuous Compliance & RemediationIntroduction To Continuous Compliance & Remediation
Introduction To Continuous Compliance & RemediationNicole Johnson
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefAll Things Open
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefNathen Harvey
 
Testing Your Automation Code (Vagrant Version)
Testing Your Automation Code (Vagrant Version)Testing Your Automation Code (Vagrant Version)
Testing Your Automation Code (Vagrant Version)Mischa Taylor
 
Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015Chef
 
Testing your-automation-code (vagrant version) v0.2
Testing your-automation-code (vagrant version) v0.2Testing your-automation-code (vagrant version) v0.2
Testing your-automation-code (vagrant version) v0.2Sylvain Tissot
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chefkevsmith
 
Testable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and DockerTestable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and DockerMandi Walls
 
How to Write Chef Cookbook
How to Write Chef CookbookHow to Write Chef Cookbook
How to Write Chef Cookbookdevopsjourney
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 
Effective Testing with Ansible and InSpec
Effective Testing with Ansible and InSpecEffective Testing with Ansible and InSpec
Effective Testing with Ansible and InSpecNathen Harvey
 
Azure handsonlab
Azure handsonlabAzure handsonlab
Azure handsonlabChef
 
AWS re:Invent 2016: Configuration Management in the Cloud (DEV305)
AWS re:Invent 2016: Configuration Management in the Cloud (DEV305)AWS re:Invent 2016: Configuration Management in the Cloud (DEV305)
AWS re:Invent 2016: Configuration Management in the Cloud (DEV305)Amazon Web Services
 
Cook Infrastructure with chef -- Justeat.IN
Cook Infrastructure with chef  -- Justeat.INCook Infrastructure with chef  -- Justeat.IN
Cook Infrastructure with chef -- Justeat.INRajesh Hegde
 

Similar to Node setup, resource, and recipes - Fundamentals Webinar Series Part 2 (20)

Introduction To Continuous Compliance & Remediation
Introduction To Continuous Compliance & RemediationIntroduction To Continuous Compliance & Remediation
Introduction To Continuous Compliance & Remediation
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to Chef
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to Chef
 
Testing Your Automation Code (Vagrant Version)
Testing Your Automation Code (Vagrant Version)Testing Your Automation Code (Vagrant Version)
Testing Your Automation Code (Vagrant Version)
 
Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015
 
Testing your-automation-code (vagrant version) v0.2
Testing your-automation-code (vagrant version) v0.2Testing your-automation-code (vagrant version) v0.2
Testing your-automation-code (vagrant version) v0.2
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
IT Automation with Chef
IT Automation with ChefIT Automation with Chef
IT Automation with Chef
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 
Testable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and DockerTestable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and Docker
 
The Environment Restaurant
The Environment RestaurantThe Environment Restaurant
The Environment Restaurant
 
How to Write Chef Cookbook
How to Write Chef CookbookHow to Write Chef Cookbook
How to Write Chef Cookbook
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
Effective Testing with Ansible and InSpec
Effective Testing with Ansible and InSpecEffective Testing with Ansible and InSpec
Effective Testing with Ansible and InSpec
 
Learning chef
Learning chefLearning chef
Learning chef
 
Azure handsonlab
Azure handsonlabAzure handsonlab
Azure handsonlab
 
Chef training Day4
Chef training Day4Chef training Day4
Chef training Day4
 
AWS re:Invent 2016: Configuration Management in the Cloud (DEV305)
AWS re:Invent 2016: Configuration Management in the Cloud (DEV305)AWS re:Invent 2016: Configuration Management in the Cloud (DEV305)
AWS re:Invent 2016: Configuration Management in the Cloud (DEV305)
 
Chef: Smart infrastructure automation
Chef: Smart infrastructure automationChef: Smart infrastructure automation
Chef: Smart infrastructure automation
 
Cook Infrastructure with chef -- Justeat.IN
Cook Infrastructure with chef  -- Justeat.INCook Infrastructure with chef  -- Justeat.IN
Cook Infrastructure with chef -- Justeat.IN
 

More from Chef

Habitat Managed Chef
Habitat Managed ChefHabitat Managed Chef
Habitat Managed ChefChef
 
Automation, Audits, and Apps Tour
Automation, Audits, and Apps TourAutomation, Audits, and Apps Tour
Automation, Audits, and Apps TourChef
 
Automation, Audits, and Apps Tour
Automation, Audits, and Apps TourAutomation, Audits, and Apps Tour
Automation, Audits, and Apps TourChef
 
London Community Summit 2016 - Adopting Chef Compliance
London Community Summit 2016 - Adopting Chef ComplianceLondon Community Summit 2016 - Adopting Chef Compliance
London Community Summit 2016 - Adopting Chef ComplianceChef
 
Learning from Configuration Management
Learning from Configuration Management Learning from Configuration Management
Learning from Configuration Management Chef
 
London Community Summit 2016 - Fresh New Chef Stuff
London Community Summit 2016 - Fresh New Chef StuffLondon Community Summit 2016 - Fresh New Chef Stuff
London Community Summit 2016 - Fresh New Chef StuffChef
 
London Community Summit - Chef at SkyBet
London Community Summit - Chef at SkyBetLondon Community Summit - Chef at SkyBet
London Community Summit - Chef at SkyBetChef
 
London Community Summit - From Contribution to Authorship
London Community Summit - From Contribution to AuthorshipLondon Community Summit - From Contribution to Authorship
London Community Summit - From Contribution to AuthorshipChef
 
London Community Summit 2016 - Chef Automate
London Community Summit 2016 - Chef AutomateLondon Community Summit 2016 - Chef Automate
London Community Summit 2016 - Chef AutomateChef
 
London Community Summit 2016 - Community Update
London Community Summit 2016 - Community UpdateLondon Community Summit 2016 - Community Update
London Community Summit 2016 - Community UpdateChef
 
London Community Summit 2016 - Habitat
London Community Summit 2016 -  HabitatLondon Community Summit 2016 -  Habitat
London Community Summit 2016 - HabitatChef
 
Compliance Automation with Inspec Part 4
Compliance Automation with Inspec Part 4Compliance Automation with Inspec Part 4
Compliance Automation with Inspec Part 4Chef
 
Compliance Automation with Inspec Part 3
Compliance Automation with Inspec Part 3Compliance Automation with Inspec Part 3
Compliance Automation with Inspec Part 3Chef
 
Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2Chef
 
Compliance Automation with Inspec Part 1
Compliance Automation with Inspec Part 1Compliance Automation with Inspec Part 1
Compliance Automation with Inspec Part 1Chef
 
Application Automation with Habitat
Application Automation with HabitatApplication Automation with Habitat
Application Automation with HabitatChef
 
Achieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef AutomateAchieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef AutomateChef
 
Nike pop up habitat
Nike pop up   habitatNike pop up   habitat
Nike pop up habitatChef
 
Nike popup compliance workshop
Nike popup compliance workshopNike popup compliance workshop
Nike popup compliance workshopChef
 
Chef Automate Workflow Demo
Chef Automate Workflow DemoChef Automate Workflow Demo
Chef Automate Workflow DemoChef
 

More from Chef (20)

Habitat Managed Chef
Habitat Managed ChefHabitat Managed Chef
Habitat Managed Chef
 
Automation, Audits, and Apps Tour
Automation, Audits, and Apps TourAutomation, Audits, and Apps Tour
Automation, Audits, and Apps Tour
 
Automation, Audits, and Apps Tour
Automation, Audits, and Apps TourAutomation, Audits, and Apps Tour
Automation, Audits, and Apps Tour
 
London Community Summit 2016 - Adopting Chef Compliance
London Community Summit 2016 - Adopting Chef ComplianceLondon Community Summit 2016 - Adopting Chef Compliance
London Community Summit 2016 - Adopting Chef Compliance
 
Learning from Configuration Management
Learning from Configuration Management Learning from Configuration Management
Learning from Configuration Management
 
London Community Summit 2016 - Fresh New Chef Stuff
London Community Summit 2016 - Fresh New Chef StuffLondon Community Summit 2016 - Fresh New Chef Stuff
London Community Summit 2016 - Fresh New Chef Stuff
 
London Community Summit - Chef at SkyBet
London Community Summit - Chef at SkyBetLondon Community Summit - Chef at SkyBet
London Community Summit - Chef at SkyBet
 
London Community Summit - From Contribution to Authorship
London Community Summit - From Contribution to AuthorshipLondon Community Summit - From Contribution to Authorship
London Community Summit - From Contribution to Authorship
 
London Community Summit 2016 - Chef Automate
London Community Summit 2016 - Chef AutomateLondon Community Summit 2016 - Chef Automate
London Community Summit 2016 - Chef Automate
 
London Community Summit 2016 - Community Update
London Community Summit 2016 - Community UpdateLondon Community Summit 2016 - Community Update
London Community Summit 2016 - Community Update
 
London Community Summit 2016 - Habitat
London Community Summit 2016 -  HabitatLondon Community Summit 2016 -  Habitat
London Community Summit 2016 - Habitat
 
Compliance Automation with Inspec Part 4
Compliance Automation with Inspec Part 4Compliance Automation with Inspec Part 4
Compliance Automation with Inspec Part 4
 
Compliance Automation with Inspec Part 3
Compliance Automation with Inspec Part 3Compliance Automation with Inspec Part 3
Compliance Automation with Inspec Part 3
 
Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2
 
Compliance Automation with Inspec Part 1
Compliance Automation with Inspec Part 1Compliance Automation with Inspec Part 1
Compliance Automation with Inspec Part 1
 
Application Automation with Habitat
Application Automation with HabitatApplication Automation with Habitat
Application Automation with Habitat
 
Achieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef AutomateAchieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef Automate
 
Nike pop up habitat
Nike pop up   habitatNike pop up   habitat
Nike pop up habitat
 
Nike popup compliance workshop
Nike popup compliance workshopNike popup compliance workshop
Nike popup compliance workshop
 
Chef Automate Workflow Demo
Chef Automate Workflow DemoChef Automate Workflow Demo
Chef Automate Workflow Demo
 

Recently uploaded

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Node setup, resource, and recipes - Fundamentals Webinar Series Part 2

  • 2. Nathen Harvey • Community Director • Co-host of the Food Fight Show Podcast • @nathenharvey
  • 4. Multi-week Webinar Series • After completing of this webinar series you will be able to • Automate common infrastructure tasks with Chef • Describe Chef’s architecture • Describe Chef’s various tools • Apply Chef’s primitives to solve your problems
  • 5. How to learn Chef • You bring the domain expertise about your business and infrastructure • Chef provides a framework for automating your infrastructure • Our job is to work together to teach you how to model and automate your infrastructure with Chef
  • 6. Chef is a Language • Learning Chef is like learning the basics of a language • 80% fluency will be reached very quickly • The remaining 20% just takes practice • The best way to learn Chef is to use Chef
  • 7. Questions & Answers • Ask questions in the chat window when they come to you • We’ll answer as many questions as we can at the end of the session
  • 8. Slides and Video • This webinar is being recorded. The video will be made available shortly after the session has ended. • The slides used throughout this webinar will be made available at the end of each webinar. • Watch http://learnchef.com for updates.
  • 10. Topics • Overview of Chef • Workstation Setup • Node Setup - Today • Chef Resources and Recipes - Today • Working with the Node object • Common configuration with Data Bags • Roles and Environments • Community Cookbooks and Further Resources
  • 11. Node Setup Setup a Node to manage 11
  • 12. Lesson Objectives • After completing the lesson, you will be able to • Login to the node in your Chef Training Lab • Install Chef nodes using "knife bootstrap" • Explain how knife bootstrap configures a node to use the Organization created in the previous section • Explain the basic configuration needed to run chef- client 12
  • 16. Nodes • Nodes represent the servers in your infrastructure these may be • Physical or virtual servers • Hardware that you own • Compute instances in a public or private cloud 16
  • 17. We Have No Nodes Yet 17
  • 18. $ ssh root@<EXTERNAL_ADDRESS> Lab - Login The authenticity of host 'uvo1qrwls0jdgs3blvt.vm.cld.sr (69.195.232.110)' can't be established. RSA key fingerprint is d9:95:a3:b9:02:27:e9:cd: 74:e4:a2:34:23:f5:a6:8b. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'uvo1qrwls0jdgs3blvt.vm.cld.sr, 69.195.232.110' (RSA) to the list of known hosts. chef@uvo1qrwls0jdgs3blvt.vm.cld.sr's password: Last login: Mon Jan 6 16:26:24 2014 from host86-145-117-53.range86-145.btcentralplus.com [chef@CentOS63 ~]$ 18
  • 19. Checkpoint • At this point you should have • One virtual machine (VM) or server that you’ll use for the lab exercises • The IP address or public hostname • An application for establishing an ssh connection • 'sudo' or 'root' permissions on the VM 19
  • 21. $ knife bootstrap <EXTERNAL_ADDRESS> -x chef -P chef -N "module2" "Bootstrap" the Target Instance Bootstrapping Chef on uvo1qrwls0jdgs3blvt.vm.cld.sr ... ... uvo1qrwls0jdgs3blvt.vm.cld.sr Creating a new client identity for module2 using the validator key. uvo1qrwls0jdgs3blvt.vm.cld.sr resolving cookbooks for run list: [] uvo1qrwls0jdgs3blvt.vm.cld.sr Synchronizing Cookbooks: uvo1qrwls0jdgs3blvt.vm.cld.sr Compiling Cookbooks... uvo1qrwls0jdgs3blvt.vm.cld.sr [2014-01-28T11:03:14-05:00] WARN: Node node2 has an empty run list. uvo1qrwls0jdgs3blvt.vm.cld.sr Converging 0 resources uvo1qrwls0jdgs3blvt.vm.cld.sr Chef Client finished, 0 resources updated 21
  • 23. Node knife bootstrap 23 Workstation knife bootstrap HOSTNAME -x root -P PASSWORD -N module2 Chef Server
  • 24. Node knife bootstrap 24 Workstation knife bootstrap HOSTNAME -x root -P PASSWORD -N module2 ssh/scp chef_server_url validation_client_name validation_client_key Chef Server
  • 25. Node knife bootstrap 25 Workstation knife bootstrap HOSTNAME -x root -P PASSWORD -N module2 ssh/scp chef_server_url validation_client_name validation_client_key install chef-client configure chef-client run chef-client Chef Server
  • 26. Node knife bootstrap 26 Workstation knife bootstrap HOSTNAME -x root -P PASSWORD -N module2 ssh/scp chef_server_url validation_client_name validation_client_key register node save node details install chef-client configure chef-client run chef-client Chef Server
  • 27. Node knife bootstrap 27 Workstation knife bootstrap HOSTNAME -x root -P PASSWORD -N module2 ssh/scp chef_server_url validation_client_name validation_client_key register node save node details install chef-client configure chef-client run chef-client Chef Server
  • 28. Node knife bootstrap 28 Workstation knife bootstrap HOSTNAME -x root -P PASSWORD -N module2 ssh/scp chef_server_url validation_client_name validation_client_key register node save node details install chef-client configure chef-client run chef-client Chef Server
  • 29. Verify Your Target Instance’s Chef-Client is Configured Properly $ ssh root@<EXTERNAL_ADDRESS> root@CentOS63:~$ ls /etc/chef client.pem client.rb first-boot.json validation.pem root@CentOS63:~$ which chef-client /usr/bin/chef-client 29
  • 30. View Node on Chef Server • Click the 'Details' tab
  • 31. View Node on Chef Server 31 • Click the 'Attributes' tab
  • 32. Node • The node is registered with Chef Server • The Chef Server displays information about the node • This information comes from Ohai - we'll see Ohai later..... 32
  • 34. Chef Resources and Recipes Writing an Apache cookbook 34
  • 35. Lesson Objectives • After completing the lesson, you will be able to • Describe in detail what a cookbook is • Create a new cookbook • Explain what a recipe is • Describe how to use the package, service, and template resources • Upload a cookbook to the Chef Server • Explain what a run list is, and how to set it for a node via knife • Explain the output of a chef-client run 35
  • 36. What is a cookbook? • A cookbook is like a “package” for Chef recipes. • It contains all the recipes, files, templates, libraries, etc. required to configure a portion of your infrastructure • Typically they map 1:1 to a piece of software or functionality. 36
  • 37. The Problem and the Success Criteria • The Problem: We need a web server configured to serve up our home page. • Success Criteria: We can see the homepage in a web browser. 37
  • 38. Desired state: our policy • Apache web server should be installed • Apache should be running and configured to start when the machine boots • Our home page should be displayed • Please note in this course we're teaching Chef primitives, not web server management • This is probably not the Apache HTTP server configuration you would use in production 38
  • 39. $ knife cookbook create apache Exercise: Create a new Cookbook ** Creating cookbook apache ** Creating README for cookbook: apache ** Creating CHANGELOG for cookbook: apache ** Creating metadata for cookbook: apache 39
  • 40. $ ls -la cookbooks/apache Exercise: Explore the cookbook total 24 drwxr-xr-x 13 opscode opscode 442 Jan 24 21:25 . drwxr-xr-x 5 opscode opscode 170 Jan 24 21:25 .. -rw-r--r-- 1 opscode opscode 412 Jan 24 21:25 CHANGELOG.md -rw-r--r-- 1 opscode opscode 1447 Jan 24 21:25 README.md drwxr-xr-x 2 opscode opscode 68 Jan 24 21:25 attributes drwxr-xr-x 2 opscode opscode 68 Jan 24 21:25 definitions drwxr-xr-x 3 opscode opscode 102 Jan 24 21:25 files drwxr-xr-x 2 opscode opscode 68 Jan 24 21:25 libraries -rw-r--r-- 1 opscode opscode 276 Jan 24 21:25 metadata.rb drwxr-xr-x 2 opscode opscode 68 Jan 24 21:25 providers drwxr-xr-x 3 opscode opscode 102 Jan 24 21:25 recipes drwxr-xr-x 2 opscode opscode 68 Jan 24 21:25 resources drwxr-xr-x 3 opscode opscode 102 Jan 24 21:25 templates 40
  • 41. Exercise: Open a project drawer if you're using Sublime Text • If you're using Sublime, then File>Open the chef-repo directory you created earlier 41 Access the cookbook files from the left menu
  • 42. OPEN IN EDITOR: cookbooks/apache/recipes/default.rb # # Cookbook Name:: apache # Recipe:: default # # Copyright 2013, YOUR_COMPANY_NAME # # All rights reserved - Do Not Redistribute # Exercise: Edit the default recipe 42
  • 43. SAVE FILE! # # Cookbook Name:: apache # Recipe:: default # # Copyright 2013, YOUR_COMPANY_NAME # # All rights reserved - Do Not Redistribute # package "httpd" do action :install end Exercise: Add a package resource to install Apache to the default recipe OPEN IN EDITOR: cookbooks/apache/recipes/default.rb 43
  • 44. package "httpd" do action :install end So the resource we just wrote... 44
  • 45. package "httpd" do action :install end So the resource we just wrote... • Is a package resource 45
  • 46. package "httpd" do action :install end So the resource we just wrote... • Is a package resource • Whose name is httpd 46
  • 47. package "httpd" do action :install end So the resource we just wrote... • Is a package resource • Whose name is httpd • With an install action 47
  • 48. Notice we didn’t say how to install the package • Resources are declarative - that means we say what we want to have happen, rather than how • Resources take action through Providers - providers perform the how • Chef uses the platform the node is running to determine the correct provider for a resource 48
  • 49. Package Resource package "git" { yum install git apt-get install git pacman sync git pkg_add -r git Providers aredetermined by node's platform 49
  • 50. SAVE FILE! ... # All rights reserved - Do Not Redistribute # package "httpd" do action :install end service "httpd" do action [ :enable, :start ] end Exercise: Add a service resource to ensure the service is started and enabled at boot OPEN IN EDITOR: cookbooks/apache/recipes/default.rb 50
  • 51. service "httpd" do action [ :enable, :start ] end So the resource we just wrote... 51
  • 52. service "httpd" do action [ :enable, :start ] end So the resource we just wrote... • Is a service resource 52
  • 53. service "httpd" do action [ :enable, :start ] end So the resource we just wrote... • Is a service resource • Whose name is httpd 53
  • 54. service "httpd" do action [ :enable, :start ] end So the resource we just wrote... • Is a service resource • Whose name is httpd • With two actions: • enable • start 54
  • 55. • Body Level One • Body Level Two • Body Level Three • Body Level Four • Body Level Five Order Matters package "haproxy" do action :install end template "/etc/haproxy/haproxy.cfg" do source "haproxy.cfg.erb" owner "root" group "root" mode "0644" notifies :restart, "service[haproxy]" end service "haproxy" do supports :restart => :true action [:enable, :start] end • Resources are executed in order 1st 2nd 3rd 55
  • 56. SAVE FILE! ... service "httpd" do action [ :enable, :start ] end template "/var/www/html/index.html" do source "index.html.erb" mode "0644" end Exercise: Add a cookbook_file resource to copy the home page in place OPEN IN EDITOR: cookbooks/apache/recipes/default.rb 56
  • 57. So the resource we just wrote... template "/var/www/html/index.html" do source "index.html.erb" mode "0644" end 57
  • 58. So the resource we just wrote... • Is a template resource template "/var/www/html/index.html" do source "index.html.erb" mode "0644" end 58
  • 59. So the resource we just wrote... • Is a template resource • Whose name is: /var/www/html/index.html template "/var/www/html/index.html" do source "index.html.erb" mode "0644" end 59
  • 60. So the resource we just wrote... • Is a template resource • Whose name is: /var/www/html/index.html • With two parameters: • source of index.html.erb • mode of “0644” template "/var/www/html/index.html" do source "index.html.erb" mode "0644" end 60
  • 61. Full contents of the apache recipe # # Cookbook Name:: apache # Recipe:: default # # Copyright 2013, YOUR_COMPANY_NAME # # All rights reserved - Do Not Redistribute # package "httpd" do action :install end service "httpd" do action [ :enable, :start ] end template "/var/www/html/index.html" do source "index.html.erb" mode "0644" end 61
  • 62. OPEN IN EDITOR: SAVE FILE! cookbooks/apache/templates/default/index.html.erb <h1>Hello, world!</h1> Exercise: Add index.html to your cookbook’s files/default directory 62
  • 63. $ knife cookbook upload apache Exercise: Upload the cookbook Uploading apache [0.1.0] Uploaded 1 cookbook. 63
  • 64. Upload a cookbook knife cookbook upload apache
  • 65. Upload a cookbook knife cookbook upload apache
  • 66. Upload a cookbook knife cookbook upload apache
  • 67. Upload a cookbook knife cookbook upload apache
  • 68. The Run List • The Run List is the ordered set of recipes and roles that the Chef Client will execute on a node • Recipes are specified by “recipe[name]” 68
  • 69. $ knife node run_list add module2 "recipe[apache]" Exercise: Add apache recipe to test node’s run list module2: run_list: recipe[apache] 69
  • 70. Upload a cookbook knife node run_list add module2 “recipe[apache]”
  • 71. Upload a cookbook knife node run_list add module2 “recipe[apache]” recipe[apache]
  • 72. Upload a cookbook knife node run_list add module2 “recipe[apache]” recipe[apache]
  • 73. Upload a cookbook knife node run_list add module2 “recipe[apache]” recipe[apache]
  • 74. Upload a cookbook knife node run_list add module2 “recipe[apache]”
  • 75. root@CentOS63:~$ sudo chef-client Exercise: Run Chef Client Starting Chef Client, version 11.10.4 resolving cookbooks for run list: ["apache"] Synchronizing Cookbooks: - apache Compiling Cookbooks... Converging 3 resources Recipe: apache::default * package[httpd] action install - install version 2.2.15-29.el6.centos of package httpd * service[httpd] action enable - enable service service[httpd] * service[httpd] action start - start service service[httpd] * template[/var/www/html/index.html] action create - create new file /var/www/html/index.html - update content in file /var/www/html/index.html from none to 17d291 75
  • 76. Exercise: Verify that the home page works • Open a web browser • Type in the the URL for your test node 76
  • 77. Congratulate yourself! • You have just written your first Chef cookbook! • (clap!) 77
  • 79. Run List Node Enterprise Chef chef-client What policy should I follow? "recipe[apache]" 79
  • 80. Run List Node Enterprise Chef chef-client What policy should I follow? "recipe[apache]" 80
  • 81. Run List Enterprise Chef chef-client What policy should I follow? "recipe[apache]" 81
  • 82. Run List Enterprise Chef chef-client What policy should I follow? "recipe[apache]" 82
  • 84. Six Week Series • Module 1 - Overview of Chef • Today - Node Setup, Chef Resources & Recipes • June 3 - Working with the Node object • June 10 - Common configuration data with Databags • June 17 - Using Roles and Environments • June 24 - Community Cookbooks and Further Resources • * Topics subject to change, schedule unlikely to change
  • 85. Sign-up for Webinar • http://pages.getchef.com/ cheffundamentalsseries.html
  • 86. Additional Resources • Chef Fundamentals Webinar Series • https://www.youtube.com/watch? v=S5lHUpzoCYo&list=PL11cZfNdwNyPnZA9D1MbVqldGuOWqbum Z • Discussion group for webinar participants • https://groups.google.com/d/forum/learnchef-fundamentals-webinar 102
  • 87. Additional Resources • Learn Chef • http://learnchef.com • Documentation • http://docs.opscode.com 103