SlideShare ist ein Scribd-Unternehmen logo
1 von 54
Downloaden Sie, um offline zu lesen
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
Questions & Answers
• Ask questions in the
Google Discussion Forum
• This can be used during
the webinar and outside
of the webinar, too.
• https://groups.google.com/d/
forum/learnchef-fundamentals-
webinar
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
10
Topics
• Overview of Chef
• Workstation Setup
• Node Setup
• Chef Resources and Recipes
• Working with the Node object
• Roles
• Common configuration with Data Bags - Today
• Environments
• Community Cookbooks and Further Resources
Quick Recap
Where are we?
12
In the last module
• Login to the node in your Chef Training Lab
• Install Chef nodes using "knife bootstrap"
• Included a run_list so that the server was a web
server when the bootstrap process completed
• Read and wrote node attributes
13
Where did my Node go?
• We still need a CentOS machine to manage
• The one we launched last time has likely expired
• Launch a new one using the Chef Lab
• Hopefully, you’ve already done this. We’re not
going to spend time walking through it now.
14
Launch Chef Training Lab
15
$ 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 ~]$
16
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
17
$ knife bootstrap <EXTERNAL_ADDRESS> -x root -P chef -N ‘module4’ -r ‘role[webserver]’
"Bootstrap" the Target Instance
Bootstrapping Chef on uvo1qrwls0jdgs3blvt.vm.cld.sr
...
...
uvo1qrwls0jdgs3blvt.vm.cld.sr Creating a new client identity for
module3 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
module3 has an empty run list.
uvo1qrwls0jdgs3blvt.vm.cld.sr Converging 0 resources
uvo1qrwls0jdgs3blvt.vm.cld.sr Chef Client finished, 0 resources updated
18
Exercise: Verify that the home page works
• Open a web browser
• Type in the the URL for your test node
19
v1.0.0_ChefConf
Data Bags
20
Lesson Objectives
• After completing the lesson, you will be able to
• Use Data Bags for data-driven recipes
• Use multiple recipes for a node's run list
Data Bags are generic stores of information
• Data Bags are generic, arbitrary stores of
information about the infrastructure
• Data Bag Items are JSON data
• Our apache cookbook provides a good baseline
• We'll drive site-specific virtual hosts with data bags
$ mkdir -p data_bags/vhosts
Create a directory for Data Bags
OPEN IN EDITOR:
SAVE FILE!
data_bags/vhosts/bears.json
{
"id" : "bears",
"port" : 80
}
Add a Data Bag Item
OPEN IN EDITOR:
SAVE FILE!
data_bags/vhosts/clowns.json
{
"id" : "clowns",
"port" : 81
}
Add a Data Bag Item
$ knife upload data_bags/vhosts
Upload the data bags
Created data_bags/vhosts
Created data_bags/vhosts/bears.json
Created data_bags/vhosts/clowns.json
A new recipe for virtual hosts
• We'll create an apache::vhosts recipe to manage
the virtual hosts we created in data bag items
• There's a number of new things to talk about in this
recipe
• We'll take this nice and slow :)
OPEN IN EDITOR:
SAVE FILE!
cookbooks/apache/recipes/vhosts.rb
data_bag("vhosts").each do |site|
site_data = data_bag_item("vhosts", site)
site_name = site_data["id"]
document_root = "/srv/apache/#{site_name}"
end
Create a vhosts recipe
OPEN IN EDITOR:
SAVE FILE!
cookbooks/apache/recipes/vhosts.rb
document_root = "/srv/apache/#{site_name}"
template "/etc/httpd/conf.d/#{site_name}.conf" do
source "custom-vhosts.erb"
mode "0644"
variables(
:document_root => document_root,
:port => site_data["port"]
)
notifies :restart, "service[httpd]"
end
end
Add a Virtual Hosts Configuration Template
OPEN IN EDITOR:
SAVE FILE!
cookbooks/apache/recipes/vhosts.rb
end
directory document_root do
mode "0755"
recursive true
end
end
Add a directory resource
OPEN IN EDITOR:
SAVE FILE!
cookbooks/apache/recipes/vhosts.rb
end
template "#{document_root}/index.html" do
source "index.html.erb"
mode "0644"
variables(
:site_name => site_name,
:port => site_data["port"]
)
end
end
Index for each vhost
OPEN IN EDITOR:
SAVE FILE!
cookbooks/apache/recipes/vhosts.rb
end
template "#{document_root}/index.html" do
source "index.html.erb"
mode "0644"
variables(
:site_name => site_name,
:port => site_data["port"]
)
end
end
Index for each vhost
https://gist.github.com/9134977
OPEN IN EDITOR:
SAVE FILE!
cookbooks/apache/templates/default/custom-vhosts.erb
<% if @port != 80 -%>
Listen <%= @port %>
<% end -%>
<VirtualHost *:<%= @port %>>
ServerAdmin webmaster@localhost
DocumentRoot <%= @document_root %>
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory <%= @document_root %>>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Index for each vhost
OPEN IN EDITOR:
SAVE FILE!
cookbooks/apache/templates/default/custom-vhosts.erb
<% if @port != 80 -%>
Listen <%= @port %>
<% end -%>
<VirtualHost *:<%= @port %>>
ServerAdmin webmaster@localhost
DocumentRoot <%= @document_root %>
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory <%= @document_root %>>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Index for each vhost
https://gist.github.com/2866454
OPEN IN EDITOR:
SAVE FILE!
cookbooks/apache/templates/default/index.html.erb
<h1>Hello, <%= node['apache']['greeting'] %>!</h1>
<p>My name is <%= node['hostname'] %></p>
<p>We love <%= @site_name %></p>
<p>Served from <%= node['ipaddress'] %>:<%= @port %></p>
Update the index.html template
$ knife diff cookbooks/apache
Diff the cookbook
diff --knife cookbooks/apache/templates/default/index.html.erb cookbooks/apache/templates/default/
index.html.erb
--- cookbooks/apache/templates/default/index.html.erb 2014-02-21 06:02:53.000000000 -0800
+++ cookbooks/apache/templates/default/index.html.erb 2014-02-21 06:02:53.000000000 -0800
@@ -1,3 +1,5 @@
<h1>Hello, <%= node['apache']['greeting'] %>!</h1>
<p>My name is <%= node['hostname'] %></p>
+<p>We love <%= @site_name %></p>
+<p>Served from <%= node['ipaddress'] %>:<%= @port %></p>
diff --knife cookbooks/apache/templates/default/custom-vhosts.erb cookbooks/apache/templates/
default/custom-vhosts.erb
new file
--- /dev/null 2014-02-21 06:02:53.000000000 -0800
+++ cookbooks/apache/templates/default/custom-vhosts.erb 2014-02-21 06:02:53.000000000 -0800
OPEN IN EDITOR:
SAVE FILE!
cookbooks/apache/metadata.rb
name 'apache'
maintainer 'YOUR_COMPANY_NAME'
maintainer_email 'YOUR_EMAIL'
license 'All rights reserved'
description 'Installs/Configures apache'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.2.0'
Update the metadata.rb
$ knife cookbook upload apache
Upload the cookbook
Uploading apache [0.2.0]
Uploaded 1 cookbook.
OPEN IN EDITOR:
SAVE FILE!
roles/webserver.json
{
"name" : "webserver",
"default_attributes" : {
"apache" : {
"greeting" : "Webinar"
}
},
"run_list" : [
"recipe[apache]",
"recipe[apache::vhosts]"
]
}
Update the webserver role
Exercise: Update the role
Updated Role webserver!
38
$ knife role from file webserver.json
Exercise: Update the role
Updated Role webserver!
38
root@module4:~$ sudo chef-client
Run the chef-client on your test node
Starting Chef Client, version 11.10.4
resolving cookbooks for run list: ["apache", "apache::vhosts"]
Synchronizing Cookbooks:
- apache
Compiling Cookbooks...
Converging 9 resources
Recipe: apache::default
* package[httpd] action install (up to date)
* service[httpd] action enable (up to date)
* service[httpd] action start (up to date)
* execute[mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.disabled] action run
(skipped due to only_if)
Recipe: apache::vhosts
* template[/etc/httpd/conf.d/bears.conf] action create
- create new file /etc/httpd/conf.d/bears.conf
- update content in file /etc/httpd/conf.d/bears.conf from none to 416948
--- /etc/httpd/conf.d/bears.conf 2014-02-21 09:20:53.592830069 -0500
+++ /tmp/chef-rendered-template20140221-6294-y855dq 2014-02-21 09:20:53.594830068 -0500
Think about what we just did...
Think about what we just did...
• We had two virtual hosts...
Think about what we just did...
• We had two virtual hosts...
• But we could arbitrarily add more...
Think about what we just did...
• We had two virtual hosts...
• But we could arbitrarily add more...
• Tigers on port 82, Lions on port 83, oh my!
Checkpoint
• Our cookbook has two recipes, default and vhosts
• Additional data bags can be added, expanding our
Virtual Hosting empire!
Chef Fundamentals
Webinar Series
Six Week Series
• Module 1 - Overview of Chef
• Module 2 - Node Setup, Chef Resources & Recipes
• Module 3 - Working with the Node object & Roles
• Today - Common configuration data with Databags
• June 17 - 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
45
Additional Resources
• Learn Chef
• http://learnchef.com
• Documentation
• http://docs.opscode.com
46
Lesson Objectives
• After completing the lesson, you will be able to
• Use Data Bags for data-driven recipes
• Use multiple recipes for a node's run list
Six Week Series
• Module 1 - Overview of Chef
• Module 2 - Node Setup, Chef Resources & Recipes
• Module 3 - Working with the Node object & Roles
• Today - Common configuration data with Databags
• June 17 - Environments
• June 24 - Community Cookbooks and Further Resources
• * Topics subject to change, schedule unlikely to change

