SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
Chef
Smart infrastructure automation
Who am I
•

Johannes Skov Frandsen

•

Works primarily with Open
Source

•

Open Source enthusiast since
2000

•

Mostly into web development
og process automation.
What is devops
•

Your software product is not
only the application itself but
also the platform it is running
on

•

Methods used for software
development that can be
valuable in the field of
operations

•

“Missing link” between
developers and sysadmins
What are we trying to solve?
•

Differences in configuration of each environment
Famous: „Works for me”

•

Big amount of time required to configure new
environment

•

Manual configuration changes are prone to errors

•

Lack of local development environment encapsulation

•

Lack of version control for configuration
How are we trying to solve it
•

Make tasks repeatable
•

•

Make tasks rapid
•

•

No manual steps and idempotent.

Fast to build, deploy and restore

Make systems resilient
•

Automated reconfiguration
Devops working areas
•

Configuration management

•

Deployment automation (not todays topic)

•

Build automation (not todays topic)
Configuration management
•

The two biggest contenders are Puppet and
Chef

•

Both a written in Ruby

•

Chef used Ruby as a DSL, Puppet use resource
declaration files.

•

If you are more “Dev” than “Ops”, Chef is
probably your best fit and vice versa.
Chef : http://www.getchef.com/chef/
Puppet : http://puppetlabs.com/
•

•

•

A systems and cloud
infrastructure automation
framework
Makes it easy to deploy
servers and applications to
any physical, virtual, or cloud
location
No matter the size of the
infrastructure
How to use Chef
•

Use it to configure a single machine (chef-solo)

•

Or your entire infrastructure (chef client-server)

•

Use it on-site or in the cloud (build in to amazon
and Rackspace)

•

Use in you local development environment.
Chef in general
Chef is used to describe abstract definitions as
code, defining how you want individual parts of
you infrastructure constructed.

Provisioning

Configuring

Integration
Chef provisioning
•
•
•

Chef can administrate machines via a REST API.
Chef supports Kickstart on Linux, Jumpstart on Solaris and
NIM on AIX.
In virtualised environments, Chef integrates with libvirt and
hypervisors like XEN, KVM, VMware. Chef works well with
VirtualBox.

Provisioning
Configuration
•

Chef is a complete configuration handling tool where recipes
and roles are used to describe how servers are configured.

•

You can describe which packages must be installed, what
services that needs to run, and which configuration files that
needs to be edited.

•

Chef can ensure that all resources are correct installed and
will only make changes to the system if needed.

•

Chef works well in tandem with existing configurations scripts
like shell or perl scripts.
Configuring
Integration
•

Chef can handle separation of configuration logic and
configuration data.

•

As an example, with Chef, when you install a new load
balancer, you can search for installed http servers and
automatically add them to you configuration.

•

Likewise, if you install a new memcached server, you can
advertise this to services that need memcached and
automatically add the new server to their configuration.
Integration
Chef terms
•

Cookbooks
•

•

Environments
•

•

Roles work much the same way as environments, but instead defines a node role. This allows a
cookbook to be used on different nodes with different configurations. When a cookbook is provisioned
in a role, the attributes specified in the cookbook is overridden by those specified in the role.

Nodes
•

•

Different environments can be specifies to distinguish groups of node from others. When a cookbook is
provisioned in a environments, the attributes specified in the cookbook is overridden by those specified
in the environment.

Roles
•

•

Cookbooks describes how to install an individual pieces of software in a generic way across any
number of nodes. Configuration options and settings are specified as attributes with sensible defaults.

Nodes are the finest level of granularity in Chef. The node names a specific instance in the setup and its
configuration can override any attribute define either cookbook, environment or role. Chef server uses
node configurations for provisioning Chef clients.

Data Bags
•

A global variable that is stored as JSON data and is accessible from a Chef Server. The contents of a
data bag include sensitive information and is encrypted.
Solo or Client/Server
•

Chef Solo
•

•

Chef Server
•

•

In cases where you can't use the client server model, Chef solo can be
used to provision the nodes locally. This is handy for provisioning the chef
server itself or for testing new recipes before they are deployed to the Chef
server.

