SlideShare a Scribd company logo
1 of 56
Download to read offline
IT Automation with Chef
Anuchit Chalothorn
anuchit@redlinesoft.net
Chef Server
*hosted*
Node
*chef-client*
Workstation
*chef*
Git
Tools
● Chef client tools for admin workstation
● Chef server
● Node with bootstrap
Chef client
Install from http://www.getchef.com/chef/install/ choose
match with your operating system and arch.
Chef client
* for Linux and Mac user can use shell script installer from curl :)
Chef server
You can use on premises chef server or use hosted chef.
choose your version at http://www.getchef.com/chef/choose-
your-version/
Chef server
Chef server
Starter kit
Download Starter Kit on Administration page, then extract to
your home directory.
Starter kit
Git repository
Chef need repository for your cookbook. Change to your chef-
repo and using git to init your repository.
git init
git add .
git commit -m “add starter kit”
* Ref : Customized Git Configuration
Try knife
Change to your Chef repo directory and use knife command line
eg: knife client list
knife client list
Node bootstrap
To add node to Chef server, use knife bootstrap to your node.
knife bootstrap fqdn/ip --sudo -x username -P passwd
-N "nodename"
knife bootstrap 192.168.2.138 --sudo -x username -P passwd -N
"nodename"
Node bootstrap
Node bootstrap
Cookbook
Now write your first cookbook call apache, use knife to create
new cookbook.
knife cookbook create apache
Cookbook : Apache
Edit cookbooks/apache/recipes/default.rb to create
your recipe, with following structure
# install apache
...
# start the apache service make sure the service starts
...
# write our home page
...
Cookbook : Apache
# install apache
package "apache2" do
action :install
end
# start the apache service make sure the service starts
service "apache2" do
action [ :enable, :start]
end
# write our home page
cookbook_file "/var/www/index.html" do
source "index.html"
mode "0644"
end
Cookbook : Apache
At the last part in cookbook_file you must have index.html in
cookbooks/apache/files/default/index.html write
your own content.
<html>
<title>Hello World from Chef</title>
<body>
<h1>Hello World from Chef</h1>
</body>
</html>
Cookbook upload
Each part call resources, which are step to install apache,
enable service and create default html file. Now you are ready to
publish your cookbook.
knife cookbook upload apache
Cookbook
Ubuntu need you to update APT cache before install any
package the you shuld create apt cookbook to update APT
cache first
knife cookbook create apt
Cookbook : apt
Use the execute command to update APT cache
execute "apt-get update" do
command "apt-get update"
end
Cookbook upload
Now you are ready to publish your apt cookbook.
knife cookbook upload apt
Cookbook
Run list
After upload cookbook to Chef server, you must create a run list
for the node to apply recipes.
Run list
Run list
Chef Client
Now back to your node, run command sudo chef-client to
apply run list.
sudo chef-client
* Run remote by knife: knife ssh ‘name:*’ ‘sudo chef-client’ -x username -P password
Check the result
Open your browser and browse to your node with an ip address
or fqdn.
Check the report
Goto Chef server to check your report; success, failure, aborted.
Reports
Reports
Make more dynamic
Your first recipe support only Ubuntu node, then make support
another distributions you may add following items for more
dynamically
● Attributes
● Templates
● Metadata
Attributes
Add cookbooks/apache/attributes/default.rb as a
default values for your recipes.
case node["platform_family"]
when "debian"
default["package_name"] = "apache2"
default["service_name"] = "apache2"
default["document_root"] = "/var/www"
when "rhel"
default["package_name"] = "httpd"
default["service_name"] = "httpd"
default["document_root"] = "/var/www/html"
end
Recipes
# install apache
package node["package_name"] do
action :install
end
# start the apache service
# make sure the service starts
service node["service_name"] do
action [ :enable, :start]
end
# write our home page
template "#{node["document_root"]}/index.html" do
source "index.html.erb"
mode "0644"
end
Templates
Add template file for your index.html in
cookbooks/apache/templates/default/index.html.
erb
<html>
<title>Hello World</title>
<body>
<h1>Hello World from <%= node["fqdn"] %>!</h1>
</body>
</html>
Metadata
Edit metadata file in cookbooks/apache/metadata.rb
name 'apache'
maintainer 'Anuchit Chalothorn'
maintainer_email 'anuchit@redlinesoft.net'
license 'All rights reserved'
description 'Installs/Configures apache'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.
md'))
version '0.1.0'
Rules
Roles allow you to encapsulate run lists and attribute required
for a server to be. eg:
● Web Server
● Database Server
● etc
Rules
Create role for your web server by adding a webserver.rb in
roles directory edit with following content.
name "webserver"
description "Web Server"
run_list "recipe[apache]"
default_attributes({
"company" => "RedLineSoft"
})
Rules
Create role for your web server by adding a base-ubuntu.rb
in roles directory edit with following content.
name "base-ubuntu"
description "Base Ubuntu"
run_list "recipe[apt]"
Rules
Update your cookbook version in metadata and add new role
with following knife command
knife role create from file webserver.rb
knife role create from file base-ubuntu.rb
knife cookbook upload apache
Rules
Goto Chef server and add new roles to your node instead of
using cookbook then use chef-client to apply recipes
Rules
Community Cookbook
Chef also have a community cookbooks. You can find an
interest cookbook at http://community.opscode.
com/cookbooks
Community Cookbook
Community Cookbook
You can use community cookbook from Chef community by
using knife.
knife cookbook site download mysql 4.1.2
You'll get an archive file mysql-4.1.2.tar.gz in your chef-
repo
* Easy way use; knife cookbook site install mysql
Using Community Cookbook
Now you get the archive cookbook from community already
then extract an archive to cookbooks directory
tar zxvf mysql-4.1.2.tar.gz -C cookbooks/
Using Community Cookbook
Check dependency in metadata.rb, if you don’t have please
download them, for homebrew, windows is dependency for OSX
and Windows if you not use it, just comment it.
depends 'openssl', '~> 1.1'
depends 'build-essential', '~> 1.4'
#depends 'homebrew'
#depends 'windows'
Using Community Cookbook
Read the recipe files, mysql cookbook has mysql::client,
mysql::server and mysql::ruby so you can specify which
recipe you will use.
Using Community Cookbook
Download dependency cookbook for mysql
knife cookbook site download openssl 1.1.0
knife cookbook site download build-essential 1.4.4
tar zxvf openssl-1.1.0.tar.gz -C cookbooks/
tar zxvf build-essential-1.4.4.tar.gz -C cookbooks/
knife cookbook upload build-essential openssl mysql
Using Community Cookbook
Create new role webserver-mysql to install webserver and mysql
in this role.
name "webserver-mysql"
description "Webserver and MySQL Database Server"
run_list "recipe[apache]","recipe[mysql::client]","recipe[mysql::
server]"
knife role from file webserver-mysql.rb
Using Community Cookbook
Goto Chef server add role to node then apply webserver-
mysql role in node
Using Community Cookbook
Using Community Cookbook
Goto node and run chef-client to apply role.
sudo chef-client
Further Resources
● http://www.opscode.com
● http://community.opscode.com
● http://docs.opscode.com
● http://learnchef.com
● http://youtube.com/user/Opscode
IT Automation with Chef