Weitere ähnliche Inhalte

Was ist angesagt?

Chef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of ChefChef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of ChefChef Software, Inc.
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to ChefKnoldus Inc.
 
Introduction to Chef - April 22 2015
Introduction to Chef - April 22 2015Introduction to Chef - April 22 2015
Introduction to Chef - April 22 2015Jennifer Davis
 
Introduction to Chef - Techsuperwomen Summit
Introduction to Chef - Techsuperwomen SummitIntroduction to Chef - Techsuperwomen Summit
Introduction to Chef - Techsuperwomen SummitJennifer Davis
 
Automating Infrastructure with Chef
Automating Infrastructure with ChefAutomating Infrastructure with Chef
Automating Infrastructure with ChefJennifer 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.
 
Chef-Zero & Local Mode
Chef-Zero & Local ModeChef-Zero & Local Mode
Chef-Zero & Local ModeMichael Goetz
 
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
 
Compliance Automation Workshop
Compliance Automation WorkshopCompliance Automation Workshop
Compliance Automation WorkshopChef
 
Chef, Devops, and You
Chef, Devops, and YouChef, Devops, and You
Chef, Devops, and YouBryan Berry
 
Automating your infrastructure with Chef
Automating your infrastructure with ChefAutomating your infrastructure with Chef
Automating your infrastructure with ChefJohn Ewart
 