The Chef server manages a repository of all the cookbooks, environments,
roles and nodes in your setup. The Chef server monitors all the node it
manages.

Chef Client
•

The Chef client request its configuration from the Chef server, download the
required software and configures it self.
Show me some code
Chef “Hello World” recipe
package "logrotate" do	
action :install	
end

Chef php cookbook
Recipe
...	
if platform?("redhat")	
node[:php5][:packages][:redhat].each do |pkg|	
package pkg do	
action :install	
end	
end	
end	
if platform?("suse")	
node[:php5][:packages][:suse].each do |pkg|	
package pkg do	
action :install	
end	
end	
end	
...

Attributes
default.php5.packages.redhat = [	
"php", "php-gd", "php-mysql", "php-odbc", "phppdo", "php-soap", "php-xml",	
"php-xmlrpc", "php-mbstring", "php-mcrypt"	
]	

!

default.php5.packages.suse = [	
"php5", "apache2-mod_php5", "php5-calendar",
"php5-ctype", "php5-curl", "php5-dom",	
"php5-exif"	
]
Templates and scripts
Recipe
...	
template "/etc/php5/conf.d/memcache.ini" do	
source "extension"	
mode 0644	
owner "root"	
group "root"	
variables({:extension => "memcache.so"})	
notifies :restart, "service[apache2]"	
end	
...

Template
extension=<%= @extension %>

Recipe
...	
cookbook_file "/tmp/install_memcache.exp" do	
source "install_memcache.exp"	
mode 0600	
owner "root"	
group "root"	
end	
script "install_pecl_memcache" do	
interpreter "bash"	
user "root"	
cwd "/tmp"	
code <<-EOH	
cat /tmp/install_memcache.exp | expect --	
rm /tmp/install_memcache.exp	
EOH	
end	
...

Script
#!/usr/bin/expect	
spawn pecl install memcache	

!
set timeout -1	
!

expect "Enable memcache session handler support?"	
send "yesr"	

!

expect eof
Providers
Recipe

Providers

...	
service "apache2" do	
action :stop	
end	