More Related Content

What's hot

Automating Infrastructure with Chef
Automating Infrastructure with ChefAutomating Infrastructure with Chef
Automating Infrastructure with ChefJennifer Davis
 
DevOps Hackathon - Session 1: Vagrant
DevOps Hackathon - Session 1: VagrantDevOps Hackathon - Session 1: Vagrant
DevOps Hackathon - Session 1: VagrantAntons Kranga
 
Monitoring and tuning your chef server - chef conf talk
Monitoring and tuning your chef server - chef conf talk Monitoring and tuning your chef server - chef conf talk
Monitoring and tuning your chef server - chef conf talk Andrew DuFour
 
Chef Fundamentals Training Series Module 2: Workstation Setup
Chef Fundamentals Training Series Module 2: Workstation SetupChef Fundamentals Training Series Module 2: Workstation Setup
Chef Fundamentals Training Series Module 2: Workstation SetupChef Software, Inc.
 
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
 
Opscode Webinar: Managing Your VMware Infrastructure with Chef
Opscode Webinar: Managing Your VMware Infrastructure with ChefOpscode Webinar: Managing Your VMware Infrastructure with Chef
Opscode Webinar: Managing Your VMware Infrastructure with ChefChef Software, Inc.
 
Cookbook testing with KitcenCI and Serverrspec
Cookbook testing with KitcenCI and ServerrspecCookbook testing with KitcenCI and Serverrspec
Cookbook testing with KitcenCI and ServerrspecDaniel Paulus
 
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.
 
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012Patrick McDonnell
 
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.
 
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
 