Orchestration with Chef
Orchestration with ChefOrchestration with Chef
Orchestration with ChefMayank Gaikwad
 
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 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!
 
Opscode Webinar: Cooking with Chef on Microsoft Windows
Opscode Webinar: Cooking with Chef on Microsoft WindowsOpscode Webinar: Cooking with Chef on Microsoft Windows
Opscode Webinar: Cooking with Chef on Microsoft WindowsChef Software, Inc.
 
Velocity2011 chef-workshop
Velocity2011 chef-workshopVelocity2011 chef-workshop
Velocity2011 chef-workshopjtimberman
 

Was ist angesagt? (20)

Chef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of ChefChef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of Chef
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 
Introduction to Chef - April 22 2015
Introduction to Chef - April 22 2015Introduction to Chef - April 22 2015
Introduction to Chef - April 22 2015
 
Introduction to Chef - Techsuperwomen Summit
Introduction to Chef - Techsuperwomen SummitIntroduction to Chef - Techsuperwomen Summit
Introduction to Chef - Techsuperwomen Summit
 
Automating Infrastructure with Chef
Automating Infrastructure with ChefAutomating Infrastructure with Chef
Automating Infrastructure with Chef
 
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-Zero & Local Mode
Chef-Zero & Local ModeChef-Zero & Local Mode
Chef-Zero & Local Mode
 
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
 
The unintended benefits of Chef
The unintended benefits of ChefThe unintended benefits of Chef
The unintended benefits of Chef
 
Compliance Automation Workshop
Compliance Automation WorkshopCompliance Automation Workshop
Compliance Automation Workshop
 
Chef, Devops, and You
Chef, Devops, and YouChef, Devops, and You
Chef, Devops, and You
 
Chef introduction
Chef introductionChef introduction
Chef introduction
 
Chef fundamentals
Chef fundamentalsChef fundamentals
Chef fundamentals
 
Introduction to chef
Introduction to chefIntroduction to chef
Introduction to chef
 
