Twitter: @sigje Email: [email protected]
Introductions
Name
Current Job Role
Previous Job Experience
Experience with Infrastructure Automation
Favorite Text Editor
4
Slide 5
Slide 5 text
5
@beerops
@bridgetkromhout
Slide 6
Slide 6 text
6
Slide 7
Slide 7 text
Objectives
7
Slide 8
Slide 8 text
Twitter: @sigje Email: [email protected]
Objectives
Describe Infrastructure Automation
Describe Chef architecture, tools
Read Chef Recipes
8
Slide 9
Slide 9 text
Twitter: @sigje Email: [email protected]
Application of Learning
Knowledge of your environment, business needs
Chef - Framework to solve infrastructure automation
9
Slide 10
Slide 10 text
Twitter: @sigje Email: [email protected]
Chef Fluency
10
20%
80%
Training Practice
Fundamentals Training - 16 hours
Slide 11
Slide 11 text
Twitter: @sigje Email: [email protected]
Additional Resources
11
Fundamentals Training, Intermediate Training
Learn Chef
Google Forum
Slide 12
Slide 12 text
Twitter: @sigje Email: [email protected]
Workshop Fundamentals
Objectives at the beginning.
Ask questions.
Ask for help.
Answer questions.
Slides will be available after the class.
12
Slide 13
Slide 13 text
Twitter: @sigje Email: [email protected]
Setting Expectations
Experience Level: Beginner
Flexible content based on class
It’s OK to leave (and come back). Minimize disruptions.
13
Slide 14
Slide 14 text
Agenda
14
Slide 15
Slide 15 text
Twitter: @sigje Email: [email protected]
Agenda
Overview of Infrastructure Automation
Intro to Resources, Recipes, Cookbooks
Working with the Node Object
Introduction to Community Cookbooks
15
Slide 16
Slide 16 text
Overview of
Infrastructure
Automation
16
Slide 17
Slide 17 text
Twitter: @sigje Email: [email protected]
Objectives:
Overview of Infrastructure Automation
Describe Infrastructure Automation.
Describe how Chef treats Infrastructure Automation.
Define Node.
17
Twitter: @sigje Email: [email protected]
Complexity in Applications
22
Single service == multiple
applications.
Single application == a component of
service.
Twitter: @sigje Email: [email protected]
Complexity in Configurations
24
Multiple services using same software
with different configurations.
Different Operating Systems requiring
same software (and user experience).
Twitter: @sigje Email: [email protected]
Complexity in Access Control
26
Different users access to different
systems.
External versus internal.
Compliance.
Slide 27
Slide 27 text
Twitter: @sigje Email: [email protected]
Data
27
Tweets.
Profiles.
Emails.
Specific to your organization.
Infrastructure Automation is creating control
systems that reduce the burden on people to
manage services and increase the quality,
accuracy and precision of a service to the
consumers of the service.
37
Slide 38
Slide 38 text
Describe how Chef treats Infrastructure Automation.
38
Slide 39
Slide 39 text
Twitter: @sigje Email: [email protected]
Infrastructure as Code
39
Programmatically provision and
configure components.
Slide 40
Slide 40 text
Twitter: @sigje Email: [email protected]
Infrastructure as Code
40
Treat infrastructure code like the rest
of the code.
Slide 41
Slide 41 text
Twitter: @sigje Email: [email protected]
Infrastructure as Code
41
Reconstruct business from code
repository, data backups, and
compute resources.
Slide 42
Slide 42 text
Twitter: @sigje Email: [email protected]
Chef Tenets of Infrastructure as Code
42
1. Programmatically provision and configure components.
2. Treat infrastructure code like the rest of the code.
3. Reconstruct business from code repository, data backups, and compute
resources.
Slide 43
Slide 43 text
Define a Node
43
Slide 44
Slide 44 text
Twitter: @sigje Email: [email protected]
Nodes
44
any physical, virtual, or cloud
machine that is configured to be
maintained by a chef-client.
Slide 45
Slide 45 text
Twitter: @sigje Email: [email protected]
Physical Node
45
server
virtual machine
any active device attached to a
network that can run a chef-client.
Slide 46
Slide 46 text
Twitter: @sigje Email: [email protected]
Network Node
46
any active network device attached to
a network that can run a chef-client.
Slide 47
Slide 47 text
Twitter: @sigje Email: [email protected]
Cloud Node
47
Amazon Virtual Private Cloud
OpenStack
Rackspace
Google Compute Engine
Linode
Microsoft Azure
Slide 48
Slide 48 text
Twitter: @sigje Email: [email protected]
Virtual Node
48
a machine that runs only as a
software implementation, but
otherwise behaves much like a
physical machine.
Slide 49
Slide 49 text
Twitter: @sigje Email: [email protected]
Containers
49
a single operating system to host
many working configurations, with
each working configuration running
as a process that is isolated from all
other processes, including even the
host operating system
Slide 50
Slide 50 text
Twitter: @sigje Email: [email protected]
chef-client
50
agent - special software installed on
the server
Slide 51
Slide 51 text
Twitter: @sigje Email: [email protected]
hostname vs node name
51
host name - network addressable
label assigned to a server
node name - unique identifier
RECOMMENDATION:
hostname == node name
Slide 52
Slide 52 text
Twitter: @sigje Email: [email protected]
Lesson 1: Set up your cloud node
http://opscode-
cheflab.herokuapp.com/labs/
chefdk/centos/attend/
Fill in the form!
52
Slide 53
Slide 53 text
Twitter: @sigje Email: [email protected]
Lesson 1: Set up your cloud node
http://opscode-
cheflab.herokuapp.com/labs/
chefdk/centos/attend/
Click on “Create user”
53
Slide 54
Slide 54 text
Twitter: @sigje Email: [email protected]
Lesson 1: Set up your cloud node
!
Wait until you see “Environment is
Ready”
Click on “Start Using This Environment”
54
Slide 55
Slide 55 text
Twitter: @sigje Email: [email protected]
Lesson 1: Set up your cloud node
55
!
SUCCESS! Server has been created.
Slide 56
Slide 56 text
Twitter: @sigje Email: [email protected]
Lesson 2: Identify your cloud node
!
Click on “More details”
56
Slide 57
Slide 57 text
Twitter: @sigje Email: [email protected]
Lesson 2: Identify your cloud node
!
External Address
Host Name
57
Slide 58
Slide 58 text
Twitter: @sigje Email: [email protected]
Lesson 2: Identify your cloud node
!
Click on “show password”
58
Slide 59
Slide 59 text
Twitter: @sigje Email: [email protected]
Lesson 2: Identify your cloud node
!
Click on “show password”
Password will be in the clear. Note it
down.
59
Slide 60
Slide 60 text
Twitter: @sigje Email: [email protected]
Lesson 3: Connect to your cloud node
!
2 choices.
ssh available?
GUI (may be a little slower)
60
Slide 61
Slide 61 text
Twitter: @sigje Email: [email protected]
Lesson 3: Connect to your cloud node
with SSH
!
Remember this is YOUR hostname
Remember this is YOUR root password
ssh $HOSTNAME -l root
61
Slide 62
Slide 62 text
Twitter: @sigje Email: [email protected]
Lesson 3: Connect to your cloud node
with SSH
!
at command prompt type
cd chef-repo
62
Slide 63
Slide 63 text
Twitter: @sigje Email: [email protected]
Lesson 3: Connect to your cloud node
with GUI
!
Click on “View VM”
63
Slide 64
Slide 64 text
Twitter: @sigje Email: [email protected]
Lesson 3: Connect to your cloud node
with GUI
!
Click anywhere in the white box.
64
Slide 65
Slide 65 text
Twitter: @sigje Email: [email protected]
Lesson 4: Verify chef-dk install
!
At command prompt type
chef verify
65
Slide 66
Slide 66 text
Twitter: @sigje Email: [email protected]
Chef Development Kit
chef
Berkshelf 3.0
Test Kitchen
ChefSpec
Foodcritic
chef-client
knife
ohai
Chef Zero
66
Twitter: @sigje Email: [email protected]
Lesson 5: Use docs to find info about
resources
Open up a browser window to
http://docs.getchef.com/
78
Slide 79
Slide 79 text
Twitter: @sigje Email: [email protected]
Lesson 5: Use docs to find info about
resources
Click on “Search the Docs”
79
Slide 80
Slide 80 text
Twitter: @sigje Email: [email protected]
Lesson 5: Use docs to find info about
resources
Click on “Search the Docs”
80
Slide 81
Slide 81 text
Twitter: @sigje Email: [email protected]
Lesson 5: Use docs to find info about
resources
enter the word resources into the search
box
81
Slide 82
Slide 82 text
Twitter: @sigje Email: [email protected]
Lesson 5: Use docs to find info about
resources
click on “Resources and Providers
Reference - Chef Single-page Topics”
82
Slide 83
Slide 83 text
Twitter: @sigje Email: [email protected]
Lesson 5: Use docs to find info about
resources
Scroll down the “Table of Contents” on the
right hand side
Find and click on “Resources”
83
Slide 84
Slide 84 text
Twitter: @sigje Email: [email protected]
Lesson 5: Use docs to find info about
resources
Success!
84
Slide 85
Slide 85 text
Twitter: @sigje Email: [email protected]
Lesson 6: Create a file resource.
GUI users: if the node isn’t available, click
on “Reconnect”
85
Slide 86
Slide 86 text
Twitter: @sigje Email: [email protected]
Lesson 6: Create a file resource.
create a file named hello.rb.
SSH users
vi hello.rb
GUI
vi hello.rb
or
gedit hello.rb &
86
Slide 87
Slide 87 text
Twitter: @sigje Email: [email protected]
Lesson 6: Create a file resource.
create a file named hello.rb.
GUI gedit users
Opens a graphical window
Click on the window to type in it.
87
Slide 88
Slide 88 text
Twitter: @sigje Email: [email protected]
Lesson 6: Create a file resource.
create a file named hello.rb.
add content.
88
Slide 89
Slide 89 text
Twitter: @sigje Email: [email protected]
Lesson 6: Create a file resource.
create a file named hello.rb.
add content.
89
Slide 90
Slide 90 text
Twitter: @sigje Email: [email protected]
Lesson 6: Create a file resource.
create a file named hello.rb.
add content.
GUI gedit users
Click on “File”
90
Slide 91
Slide 91 text
Twitter: @sigje Email: [email protected]
Lesson 6: Create a file resource.
create a file named hello.rb.
add content.
GUI gedit users
Click on “Save”
91
Slide 92
Slide 92 text
Twitter: @sigje Email: [email protected]
Lesson 6: Create a file resource.
create a file named hello.rb.
add content.
SSH and GUI - vi users
type “i” to go into insert mode
enter text
92
Slide 93
Slide 93 text
Twitter: @sigje Email: [email protected]
Lesson 6: Create a file resource.
create a file named hello.rb.
add content.
vi users
Click “esc” key (Command mode)
Enter “:x” and click return
93
Slide 94
Slide 94 text
Twitter: @sigje Email: [email protected]
Lesson 6: Create a file resource.
create a file named hello.rb.
add content.
save the file.
94
Slide 95
Slide 95 text
Twitter: @sigje Email: [email protected]
Lesson 7: Apply the resource.
At command prompt type:
chef-apply hello.rb
95
Slide 96
Slide 96 text
Twitter: @sigje Email: [email protected]
Lesson 8: Verify that the file was created.
At command prompt type:
cat motd
96
Slide 97
Slide 97 text
Twitter: @sigje Email: [email protected]
Lesson 9: Update the resource.
At command prompt type:
chef-apply hello.rb
97
Slide 98
Slide 98 text
Twitter: @sigje Email: [email protected]
Lesson 10: Modify the resource.
Edit your resource to make your message
personal!
Edit the file.
Modify ‘hello world’.
98
Slide 99
Slide 99 text
Twitter: @sigje Email: [email protected]
Lesson 11: Update the resource.
At command prompt type:
chef-apply hello.rb
99
Slide 100
Slide 100 text
Twitter: @sigje Email: [email protected]
Lesson 11: Update the resource.
At command prompt type:
chef-apply hello.rb
100
Slide 101
Slide 101 text
Twitter: @sigje Email: [email protected]
Lesson 12: Verify the file changed.
At command prompt type:
cat motd
101
Slide 102
Slide 102 text
Twitter: @sigje Email: [email protected]
Lesson 13: Modify the file by hand.
Edit the motd file to have a new message.
102
Slide 103
Slide 103 text
Twitter: @sigje Email: [email protected]
Lesson 14: Update the resource.
103
At command prompt type:
chef-apply hello.rb
Slide 104
Slide 104 text
Twitter: @sigje Email: [email protected]
Lesson 14: Update the resource.
104
At command prompt type:
chef-apply hello.rb
Slide 105
Slide 105 text
We programmatically defined a file resource.
105
Slide 106
Slide 106 text
Twitter: @sigje Email: [email protected]
Lesson 15: Delete a file resource.
create a file named goodbye.rb.
add content.
file ‘motd’ do
action :delete
end
save file.
106
Slide 107
Slide 107 text
Twitter: @sigje Email: [email protected]
Lesson 15: Apply the resource.
107
At command prompt type:
?????
Slide 108
Slide 108 text
Twitter: @sigje Email: [email protected]
Lesson 15: Apply the resource.
108
At command prompt type:
chef-apply goodbye.rb
Slide 109
Slide 109 text
Twitter: @sigje Email: [email protected]
Lesson 15: Apply the resource.
109
At command prompt type:
chef-apply goodbye.rb
Slide 110
Slide 110 text
Twitter: @sigje Email: [email protected]
Lesson 16: Verify the file was deleted.
110
At command prompt type:
cat motd
Slide 111
Slide 111 text
A resource represents an element or
component of the system.
A resource describes what the element should
be not how to achieve that state of being.
111
Slide 112
Slide 112 text
Twitter: @sigje Email: [email protected]
Review
Created hello.rb and goodbye.rb
Created file resource.
Ran chef commands to create and update resource.
112
Slide 113
Slide 113 text
Twitter: @sigje Email: [email protected]
Review
113
File Resource
File Resource
We created a File resource.
Slide 114
Slide 114 text
Twitter: @sigje Email: [email protected]
There are a number of different resources that are defined in the documentation.
package "apache2"
Review
114
Package Resource
Slide 115
Slide 115 text
Twitter: @sigje Email: [email protected]
There are a number of different resources that are defined in the documentation.
Review
115
Template Resource
template "/etc/apache2/apache2.conf" do
source "apache2.conf.erb"
owner "root"
group "root"
mode "0644"
variables(:allow_override => "All")
notifies :reload, "service[apache2]"
end
Slide 116
Slide 116 text
Twitter: @sigje Email: [email protected]
There are a number of different resources that are defined in the documentation.
Review
116
service "apache2" do
action [:enable,:start]
supports :reload => true
end
Service Resource
Slide 117
Slide 117 text
Twitter: @sigje Email: [email protected]
Review
117
RECIPE
RECIPE
We created two recipes.
Slide 118
Slide 118 text
What is a Recipe?
118
Slide 119
Slide 119 text
A recipe is a file that describes resources and
their desired state.
119
Slide 120
Slide 120 text
Twitter: @sigje Email: [email protected]
Review
120
RECIPE
RECIPE
We created a hello recipe and a goodbye recipe.
Slide 121
Slide 121 text
Twitter: @sigje Email: [email protected]
hello recipe should contain all the
resources required to create motd.
Review
121
Slide 122
Slide 122 text
Twitter: @sigje Email: [email protected]
goodbye recipe should contain all the
resources required to clean up any
resources we created for hello.
Review
122
Twitter: @sigje Email: [email protected]
Lesson 20: Modify recipe to start Apache.
edit webserver.rb.
add content.
service resource
starts and enables httpd service
save file.
130
package ‘httpd’
!
service 'httpd' do
action [:start, :enable]
end
Twitter: @sigje Email: [email protected]
Lesson 24: Apply the resource.
138
At command prompt type:
chef-apply webserver.rb
Slide 139
Slide 139 text
Twitter: @sigje Email: [email protected]
Lesson 25: Reload webpage.
Open a browser.
Shift + Click on reload.
139
Shift +Click
Slide 140
Slide 140 text
Twitter: @sigje Email: [email protected]
Review
140
We created a personalized index.html.
HTML code is embedded in the recipe, our
infrastructure code.
Slide 141
Slide 141 text
How do we separate our web page code from
infrastructure code?
141
Slide 142
Slide 142 text
Twitter: @sigje Email: [email protected]
Lesson 26: Create a working directory.
142
At command prompt type:
mkdir cookbooks
cd cookbooks
Slide 143
Slide 143 text
What is a Cookbook?
143
Slide 144
Slide 144 text
A cookbook is a collection of recipes.
144
Slide 145
Slide 145 text
Twitter: @sigje Email: [email protected]
Lesson 27: Create a webserver cookbook.
145
At command prompt type:
chef generate cookbook webserver
Slide 146
Slide 146 text
Twitter: @sigje Email: [email protected]
Lesson 28: Examine cookbook.
146
At command prompt type:
tree
Slide 147
Slide 147 text
Twitter: @sigje Email: [email protected]
Lesson 29: Create template file.
147
At command prompt type:
chef generate template webserver index.html
Slide 148
Slide 148 text
Twitter: @sigje Email: [email protected]
Lesson 28: Examine cookbook.
148
At command prompt type:
tree
Twitter: @sigje Email: [email protected]
Lesson 30: Edit default recipe.
150
edit default.rb
EDITOR webserver/recipes/default.rb
add content.
package, service, template resources
save file.
package 'httpd'
!
service 'httpd' do
action [:start, :enable]
end
!
template '/var/www/html/index.html'
do
source 'index.html.erb'
end
Slide 151
Slide 151 text
Twitter: @sigje Email: [email protected]
Lesson 30: Edit default recipe.
151
edit default.rb
EDITOR webserver/recipes/default.rb
add content.
package, service, template resources
save file.
package 'httpd'
!
service 'httpd' do
action [:start, :enable]
end
!
template '/var/www/html/index.html'
do
source 'index.html.erb'
end
Slide 152
Slide 152 text
What is a Cookbook?
152
Slide 153
Slide 153 text
A cookbook is a collection of recipes,
templates, custom resources, files, .…
153
Slide 154
Slide 154 text
Twitter: @sigje Email: [email protected]
Lesson 31: Use our cookbook.
154
At command prompt type:
chef-client --local-mode --runlist webserver
Slide 155
Slide 155 text
Twitter: @sigje Email: [email protected]
Lesson 32: Reload webpage.
Open a browser.
Shift + Click on reload.
155
Shift +Click
Slide 156
Slide 156 text
Twitter: @sigje Email: [email protected]
Review
156
separation of our web code and infrastructure
code.
Slide 157
Slide 157 text
Twitter: @sigje Email: [email protected]
Review
157
chef-apply - single recipe
chef-client - multiple recipes
local-mode — not using chef server
runlist — specify the ordered set of recipes
to run.
Twitter: @sigje Email: [email protected]
Objectives:
Working with the Node Object
Explain what the node object is in Chef.
Show details about a node.
Describe node attributes.
160
Slide 161
Slide 161 text
Twitter: @sigje Email: [email protected]
Node Object
161
A node is any physical, virtual, or cloud machine that is configured to be
maintained by a chef-client.
The node object is representation of that node within chef (e.g. in JSON).
Available when you are writing recipes.
Slide 162
Slide 162 text
Twitter: @sigje Email: [email protected]
Lesson 33: Set PATH variable.
162
At command prompt type:
export PATH=$PATH:/opt/chef/embedded/bin:/opt/chefdk/embedded/bin
Slide 163
Slide 163 text
Twitter: @sigje Email: [email protected]
Lesson 34: Run Ohai
163
At command prompt type:
ohai
To page through the output:
ohai | less
Slide 164
Slide 164 text
Twitter: @sigje Email: [email protected]
Node Attributes
164
Ohai populates automatically
discovered attributes of the
node.
Slide 165
Slide 165 text
Twitter: @sigje Email: [email protected]
Node Attributes
165
Ability to programmatically add
additional attributes in recipes
and cookbooks
node.default["apache"]["dir"] = "/etc/apache2"
attribute name attribute value
Slide 166
Slide 166 text
Twitter: @sigje Email: [email protected]
Lesson 35: Create the attribute file.
At command prompt type:
chef generate attribute webserver default
166
Slide 167
Slide 167 text
Twitter: @sigje Email: [email protected]
Lesson 36: Examine cookbook.
167
At command prompt type:
tree
Twitter: @sigje Email: [email protected]
Objectives:
Intro to Community Cookbooks
Find, preview, download cookbooks from the community.
Use knife to work with the Supermarket API.
Download, extract, examine, and implement cookbooks from the Supermarket.
170
Slide 171
Slide 171 text
Twitter: @sigje Email: [email protected]
Chef
171
Company
Open Source Software
Command Line tool
Community
Slide 172
Slide 172 text
Welcome to the Chef Community!
172
Slide 173
Slide 173 text
Twitter: @sigje Email: [email protected]
Supermarket
tools and cookbooks created and shared by the community
173
Slide 174
Slide 174 text
Twitter: @sigje Email: [email protected]
Lesson 38: Browse the Supermarket
website.
Open a browser.
supermarket.getchef.com
174
Slide 175
Slide 175 text
Twitter: @sigje Email: [email protected]
Lesson 38: Browse the Supermarket
website.
type “apache” in the search box.
175
Slide 176
Slide 176 text
Twitter: @sigje Email: [email protected]
Lesson 38: Browse the Supermarket
website.
Many Cookbooks!
176
Slide 177
Slide 177 text
Twitter: @sigje Email: [email protected]
Lesson 39: Inspect the apache cookbook.
Click on “apache”
177
Twitter: @sigje Email: [email protected]
Lesson 40: Search Supermarket from
command line
181
At command prompt type:
knife cookbook site search chef-client
Slide 182
Slide 182 text
Twitter: @sigje Email: [email protected]
Lesson 40: Search Supermarket from
command line
182
At command prompt type:
knife cookbook site show chef-client
Slide 183
Slide 183 text
Twitter: @sigje Email: [email protected]
Lesson 40: Search Supermarket from
command line
183
At command prompt type:
knife cookbook site show chef-client
Slide 184
Slide 184 text
Twitter: @sigje Email: [email protected]
Lesson 41: Download chef-client
cookbook.
184
At command prompt type:
knife cookbook site download chef-client
Slide 185
Slide 185 text
Twitter: @sigje Email: [email protected]
Review
185
Searched Supermarket site for a cookbook.
Downloaded cookbook.
Twitter: @sigje Email: [email protected]
Lesson 42: Extract chef-client cookbook.
187
At command prompt type:
tar zxvf chef-client-3.8.0.tar.gz
Slide 188
Slide 188 text
Twitter: @sigje Email: [email protected]
Lesson 42: Read the chef-client cookbook.
188
Examine the README.md
cat chef-client/README.md
Slide 189
Slide 189 text
Twitter: @sigje Email: [email protected]
Lesson 42: Read the chef-client cookbook.
189
Examine the README.md
Expectations of the cookbook, platform,
data
Recipes
Usage Notes
Slide 190
Slide 190 text
Twitter: @sigje Email: [email protected]
Lesson 43: Use the chef-client cookbook.
190
At command prompt type:
chef-client --local-mode --runlist webserver,chef-client
This will fail because we haven’t set up an org in hosted chef.
Slide 191
Slide 191 text
Conclusion
191
Slide 192
Slide 192 text
Twitter: @sigje Email: [email protected]
Review
Overview of Infrastructure Automation
Intro to Resources, Recipes, Cookbooks
Working with the Node Object
Introduction to Community Cookbooks
192
Slide 193
Slide 193 text
Twitter: @sigje Email: [email protected]
Objectives
Describe Infrastructure Automation
Describe Chef architecture, tools
Read Chef Recipes
193
Slide 194
Slide 194 text
Twitter: @sigje Email: [email protected]
Resources: O’Reilly Books
Learning Chef - Mischa Taylor and Seth Vargo
Experience Level: Beginner to Chef
Customizing Chef - Jon Cowie
Experience Level: Intermediate to Chef
Sekret code: (ONLY AVAILABLE TO ATTENDEES)
50% print discount, 40% ebook discount
194
Slide 195
Slide 195 text
Twitter: @sigje Email: [email protected]
Additional Resources
195
Fundamentals Training, Intermediate Training
Learn Chef
Fundamentals videos
Google Forum
Sign up for Virtual Office Hours
Slide 196
Slide 196 text
Twitter: @sigje Email: [email protected]
THANK YOU
Shirts
Knife Reference Guides
Give me your business card (or email me contact details) and I’ll send you
DRAFT version of Learning Chef ebook (potential spelling mistakes..)
196