Server Installation and Configuration with Chef
Server Installation and Configuration with ChefServer Installation and Configuration with Chef
Server Installation and Configuration with ChefRaimonds Simanovskis
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to ChefKnoldus Inc.
 
Infrastructure Automation with Chef & Ansible
Infrastructure Automation with Chef & AnsibleInfrastructure Automation with Chef & Ansible
Infrastructure Automation with Chef & Ansiblewajrcs
 
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
 
Environments - Fundamentals Webinar Series Week 5
Environments - Fundamentals Webinar Series Week 5Environments - Fundamentals Webinar Series Week 5
Environments - Fundamentals Webinar Series Week 5Chef
 
Chef, Devops, and You
Chef, Devops, and YouChef, Devops, and You
Chef, Devops, and YouBryan Berry
 
Cook Infrastructure with chef -- Justeat.IN
Cook Infrastructure with chef  -- Justeat.INCook Infrastructure with chef  -- Justeat.IN
Cook Infrastructure with chef -- Justeat.INRajesh Hegde
 

What's hot (20)

Automating Infrastructure with Chef
Automating Infrastructure with ChefAutomating Infrastructure with Chef
Automating Infrastructure with Chef
 
DevOps Hackathon - Session 1: Vagrant
DevOps Hackathon - Session 1: VagrantDevOps Hackathon - Session 1: Vagrant
DevOps Hackathon - Session 1: Vagrant
 
Monitoring and tuning your chef server - chef conf talk
Monitoring and tuning your chef server - chef conf talk Monitoring and tuning your chef server - chef conf talk
Monitoring and tuning your chef server - chef conf talk
 
Chef
ChefChef
Chef
 
Chef Fundamentals Training Series Module 2: Workstation Setup
Chef Fundamentals Training Series Module 2: Workstation SetupChef Fundamentals Training Series Module 2: Workstation Setup
Chef Fundamentals Training Series Module 2: Workstation Setup
 
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
 
Opscode Webinar: Managing Your VMware Infrastructure with Chef
Opscode Webinar: Managing Your VMware Infrastructure with ChefOpscode Webinar: Managing Your VMware Infrastructure with Chef
Opscode Webinar: Managing Your VMware Infrastructure with Chef
 
Cookbook testing with KitcenCI and Serverrspec
Cookbook testing with KitcenCI and ServerrspecCookbook testing with KitcenCI and Serverrspec
Cookbook testing with KitcenCI and Serverrspec
 
Cooking with Chef
Cooking with ChefCooking with Chef
Cooking with Chef
 
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...
 
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
 
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...
 
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
 
Server Installation and Configuration with Chef
Server Installation and Configuration with ChefServer Installation and Configuration with Chef
Server Installation and Configuration with Chef
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 
Infrastructure Automation with Chef & Ansible
Infrastructure Automation with Chef & AnsibleInfrastructure Automation with Chef & Ansible
Infrastructure Automation with Chef & Ansible
 
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
 
Environments - Fundamentals Webinar Series Week 5
Environments - Fundamentals Webinar Series Week 5Environments - Fundamentals Webinar Series Week 5
Environments - Fundamentals Webinar Series Week 5
 
Chef, Devops, and You
Chef, Devops, and YouChef, Devops, and You
Chef, Devops, and You
 
Cook Infrastructure with chef -- Justeat.IN
Cook Infrastructure with chef  -- Justeat.INCook Infrastructure with chef  -- Justeat.IN
Cook Infrastructure with chef -- Justeat.IN
 

Viewers also liked

Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chefkevsmith
 