action :create do	
execute "cp #{new_resource.file}
#{new_resource.file}.#{new_resource.extens
ion}" do	
not_if {::File.exists?
("#{new_resource.file}.#{new_resource.exte
nsion}")}	
only_if {::File.exists?
("#{new_resource.file}")}	
end	
end

!

package "apache2" do	
action :install	
end	

!

# make backup of /etc/apache2/listen.conf	
backup "/etc/apache2/listen.conf"	

!

# change listening port	
sed "/etc/apache2/listen.conf" do	
action :replace	
search "^Listen [0-9]{1,5}"	
replace "Listen #{node[:apache2][:port]}"
end	

!

	

#Allow named virtual hosts	
sed "/etc/apache2/listen.conf" do	
action :replace	
search "^#NameVirtualHost *:[0-9]{1,5}"	
replace "NameVirtualHost *:#{node[:apache2][:port]}"	
end	
...

action :replace do	
execute "sed -e "s|
#{new_resource.search}|
#{new_resource.replace}|g" -i
#{new_resource.file}"	
end	
...
Role skeleton

Roles

Role alfresco

{	

{	

"name": "alfresco",	
"default_attributes": {},	
"override_attributes": {},	
"json_class": "Chef::Role",	
"description": "This installs a alfresco server.",	
"chef_type": "role",	
"run_list": [	
"recipe[networking]",	
	 “recipe[base]",	
	 "recipe[alfresco]",	
	 "recipe[alfresco::ssh]",	
	 "recipe[alfresco::backup]"	
]	

"name": "skeleton",	
"default_attributes": {},	
"override_attributes": {},	
"json_class": "Chef::Role",	
"description": "This installs a skeleton server.",	
"chef_type": "role",	
"run_list": [	
	 "recipe[networking]",	
	 "recipe[base]"	
]	
}

}
Environments

Default

Production

{	

{	

"name": "production",	
"description": “Production environment", 	
"cookbook_versions": {	
"app-master" : "1.1.3",	
"app-slave" : "1.1.3",	
"db-master" : "1.1.3",	
"db-slave" : "1.1.3"	
}, 	
"json_class": "Chef::Environment",	
"chef_type": "environment",	
"default_attributes": {	
"postfix": {	
"aliases": {	
"root": "someone@example.com"	
}	
} }, 	
"override_attributes": {	
"apache2": {	
"admin": "someone@example.com""	
},	
"mysql": {	
"config": {	
"innodb_buffer_pool_size": "6144M"	
},	
"replication": {	
"master": "db-master"	
}	
},	
"backup": {	
"server": “files.example.com"	
}	
}	

"name": "_default",	
"description": "The default Chef environment",	
"cookbook_versions": {	
},	
"json_class": "Chef::Environment",	
"chef_type": "environment",	
"default_attributes": {	
},	
"override_attributes": {	
}	
}

Because you can version
your cookbooks, different
environments can run
different versions.
}
Structure
Lets try it with VirtualBox/
Vagrant
VAGRANTFILE_API_VERSION = "2"

!

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu"
config.vm.box_url = "https://ubuntu-server13.10.box"
config.vm.network :forwarded_port, guest: 80, host: 8080
config.ssh.forward_agent = true
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
config.vm.synced_folder "www/", "/var/www", :create => true

!

config.vm.provision :chef_solo do |chef|
chef.recipe_url = "https://cookbooks.tar.gz"
chef.add_recipe "apache2"
chef.add_recipe "php5"
end
end

VirtualBox : https://www.virtualbox.org/
Vagrant : http://www.vagrantup.com/
Experience
•

Latest project was running ~50 servers with Chef.

•

All developer was using vagrant to get a local
development environment auto configured.

•

Provisioning and configuration of servers takes
minutes… not days.

•

There are tons of free cookbooks available online
but in our experience you will mostly use them for
inspiration and write your own.
Questions
Anything that is in the world when you're born
is normal and ordinary
and is just natural part of the way the world works.

Anything that's invented between
when you're fifteen and thirty-five
is new and exciting and revolutionary
and you can probably get a career in it.

Thanks
Get the slide at http://www.slideshare.net/localgod

Weitere ähnliche Inhalte

Was ist angesagt?

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 - 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
 
Automating your infrastructure with Chef
Automating your infrastructure with ChefAutomating your infrastructure with Chef
Automating your infrastructure with ChefJohn Ewart
 
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
 
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...Chef Software, Inc.
 
Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...
Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...
Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...Chef Software, Inc.
 
Infrastructure Automation with Chef
Infrastructure Automation with ChefInfrastructure Automation with Chef
Infrastructure Automation with ChefJonathan Weiss
 
Automating Infrastructure with Chef
Automating Infrastructure with ChefAutomating Infrastructure with Chef
Automating Infrastructure with ChefJennifer Davis
 
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6Chef
 
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2Node setup, resource, and recipes - Fundamentals Webinar Series Part 2
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2Chef
 
Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3Chef
 
Introduction to Cooking with Chef
Introduction to Cooking with ChefIntroduction to Cooking with Chef
Introduction to Cooking with ChefJohn Osborne
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to ChefKnoldus Inc.
 
Environments - Fundamentals Webinar Series Week 5
Environments - Fundamentals Webinar Series Week 5Environments - Fundamentals Webinar Series Week 5
Environments - Fundamentals Webinar Series Week 5Chef
 
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
 

Was ist angesagt? (20)

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 - 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
 
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
 
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 Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
 
Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...
Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...
Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...
 
The unintended benefits of Chef
The unintended benefits of ChefThe unintended benefits of Chef
The unintended benefits of Chef
 
Infrastructure Automation with Chef
Infrastructure Automation with ChefInfrastructure Automation with Chef
Infrastructure Automation with Chef
 
Automating Infrastructure with Chef
Automating Infrastructure with ChefAutomating Infrastructure with Chef
Automating Infrastructure with Chef
 
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
 
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2Node setup, resource, and recipes - Fundamentals Webinar Series Part 2
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2
 
Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3
 
Introduction to Cooking with Chef
Introduction to Cooking with ChefIntroduction to Cooking with Chef
Introduction to Cooking with Chef
 
Understand Chef
Understand ChefUnderstand Chef
Understand Chef
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 
Introduction to chef
Introduction to chefIntroduction to chef
Introduction to chef
 
Environments - Fundamentals Webinar Series Week 5
Environments - Fundamentals Webinar Series Week 5Environments - Fundamentals Webinar Series Week 5
Environments - Fundamentals Webinar Series Week 5
 
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
 

Andere mochten auch

Infrastructure Automation How to Use Chef For DevOps Success
Infrastructure Automation How to Use Chef For DevOps SuccessInfrastructure Automation How to Use Chef For DevOps Success
Infrastructure Automation How to Use Chef For DevOps SuccessDynatrace
 
CIRCUIT 2015 - AEM Infrastructure Automation with Chef Cookbooks
CIRCUIT 2015 - AEM Infrastructure Automation with Chef CookbooksCIRCUIT 2015 - AEM Infrastructure Automation with Chef Cookbooks
CIRCUIT 2015 - AEM Infrastructure Automation with Chef CookbooksICF CIRCUIT
 
Chef Cookbook Testing and Continuous Integration
Chef Cookbook Testing and Continuous IntegrationChef Cookbook Testing and Continuous Integration
Chef Cookbook Testing and Continuous IntegrationJulian Dunn
 
Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures
Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructuresMaster Chef class: learn how to quickly cook delightful CQ/AEM infrastructures
Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructuresFrançois Le Droff
 
Chef for DevOps - an Introduction
Chef for DevOps - an IntroductionChef for DevOps - an Introduction
Chef for DevOps - an IntroductionSanjeev Sharma
 
Jenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated DeploymentJenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated DeploymentDan Stine
 
Infrastructure Automation with Chef
Infrastructure Automation with ChefInfrastructure Automation with Chef
Infrastructure Automation with ChefAdam Jacob
 

Andere mochten auch (7)

Infrastructure Automation How to Use Chef For DevOps Success
Infrastructure Automation How to Use Chef For DevOps SuccessInfrastructure Automation How to Use Chef For DevOps Success
Infrastructure Automation How to Use Chef For DevOps Success
 
CIRCUIT 2015 - AEM Infrastructure Automation with Chef Cookbooks
CIRCUIT 2015 - AEM Infrastructure Automation with Chef CookbooksCIRCUIT 2015 - AEM Infrastructure Automation with Chef Cookbooks
CIRCUIT 2015 - AEM Infrastructure Automation with Chef Cookbooks
 
Chef Cookbook Testing and Continuous Integration
Chef Cookbook Testing and Continuous IntegrationChef Cookbook Testing and Continuous Integration
Chef Cookbook Testing and Continuous Integration
 
Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures
Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructuresMaster Chef class: learn how to quickly cook delightful CQ/AEM infrastructures
Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures
 
Chef for DevOps - an Introduction
Chef for DevOps - an IntroductionChef for DevOps - an Introduction
Chef for DevOps - an Introduction
 
Jenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated DeploymentJenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated Deployment
 
Infrastructure Automation with Chef
Infrastructure Automation with ChefInfrastructure Automation with Chef
Infrastructure Automation with Chef
 

Ähnlich wie Chef: Smart infrastructure automation

Chef for Openstack
Chef for OpenstackChef for Openstack
Chef for OpenstackMohit Sethi
 
Introduction to OpsWorks for Chef Automate
Introduction to OpsWorks for Chef AutomateIntroduction to OpsWorks for Chef Automate
Introduction to OpsWorks for Chef AutomateAmazon Web Services
 
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
 
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
 
Configuration Management in the Cloud - AWS Online Tech Talks
Configuration Management in the Cloud - AWS Online Tech TalksConfiguration Management in the Cloud - AWS Online Tech Talks
Configuration Management in the Cloud - AWS Online Tech TalksAmazon Web Services
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chefkevsmith
 
Chef, Vagrant and Friends
Chef, Vagrant and FriendsChef, Vagrant and Friends
Chef, Vagrant and FriendsBen McRae
 
Avoiding surprises with Chef and Vagrant
Avoiding surprises with Chef and VagrantAvoiding surprises with Chef and Vagrant
Avoiding surprises with Chef and Vagrantandygale
 
Chef onlinuxonpower
Chef onlinuxonpowerChef onlinuxonpower
Chef onlinuxonpowerMoya Brannan
 
What is Chef and how we use it at tripsta
What is Chef and how we use it at tripstaWhat is Chef and how we use it at tripsta
What is Chef and how we use it at tripstaGiedrius Rimkus
 
Configuration Management with AWS OpsWorks for Chef Automate
Configuration Management with AWS OpsWorks for Chef AutomateConfiguration Management with AWS OpsWorks for Chef Automate
Configuration Management with AWS OpsWorks for Chef AutomateAmazon Web Services
 
CHEF - by Scott Russel
CHEF - by Scott RusselCHEF - by Scott Russel
CHEF - by Scott RusselKangaroot
 
Cook Infrastructure with chef -- Justeat.IN
Cook Infrastructure with chef  -- Justeat.INCook Infrastructure with chef  -- Justeat.IN
Cook Infrastructure with chef -- Justeat.INRajesh Hegde
 

Ähnlich wie Chef: Smart infrastructure automation (20)

Chef for Openstack
Chef for OpenstackChef for Openstack
Chef for Openstack
 
Chef for openstack
Chef for openstackChef for openstack
Chef for openstack
 
Learning chef
Learning chefLearning chef
Learning chef
 
AWS OpsWorks for Chef Automate
AWS OpsWorks for Chef AutomateAWS OpsWorks for Chef Automate
AWS OpsWorks for Chef Automate
 
Introduction to OpsWorks for Chef Automate
Introduction to OpsWorks for Chef AutomateIntroduction to OpsWorks for Chef Automate
Introduction to OpsWorks for Chef Automate
 
Chef fundamentals
Chef fundamentalsChef fundamentals
Chef fundamentals
 
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)
 
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
 