Automating your infrastructure with Chef
Automating your infrastructure with ChefAutomating your infrastructure with Chef
Automating your infrastructure with Chef
 
Orchestration with Chef
Orchestration with ChefOrchestration with Chef
Orchestration with Chef
 
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 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...
 
Opscode Webinar: Cooking with Chef on Microsoft Windows
Opscode Webinar: Cooking with Chef on Microsoft WindowsOpscode Webinar: Cooking with Chef on Microsoft Windows
Opscode Webinar: Cooking with Chef on Microsoft Windows
 
Velocity2011 chef-workshop
Velocity2011 chef-workshopVelocity2011 chef-workshop
Velocity2011 chef-workshop
 

Ähnlich wie Common configuration with Data Bags - Fundamentals Webinar Series Part 4

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
 
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 Continuous Compliance & Remediation
Introduction To Continuous Compliance & RemediationIntroduction To Continuous Compliance & Remediation
Introduction To Continuous Compliance & RemediationNicole Johnson
 
Chef at WebMD
Chef at WebMDChef at WebMD
Chef at WebMDadamleff
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 
CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009Jason Davies
 
Chef for Openstack
Chef for OpenstackChef for Openstack
Chef for OpenstackMohit Sethi
 
WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019Anam Ahmed
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 
What Makes a Good Cookbook?
What Makes a Good Cookbook?What Makes a Good Cookbook?
What Makes a Good Cookbook?Julian Dunn
 
Planning Application Resilience - Developer Week 2015
Planning Application Resilience - Developer Week 2015Planning Application Resilience - Developer Week 2015
Planning Application Resilience - Developer Week 2015Jennifer Davis
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chefkevsmith
 

Ähnlich wie Common configuration with Data Bags - Fundamentals Webinar Series Part 4 (20)

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
 
Configuration management with Chef
Configuration management with ChefConfiguration management with Chef
Configuration management with Chef
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 
Introduction To Continuous Compliance & Remediation
Introduction To Continuous Compliance & RemediationIntroduction To Continuous Compliance & Remediation
Introduction To Continuous Compliance & Remediation
 
Chef at WebMD
Chef at WebMDChef at WebMD
Chef at WebMD
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009
 
Chef for openstack
Chef for openstackChef for openstack
Chef for openstack
 
IT Automation with Chef
IT Automation with ChefIT Automation with Chef
IT Automation with Chef
 
Chef for Openstack
Chef for OpenstackChef for Openstack
Chef for Openstack
 
WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019
 
The Environment Restaurant
The Environment RestaurantThe Environment Restaurant
The Environment Restaurant
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
What Makes a Good Cookbook?
What Makes a Good Cookbook?What Makes a Good Cookbook?
What Makes a Good Cookbook?
 
Learning chef
Learning chefLearning chef
Learning chef
 
Chef Jumpstart
Chef JumpstartChef Jumpstart
Chef Jumpstart
 
Planning Application Resilience - Developer Week 2015
Planning Application Resilience - Developer Week 2015Planning Application Resilience - Developer Week 2015
Planning Application Resilience - Developer Week 2015
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 
Top ten-list
Top ten-listTop ten-list
Top ten-list
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

"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
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
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
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
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
 
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
 
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
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
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
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
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
 
"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
 

Kürzlich hochgeladen (20)

"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
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
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
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
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
 
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
 
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
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
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
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
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!
 
"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...
 