Velocity2011 chef-workshop
Velocity2011 chef-workshopVelocity2011 chef-workshop
Velocity2011 chef-workshopjtimberman
 
Testable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and DockerTestable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and DockerMandi Walls
 
Introducing Chef | An IT automation for speed and awesomeness
Introducing Chef | An IT automation for speed and awesomenessIntroducing Chef | An IT automation for speed and awesomeness
Introducing Chef | An IT automation for speed and awesomenessRamit Surana
 
Overview of chef ( Infrastructure as a Code )
Overview of chef ( Infrastructure as a Code )Overview of chef ( Infrastructure as a Code )
Overview of chef ( Infrastructure as a Code )Pravin Mishra
 
Chef Cookbook Testing and Continuous Integration
Chef Cookbook Testing and Continuous IntegrationChef Cookbook Testing and Continuous Integration
Chef Cookbook Testing and Continuous IntegrationJulian Dunn
 
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
 
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
 

Viewers also liked (12)

Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 
Velocity2011 chef-workshop
Velocity2011 chef-workshopVelocity2011 chef-workshop
Velocity2011 chef-workshop
 
Chef
ChefChef
Chef
 
Devops madrid: successful case in AWS
Devops madrid: successful case in AWSDevops madrid: successful case in AWS
Devops madrid: successful case in AWS
 
Testable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and DockerTestable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and Docker
 
Introducing Chef | An IT automation for speed and awesomeness
Introducing Chef | An IT automation for speed and awesomenessIntroducing Chef | An IT automation for speed and awesomeness
Introducing Chef | An IT automation for speed and awesomeness
 
DevOps and Chef improve your life
DevOps and Chef improve your life DevOps and Chef improve your life
DevOps and Chef improve your life
 
Overview of chef ( Infrastructure as a Code )
Overview of chef ( Infrastructure as a Code )Overview of chef ( Infrastructure as a Code )
Overview of chef ( Infrastructure as a Code )
 
Chef Cookbook Testing and Continuous Integration
Chef Cookbook Testing and Continuous IntegrationChef Cookbook Testing and Continuous Integration
Chef Cookbook Testing and Continuous Integration
 
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
 
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
 

Similar to IT Automation with Chef

Configuration of Apache Web Server On CentOS 8
Configuration of Apache Web Server On CentOS 8Configuration of Apache Web Server On CentOS 8
Configuration of Apache Web Server On CentOS 8Kaan Aslandağ
 
Cooking Perl with Chef: Real World Tutorial with Jitterbug
Cooking Perl with Chef: Real World Tutorial with JitterbugCooking Perl with Chef: Real World Tutorial with Jitterbug
Cooking Perl with Chef: Real World Tutorial with JitterbugDavid Golden
 
Azure handsonlab
Azure handsonlabAzure handsonlab
Azure handsonlabChef
 
Introduction to Chef - April 22 2015
Introduction to Chef - April 22 2015Introduction to Chef - April 22 2015
Introduction to Chef - April 22 2015Jennifer Davis
 
DevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven InfrastructureDevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven InfrastructureAntons Kranga
 
Introduction to chef framework
Introduction to chef frameworkIntroduction to chef framework
Introduction to chef frameworkmorgoth
 
Calico with open stack and chef
Calico with open stack and chefCalico with open stack and chef
Calico with open stack and chefD.Rajesh Kumar
 
Automating your infrastructure with Chef
Automating your infrastructure with ChefAutomating your infrastructure with Chef
Automating your infrastructure with ChefJohn Ewart
 
Bugzilla Installation Process
Bugzilla Installation ProcessBugzilla Installation Process
Bugzilla Installation ProcessVino Harikrishnan
 
Chef, Vagrant, and VirtualBox
Chef, Vagrant, and VirtualBoxChef, Vagrant, and VirtualBox
Chef, Vagrant, and VirtualBoxJason Vanderhoof
 
Deploying your rails application to a clean ubuntu 10
Deploying your rails application to a clean ubuntu 10Deploying your rails application to a clean ubuntu 10
Deploying your rails application to a clean ubuntu 10Maurício Linhares
 