Chef
ChefChef
Chef
 
Configuration Management in the Cloud - AWS Online Tech Talks
Configuration Management in the Cloud - AWS Online Tech TalksConfiguration Management in the Cloud - AWS Online Tech Talks
Configuration Management in the Cloud - AWS Online Tech Talks
 
Introduction to chef
Introduction to chefIntroduction to chef
Introduction to chef
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 
DevOps and Chef improve your life
DevOps and Chef improve your life DevOps and Chef improve your life
DevOps and Chef improve your life
 
Chef, Vagrant and Friends
Chef, Vagrant and FriendsChef, Vagrant and Friends
Chef, Vagrant and Friends
 
Avoiding surprises with Chef and Vagrant
Avoiding surprises with Chef and VagrantAvoiding surprises with Chef and Vagrant
Avoiding surprises with Chef and Vagrant
 
Chef onlinuxonpower
Chef onlinuxonpowerChef onlinuxonpower
Chef onlinuxonpower
 
What is Chef and how we use it at tripsta
What is Chef and how we use it at tripstaWhat is Chef and how we use it at tripsta
What is Chef and how we use it at tripsta
 
Configuration Management with AWS OpsWorks for Chef Automate
Configuration Management with AWS OpsWorks for Chef AutomateConfiguration Management with AWS OpsWorks for Chef Automate
Configuration Management with AWS OpsWorks for Chef Automate
 