Common configuration with Data Bags - Fundamentals Webinar Series Part 4

  • 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. Questions & Answers • Ask questions in the Google Discussion Forum • This can be used during the webinar and outside of the webinar, too. • https://groups.google.com/d/ forum/learnchef-fundamentals- webinar
  • 9. 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.
  • 11. Topics • Overview of Chef • Workstation Setup • Node Setup • Chef Resources and Recipes • Working with the Node object • Roles • Common configuration with Data Bags - Today • Environments • Community Cookbooks and Further Resources
  • 13. In the last module • Login to the node in your Chef Training Lab • Install Chef nodes using "knife bootstrap" • Included a run_list so that the server was a web server when the bootstrap process completed • Read and wrote node attributes 13
  • 14. Where did my Node go? • We still need a CentOS machine to manage • The one we launched last time has likely expired • Launch a new one using the Chef Lab • Hopefully, you’ve already done this. We’re not going to spend time walking through it now. 14
  • 16. $ 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 ~]$ 16
  • 17. 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 17
  • 18. $ knife bootstrap <EXTERNAL_ADDRESS> -x root -P chef -N ‘module4’ -r ‘role[webserver]’ "Bootstrap" the Target Instance Bootstrapping Chef on uvo1qrwls0jdgs3blvt.vm.cld.sr ... ... uvo1qrwls0jdgs3blvt.vm.cld.sr Creating a new client identity for module3 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 module3 has an empty run list. uvo1qrwls0jdgs3blvt.vm.cld.sr Converging 0 resources uvo1qrwls0jdgs3blvt.vm.cld.sr Chef Client finished, 0 resources updated 18
  • 19. Exercise: Verify that the home page works • Open a web browser • Type in the the URL for your test node 19
  • 21. Lesson Objectives • After completing the lesson, you will be able to • Use Data Bags for data-driven recipes • Use multiple recipes for a node's run list
  • 22. Data Bags are generic stores of information • Data Bags are generic, arbitrary stores of information about the infrastructure • Data Bag Items are JSON data • Our apache cookbook provides a good baseline • We'll drive site-specific virtual hosts with data bags
  • 23. $ mkdir -p data_bags/vhosts Create a directory for Data Bags
  • 24. OPEN IN EDITOR: SAVE FILE! data_bags/vhosts/bears.json { "id" : "bears", "port" : 80 } Add a Data Bag Item
  • 25. OPEN IN EDITOR: SAVE FILE! data_bags/vhosts/clowns.json { "id" : "clowns", "port" : 81 } Add a Data Bag Item
  • 26. $ knife upload data_bags/vhosts Upload the data bags Created data_bags/vhosts Created data_bags/vhosts/bears.json Created data_bags/vhosts/clowns.json
  • 27. A new recipe for virtual hosts • We'll create an apache::vhosts recipe to manage the virtual hosts we created in data bag items • There's a number of new things to talk about in this recipe • We'll take this nice and slow :)
  • 28. OPEN IN EDITOR: SAVE FILE! cookbooks/apache/recipes/vhosts.rb data_bag("vhosts").each do |site| site_data = data_bag_item("vhosts", site) site_name = site_data["id"] document_root = "/srv/apache/#{site_name}" end Create a vhosts recipe
  • 29. OPEN IN EDITOR: SAVE FILE! cookbooks/apache/recipes/vhosts.rb document_root = "/srv/apache/#{site_name}" template "/etc/httpd/conf.d/#{site_name}.conf" do source "custom-vhosts.erb" mode "0644" variables( :document_root => document_root, :port => site_data["port"] ) notifies :restart, "service[httpd]" end end Add a Virtual Hosts Configuration Template
  • 30. OPEN IN EDITOR: SAVE FILE! cookbooks/apache/recipes/vhosts.rb end directory document_root do mode "0755" recursive true end end Add a directory resource
  • 31. OPEN IN EDITOR: SAVE FILE! cookbooks/apache/recipes/vhosts.rb end template "#{document_root}/index.html" do source "index.html.erb" mode "0644" variables( :site_name => site_name, :port => site_data["port"] ) end end Index for each vhost
  • 32. OPEN IN EDITOR: SAVE FILE! cookbooks/apache/recipes/vhosts.rb end template "#{document_root}/index.html" do source "index.html.erb" mode "0644" variables( :site_name => site_name, :port => site_data["port"] ) end end Index for each vhost https://gist.github.com/9134977
  • 33. OPEN IN EDITOR: SAVE FILE! cookbooks/apache/templates/default/custom-vhosts.erb <% if @port != 80 -%> Listen <%= @port %> <% end -%> <VirtualHost *:<%= @port %>> ServerAdmin webmaster@localhost DocumentRoot <%= @document_root %> <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory <%= @document_root %>> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> </VirtualHost> Index for each vhost
  • 34. OPEN IN EDITOR: SAVE FILE! cookbooks/apache/templates/default/custom-vhosts.erb <% if @port != 80 -%> Listen <%= @port %> <% end -%> <VirtualHost *:<%= @port %>> ServerAdmin webmaster@localhost DocumentRoot <%= @document_root %> <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory <%= @document_root %>> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> </VirtualHost> Index for each vhost https://gist.github.com/2866454
  • 35. OPEN IN EDITOR: SAVE FILE! cookbooks/apache/templates/default/index.html.erb <h1>Hello, <%= node['apache']['greeting'] %>!</h1> <p>My name is <%= node['hostname'] %></p> <p>We love <%= @site_name %></p> <p>Served from <%= node['ipaddress'] %>:<%= @port %></p> Update the index.html template
  • 36. $ knife diff cookbooks/apache Diff the cookbook diff --knife cookbooks/apache/templates/default/index.html.erb cookbooks/apache/templates/default/ index.html.erb --- cookbooks/apache/templates/default/index.html.erb 2014-02-21 06:02:53.000000000 -0800 +++ cookbooks/apache/templates/default/index.html.erb 2014-02-21 06:02:53.000000000 -0800 @@ -1,3 +1,5 @@ <h1>Hello, <%= node['apache']['greeting'] %>!</h1> <p>My name is <%= node['hostname'] %></p> +<p>We love <%= @site_name %></p> +<p>Served from <%= node['ipaddress'] %>:<%= @port %></p> diff --knife cookbooks/apache/templates/default/custom-vhosts.erb cookbooks/apache/templates/ default/custom-vhosts.erb new file --- /dev/null 2014-02-21 06:02:53.000000000 -0800 +++ cookbooks/apache/templates/default/custom-vhosts.erb 2014-02-21 06:02:53.000000000 -0800
  • 37. OPEN IN EDITOR: SAVE FILE! cookbooks/apache/metadata.rb name 'apache' maintainer 'YOUR_COMPANY_NAME' maintainer_email 'YOUR_EMAIL' license 'All rights reserved' description 'Installs/Configures apache' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version '0.2.0' Update the metadata.rb
  • 38. $ knife cookbook upload apache Upload the cookbook Uploading apache [0.2.0] Uploaded 1 cookbook.
  • 39. OPEN IN EDITOR: SAVE FILE! roles/webserver.json { "name" : "webserver", "default_attributes" : { "apache" : { "greeting" : "Webinar" } }, "run_list" : [ "recipe[apache]", "recipe[apache::vhosts]" ] } Update the webserver role
  • 40. Exercise: Update the role Updated Role webserver! 38
  • 41. $ knife role from file webserver.json Exercise: Update the role Updated Role webserver! 38
  • 42. root@module4:~$ sudo chef-client Run the chef-client on your test node Starting Chef Client, version 11.10.4 resolving cookbooks for run list: ["apache", "apache::vhosts"] Synchronizing Cookbooks: - apache Compiling Cookbooks... Converging 9 resources Recipe: apache::default * package[httpd] action install (up to date) * service[httpd] action enable (up to date) * service[httpd] action start (up to date) * execute[mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.disabled] action run (skipped due to only_if) Recipe: apache::vhosts * template[/etc/httpd/conf.d/bears.conf] action create - create new file /etc/httpd/conf.d/bears.conf - update content in file /etc/httpd/conf.d/bears.conf from none to 416948 --- /etc/httpd/conf.d/bears.conf 2014-02-21 09:20:53.592830069 -0500 +++ /tmp/chef-rendered-template20140221-6294-y855dq 2014-02-21 09:20:53.594830068 -0500
  • 43. Think about what we just did...
  • 44. Think about what we just did... • We had two virtual hosts...
  • 45. Think about what we just did... • We had two virtual hosts... • But we could arbitrarily add more...
  • 46. Think about what we just did... • We had two virtual hosts... • But we could arbitrarily add more... • Tigers on port 82, Lions on port 83, oh my!
  • 47. Checkpoint • Our cookbook has two recipes, default and vhosts • Additional data bags can be added, expanding our Virtual Hosting empire!
  • 49. Six Week Series • Module 1 - Overview of Chef • Module 2 - Node Setup, Chef Resources & Recipes • Module 3 - Working with the Node object & Roles • Today - Common configuration data with Databags • June 17 - Environments • June 24 - Community Cookbooks and Further Resources • * Topics subject to change, schedule unlikely to change
  • 50. Sign-up for Webinar • http://pages.getchef.com/ cheffundamentalsseries.html
  • 51. 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 45
  • 52. Additional Resources • Learn Chef • http://learnchef.com • Documentation • http://docs.opscode.com 46
  • 53. Lesson Objectives • After completing the lesson, you will be able to • Use Data Bags for data-driven recipes • Use multiple recipes for a node's run list
  • 54. Six Week Series • Module 1 - Overview of Chef • Module 2 - Node Setup, Chef Resources & Recipes • Module 3 - Working with the Node object & Roles • Today - Common configuration data with Databags • June 17 - Environments • June 24 - Community Cookbooks and Further Resources • * Topics subject to change, schedule unlikely to change