Cooking Perl with Chef: Hello World Tutorial
Cooking Perl with Chef: Hello World TutorialCooking Perl with Chef: Hello World Tutorial
Cooking Perl with Chef: Hello World TutorialDavid Golden
 
A Supermarket of Your Own: Running a Private Chef Supermarket
A Supermarket of Your Own: Running a Private Chef SupermarketA Supermarket of Your Own: Running a Private Chef Supermarket
A Supermarket of Your Own: Running a Private Chef SupermarketNell Shamrell-Harrington
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuis Rodríguez Castromil
 
Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015Chef
 

Similar to IT Automation with Chef (20)

Configuration of Apache Web Server On CentOS 8
Configuration of Apache Web Server On CentOS 8Configuration of Apache Web Server On CentOS 8
Configuration of Apache Web Server On CentOS 8
 
Cooking Perl with Chef: Real World Tutorial with Jitterbug
Cooking Perl with Chef: Real World Tutorial with JitterbugCooking Perl with Chef: Real World Tutorial with Jitterbug
Cooking Perl with Chef: Real World Tutorial with Jitterbug
 
Azure handsonlab
Azure handsonlabAzure handsonlab
Azure handsonlab
 
Introduction to Chef - April 22 2015
Introduction to Chef - April 22 2015Introduction to Chef - April 22 2015
Introduction to Chef - April 22 2015
 
DevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven InfrastructureDevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven Infrastructure
 
Chef training - Day3
Chef training - Day3Chef training - Day3
Chef training - Day3
 
Introduction to chef framework
Introduction to chef frameworkIntroduction to chef framework
Introduction to chef framework
 
Calico with open stack and chef
Calico with open stack and chefCalico with open stack and chef
Calico with open stack and chef
 
Automating your infrastructure with Chef
Automating your infrastructure with ChefAutomating your infrastructure with Chef
Automating your infrastructure with Chef
 
Bugzilla Installation Process
Bugzilla Installation ProcessBugzilla Installation Process
Bugzilla Installation Process
 
Chef, Vagrant, and VirtualBox
Chef, Vagrant, and VirtualBoxChef, Vagrant, and VirtualBox
Chef, Vagrant, and VirtualBox
 
Deploying your rails application to a clean ubuntu 10
Deploying your rails application to a clean ubuntu 10Deploying your rails application to a clean ubuntu 10
Deploying your rails application to a clean ubuntu 10
 
Cooking Perl with Chef: Hello World Tutorial
Cooking Perl with Chef: Hello World TutorialCooking Perl with Chef: Hello World Tutorial
Cooking Perl with Chef: Hello World Tutorial
 
Apache - Quick reference guide
Apache - Quick reference guideApache - Quick reference guide
Apache - Quick reference guide
 
A Supermarket of Your Own: Running a Private Chef Supermarket
A Supermarket of Your Own: Running a Private Chef SupermarketA Supermarket of Your Own: Running a Private Chef Supermarket
A Supermarket of Your Own: Running a Private Chef Supermarket
 
Understand Chef
Understand ChefUnderstand Chef
Understand Chef
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
 
Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015
 

More from Anuchit Chalothorn (20)

Flutter Workshop 2021 @ ARU
Flutter Workshop 2021 @ ARUFlutter Workshop 2021 @ ARU
Flutter Workshop 2021 @ ARU
 
Flutter workshop @ bang saen 2020
Flutter workshop @ bang saen 2020Flutter workshop @ bang saen 2020
Flutter workshop @ bang saen 2020
 
13 web service integration
13 web service integration13 web service integration
13 web service integration
 
09 material design
09 material design09 material design
09 material design
 
07 intent
07 intent07 intent
07 intent
 
05 binding and action
05 binding and action05 binding and action
05 binding and action
 
04 layout design and basic widget
04 layout design and basic widget04 layout design and basic widget
04 layout design and basic widget
 
03 activity life cycle
03 activity life cycle03 activity life cycle
03 activity life cycle
 
02 create your first app
02 create your first app02 create your first app
02 create your first app
 
01 introduction
01 introduction 01 introduction
01 introduction
 
Material Theme
Material ThemeMaterial Theme
Material Theme
 