CHEF - by Scott Russel
CHEF - by Scott RusselCHEF - by Scott Russel
CHEF - by Scott Russel
 
Cook Infrastructure with chef -- Justeat.IN
Cook Infrastructure with chef  -- Justeat.INCook Infrastructure with chef  -- Justeat.IN
Cook Infrastructure with chef -- Justeat.IN
 

Kürzlich hochgeladen

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Kürzlich hochgeladen (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Chef: Smart infrastructure automation

  • 2. Who am I • Johannes Skov Frandsen • Works primarily with Open Source • Open Source enthusiast since 2000 • Mostly into web development og process automation.
  • 3. What is devops • Your software product is not only the application itself but also the platform it is running on • Methods used for software development that can be valuable in the field of operations • “Missing link” between developers and sysadmins
  • 4. What are we trying to solve? • Differences in configuration of each environment Famous: „Works for me” • Big amount of time required to configure new environment • Manual configuration changes are prone to errors • Lack of local development environment encapsulation • Lack of version control for configuration
  • 5. How are we trying to solve it • Make tasks repeatable • • Make tasks rapid • • No manual steps and idempotent. Fast to build, deploy and restore Make systems resilient • Automated reconfiguration
  • 6. Devops working areas • Configuration management • Deployment automation (not todays topic) • Build automation (not todays topic)
  • 7. Configuration management • The two biggest contenders are Puppet and Chef • Both a written in Ruby • Chef used Ruby as a DSL, Puppet use resource declaration files. • If you are more “Dev” than “Ops”, Chef is probably your best fit and vice versa. Chef : http://www.getchef.com/chef/ Puppet : http://puppetlabs.com/
  • 8. • • • A systems and cloud infrastructure automation framework Makes it easy to deploy servers and applications to any physical, virtual, or cloud location No matter the size of the infrastructure
  • 9. How to use Chef • Use it to configure a single machine (chef-solo) • Or your entire infrastructure (chef client-server) • Use it on-site or in the cloud (build in to amazon and Rackspace) • Use in you local development environment.
  • 10. Chef in general Chef is used to describe abstract definitions as code, defining how you want individual parts of you infrastructure constructed. Provisioning Configuring Integration
  • 11. Chef provisioning • • • Chef can administrate machines via a REST API. Chef supports Kickstart on Linux, Jumpstart on Solaris and NIM on AIX. In virtualised environments, Chef integrates with libvirt and hypervisors like XEN, KVM, VMware. Chef works well with VirtualBox. Provisioning
  • 12. Configuration • Chef is a complete configuration handling tool where recipes and roles are used to describe how servers are configured. • You can describe which packages must be installed, what services that needs to run, and which configuration files that needs to be edited. • Chef can ensure that all resources are correct installed and will only make changes to the system if needed. • Chef works well in tandem with existing configurations scripts like shell or perl scripts. Configuring
  • 13. Integration • Chef can handle separation of configuration logic and configuration data. • As an example, with Chef, when you install a new load balancer, you can search for installed http servers and automatically add them to you configuration. • Likewise, if you install a new memcached server, you can advertise this to services that need memcached and automatically add the new server to their configuration. Integration
  • 14. Chef terms • Cookbooks • • Environments • • Roles work much the same way as environments, but instead defines a node role. This allows a cookbook to be used on different nodes with different configurations. When a cookbook is provisioned in a role, the attributes specified in the cookbook is overridden by those specified in the role. Nodes • • Different environments can be specifies to distinguish groups of node from others. When a cookbook is provisioned in a environments, the attributes specified in the cookbook is overridden by those specified in the environment. Roles • • Cookbooks describes how to install an individual pieces of software in a generic way across any number of nodes. Configuration options and settings are specified as attributes with sensible defaults. Nodes are the finest level of granularity in Chef. The node names a specific instance in the setup and its configuration can override any attribute define either cookbook, environment or role. Chef server uses node configurations for provisioning Chef clients. Data Bags • A global variable that is stored as JSON data and is accessible from a Chef Server. The contents of a data bag include sensitive information and is encrypted.
  • 15. Solo or Client/Server • Chef Solo • • Chef Server • • In cases where you can't use the client server model, Chef solo can be used to provision the nodes locally. This is handy for provisioning the chef server itself or for testing new recipes before they are deployed to the Chef server. The Chef server manages a repository of all the cookbooks, environments, roles and nodes in your setup. The Chef server monitors all the node it manages. Chef Client • The Chef client request its configuration from the Chef server, download the required software and configures it self.
  • 16. Show me some code Chef “Hello World” recipe package "logrotate" do action :install end Chef php cookbook Recipe ... if platform?("redhat") node[:php5][:packages][:redhat].each do |pkg| package pkg do action :install end end end if platform?("suse") node[:php5][:packages][:suse].each do |pkg| package pkg do action :install end end end ... Attributes default.php5.packages.redhat = [ "php", "php-gd", "php-mysql", "php-odbc", "phppdo", "php-soap", "php-xml", "php-xmlrpc", "php-mbstring", "php-mcrypt" ] ! default.php5.packages.suse = [ "php5", "apache2-mod_php5", "php5-calendar", "php5-ctype", "php5-curl", "php5-dom", "php5-exif" ]
  • 17. Templates and scripts Recipe ... template "/etc/php5/conf.d/memcache.ini" do source "extension" mode 0644 owner "root" group "root" variables({:extension => "memcache.so"}) notifies :restart, "service[apache2]" end ... Template extension=<%= @extension %> Recipe ... cookbook_file "/tmp/install_memcache.exp" do source "install_memcache.exp" mode 0600 owner "root" group "root" end script "install_pecl_memcache" do interpreter "bash" user "root" cwd "/tmp" code <<-EOH cat /tmp/install_memcache.exp | expect -- rm /tmp/install_memcache.exp EOH end ... Script #!/usr/bin/expect spawn pecl install memcache ! set timeout -1 ! expect "Enable memcache session handler support?" send "yesr" ! expect eof
  • 18. Providers Recipe Providers ... service "apache2" do action :stop end action :create do execute "cp #{new_resource.file} #{new_resource.file}.#{new_resource.extens ion}" do not_if {::File.exists? ("#{new_resource.file}.#{new_resource.exte nsion}")} only_if {::File.exists? ("#{new_resource.file}")} end end ! package "apache2" do action :install end ! # make backup of /etc/apache2/listen.conf backup "/etc/apache2/listen.conf" ! # change listening port sed "/etc/apache2/listen.conf" do action :replace search "^Listen [0-9]{1,5}" replace "Listen #{node[:apache2][:port]}" end ! #Allow named virtual hosts sed "/etc/apache2/listen.conf" do action :replace search "^#NameVirtualHost *:[0-9]{1,5}" replace "NameVirtualHost *:#{node[:apache2][:port]}" end ... action :replace do execute "sed -e "s| #{new_resource.search}| #{new_resource.replace}|g" -i #{new_resource.file}" end ...
  • 19. Role skeleton Roles Role alfresco { { "name": "alfresco", "default_attributes": {}, "override_attributes": {}, "json_class": "Chef::Role", "description": "This installs a alfresco server.", "chef_type": "role", "run_list": [ "recipe[networking]", “recipe[base]", "recipe[alfresco]", "recipe[alfresco::ssh]", "recipe[alfresco::backup]" ] "name": "skeleton", "default_attributes": {}, "override_attributes": {}, "json_class": "Chef::Role", "description": "This installs a skeleton server.", "chef_type": "role", "run_list": [ "recipe[networking]", "recipe[base]" ] } }
  • 20. Environments Default Production { { "name": "production", "description": “Production environment", "cookbook_versions": { "app-master" : "1.1.3", "app-slave" : "1.1.3", "db-master" : "1.1.3", "db-slave" : "1.1.3" }, "json_class": "Chef::Environment", "chef_type": "environment", "default_attributes": { "postfix": { "aliases": { "root": "someone@example.com" } } }, "override_attributes": { "apache2": { "admin": "someone@example.com"" }, "mysql": { "config": { "innodb_buffer_pool_size": "6144M" }, "replication": { "master": "db-master" } }, "backup": { "server": “files.example.com" } } "name": "_default", "description": "The default Chef environment", "cookbook_versions": { }, "json_class": "Chef::Environment", "chef_type": "environment", "default_attributes": { }, "override_attributes": { } } Because you can version your cookbooks, different environments can run different versions. }
  • 22. Lets try it with VirtualBox/ Vagrant VAGRANTFILE_API_VERSION = "2" ! Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "ubuntu" config.vm.box_url = "https://ubuntu-server13.10.box" config.vm.network :forwarded_port, guest: 80, host: 8080 config.ssh.forward_agent = true config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" config.vm.synced_folder "www/", "/var/www", :create => true ! config.vm.provision :chef_solo do |chef| chef.recipe_url = "https://cookbooks.tar.gz" chef.add_recipe "apache2" chef.add_recipe "php5" end end VirtualBox : https://www.virtualbox.org/ Vagrant : http://www.vagrantup.com/
  • 23.
  • 24. Experience • Latest project was running ~50 servers with Chef. • All developer was using vagrant to get a local development environment auto configured. • Provisioning and configuration of servers takes minutes… not days. • There are tons of free cookbooks available online but in our experience you will mostly use them for inspiration and write your own.
  • 26. Anything that is in the world when you're born is normal and ordinary and is just natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Thanks Get the slide at http://www.slideshare.net/localgod