00 Android Wear Setup Emulator
00 Android Wear Setup Emulator00 Android Wear Setup Emulator
00 Android Wear Setup Emulator
 
MongoDB Replication Cluster
MongoDB Replication ClusterMongoDB Replication Cluster
MongoDB Replication Cluster
 
MongoDB Shard Cluster
MongoDB Shard ClusterMongoDB Shard Cluster
MongoDB Shard Cluster
 
IT Automation with Puppet Enterprise
IT Automation with Puppet EnterpriseIT Automation with Puppet Enterprise
IT Automation with Puppet Enterprise
 
Using PhoneGap Command Line
Using PhoneGap Command LineUsing PhoneGap Command Line
Using PhoneGap Command Line
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
 
OpenStack Cheat Sheet V2
OpenStack Cheat Sheet V2OpenStack Cheat Sheet V2
OpenStack Cheat Sheet V2
 
REST API with CakePHP
REST API with CakePHPREST API with CakePHP
REST API with CakePHP
 
Open Stack Cheat Sheet V1
Open Stack Cheat Sheet V1Open Stack Cheat Sheet V1
Open Stack Cheat Sheet V1
 

Recently uploaded

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 

Recently uploaded (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 

IT Automation with Chef

  • 1. IT Automation with Chef Anuchit Chalothorn anuchit@redlinesoft.net
  • 3. Tools ● Chef client tools for admin workstation ● Chef server ● Node with bootstrap
  • 4. Chef client Install from http://www.getchef.com/chef/install/ choose match with your operating system and arch.
  • 5. Chef client * for Linux and Mac user can use shell script installer from curl :)
  • 6. Chef server You can use on premises chef server or use hosted chef. choose your version at http://www.getchef.com/chef/choose- your-version/
  • 9. Starter kit Download Starter Kit on Administration page, then extract to your home directory.
  • 11. Git repository Chef need repository for your cookbook. Change to your chef- repo and using git to init your repository. git init git add . git commit -m “add starter kit” * Ref : Customized Git Configuration
  • 12. Try knife Change to your Chef repo directory and use knife command line eg: knife client list knife client list
  • 13. Node bootstrap To add node to Chef server, use knife bootstrap to your node. knife bootstrap fqdn/ip --sudo -x username -P passwd -N "nodename" knife bootstrap 192.168.2.138 --sudo -x username -P passwd -N "nodename"
  • 16. Cookbook Now write your first cookbook call apache, use knife to create new cookbook. knife cookbook create apache
  • 17. Cookbook : Apache Edit cookbooks/apache/recipes/default.rb to create your recipe, with following structure # install apache ... # start the apache service make sure the service starts ... # write our home page ...
  • 18. Cookbook : Apache # install apache package "apache2" do action :install end # start the apache service make sure the service starts service "apache2" do action [ :enable, :start] end # write our home page cookbook_file "/var/www/index.html" do source "index.html" mode "0644" end
  • 19. Cookbook : Apache At the last part in cookbook_file you must have index.html in cookbooks/apache/files/default/index.html write your own content. <html> <title>Hello World from Chef</title> <body> <h1>Hello World from Chef</h1> </body> </html>
  • 20. Cookbook upload Each part call resources, which are step to install apache, enable service and create default html file. Now you are ready to publish your cookbook. knife cookbook upload apache
  • 21. Cookbook Ubuntu need you to update APT cache before install any package the you shuld create apt cookbook to update APT cache first knife cookbook create apt
  • 22. Cookbook : apt Use the execute command to update APT cache execute "apt-get update" do command "apt-get update" end
  • 23. Cookbook upload Now you are ready to publish your apt cookbook. knife cookbook upload apt
  • 25. Run list After upload cookbook to Chef server, you must create a run list for the node to apply recipes.
  • 28. Chef Client Now back to your node, run command sudo chef-client to apply run list. sudo chef-client * Run remote by knife: knife ssh ‘name:*’ ‘sudo chef-client’ -x username -P password
  • 29. Check the result Open your browser and browse to your node with an ip address or fqdn.
  • 30. Check the report Goto Chef server to check your report; success, failure, aborted.
  • 33. Make more dynamic Your first recipe support only Ubuntu node, then make support another distributions you may add following items for more dynamically ● Attributes ● Templates ● Metadata
  • 34. Attributes Add cookbooks/apache/attributes/default.rb as a default values for your recipes. case node["platform_family"] when "debian" default["package_name"] = "apache2" default["service_name"] = "apache2" default["document_root"] = "/var/www" when "rhel" default["package_name"] = "httpd" default["service_name"] = "httpd" default["document_root"] = "/var/www/html" end
  • 35. Recipes # install apache package node["package_name"] do action :install end # start the apache service # make sure the service starts service node["service_name"] do action [ :enable, :start] end # write our home page template "#{node["document_root"]}/index.html" do source "index.html.erb" mode "0644" end
  • 36. Templates Add template file for your index.html in cookbooks/apache/templates/default/index.html. erb <html> <title>Hello World</title> <body> <h1>Hello World from <%= node["fqdn"] %>!</h1> </body> </html>
  • 37. Metadata Edit metadata file in cookbooks/apache/metadata.rb name 'apache' maintainer 'Anuchit Chalothorn' maintainer_email 'anuchit@redlinesoft.net' license 'All rights reserved' description 'Installs/Configures apache' long_description IO.read(File.join(File.dirname(__FILE__), 'README. md')) version '0.1.0'
  • 38. Rules Roles allow you to encapsulate run lists and attribute required for a server to be. eg: ● Web Server ● Database Server ● etc
  • 39. Rules Create role for your web server by adding a webserver.rb in roles directory edit with following content. name "webserver" description "Web Server" run_list "recipe[apache]" default_attributes({ "company" => "RedLineSoft" })
  • 40. Rules Create role for your web server by adding a base-ubuntu.rb in roles directory edit with following content. name "base-ubuntu" description "Base Ubuntu" run_list "recipe[apt]"
  • 41. Rules Update your cookbook version in metadata and add new role with following knife command knife role create from file webserver.rb knife role create from file base-ubuntu.rb knife cookbook upload apache
  • 42. Rules Goto Chef server and add new roles to your node instead of using cookbook then use chef-client to apply recipes
  • 43. Rules
  • 44. Community Cookbook Chef also have a community cookbooks. You can find an interest cookbook at http://community.opscode. com/cookbooks
  • 46. Community Cookbook You can use community cookbook from Chef community by using knife. knife cookbook site download mysql 4.1.2 You'll get an archive file mysql-4.1.2.tar.gz in your chef- repo * Easy way use; knife cookbook site install mysql
  • 47. Using Community Cookbook Now you get the archive cookbook from community already then extract an archive to cookbooks directory tar zxvf mysql-4.1.2.tar.gz -C cookbooks/
  • 48. Using Community Cookbook Check dependency in metadata.rb, if you don’t have please download them, for homebrew, windows is dependency for OSX and Windows if you not use it, just comment it. depends 'openssl', '~> 1.1' depends 'build-essential', '~> 1.4' #depends 'homebrew' #depends 'windows'
  • 49. Using Community Cookbook Read the recipe files, mysql cookbook has mysql::client, mysql::server and mysql::ruby so you can specify which recipe you will use.
  • 50. Using Community Cookbook Download dependency cookbook for mysql knife cookbook site download openssl 1.1.0 knife cookbook site download build-essential 1.4.4 tar zxvf openssl-1.1.0.tar.gz -C cookbooks/ tar zxvf build-essential-1.4.4.tar.gz -C cookbooks/ knife cookbook upload build-essential openssl mysql
  • 51. Using Community Cookbook Create new role webserver-mysql to install webserver and mysql in this role. name "webserver-mysql" description "Webserver and MySQL Database Server" run_list "recipe[apache]","recipe[mysql::client]","recipe[mysql:: server]" knife role from file webserver-mysql.rb
  • 52. Using Community Cookbook Goto Chef server add role to node then apply webserver- mysql role in node
  • 54. Using Community Cookbook Goto node and run chef-client to apply role. sudo chef-client
  • 55. Further Resources ● http://www.opscode.com ● http://community.opscode.com ● http://docs.opscode.com ● http://learnchef.com ● http://youtube.com/user/Opscode