SlideShare ist ein Scribd-Unternehmen logo
1 von 37
Chef Opswork
Horizontal Scaling, made simple!
- Hamza Waqas
High-level Overview
● A library for configuration management.
● A configuration management system.
● A system integration platform.
● An API for your entire infrastructure.
● Change Management made simple.
Principles
● Idempotent
● Reliability
● Reasonability
● pre-configured defaults settings.
● Hackability.
● Re-usability.
Problems
● You are just an engineer.
● DevOps were never meant to you.
● ~N horizontal scaling nodes.
● System in Production, Images aren’t synced.
● Reflect a change to all nodes without doing
that manually.
● Generic practice missing.
More problems?
● OS packages been updated frequently.
● Inject / Reject any dependency anytime from
entire cluster.
● Multiple clusters of differentiated stack i.e
(App Cluster, MySQL Cluster, glusterFS
cluster).
● Tired of manual SSH connections to each
machine.
Infrastructure Specs
● Manages configuration as Idempotent
Resources.
● Merge them together in Recipe.
● Version Control System on the bottom.
● Keeps underlying generic configuration
separate from `client` environment.
● Extendable and replicable.
Infrastructure as Code
A technical domain revolving around building
and managing infrastructure programmatically.
Enables the reconstruction of the business from
nothing but a source code repository, an
application data backup and bare metal
resources. All you’ve to do is to take care of
middleware building your stack instead of
nodes, itself.
Chef Client
● CLI deployed over node.
● Communicates with Chef Server to pull
configuration and updates.
● Should exists on each node apart of the
belonging role cluster.
● Carries unique IP and name providing
independent identity in server
Chef Server
Chef Server is the major man in the entire
workflow. It communicates with `knife` and
`chef-client` and at the mean time, it also
collaborate to persist recipes and cookbooks of
configuration with versioning so that, `chef-
client` could ask for relevant configuration
later.
Knife
`Knife` is a command-line tool, providing an
ability to communicate with Chef Server and
indirectly with chef-client. If you actually want
to make changes over each ~N node configured
in your Chef- `knife` would be responsible for
passing an argument to `Chef Server` and that
will take care of `chef-client` (nodes) itself.
Cookbook
A cookbook is the fundamental unit of
configuration and policy distribution. A
cookbook defines a scenario and contains
everything that is required to support that
scenario. Measuring Recipes, Attributes, File
distribution and Templates.
Recipe
Its a fundamental unit of cookbook. It should
reside inside `cookbook` respectively.
However, `Recipe` could be written using
`Ruby` language exposing the behavior to be
done on the client. It should define everything
that is required to configure part of a system.
Recipe could be inherited or included inside
another recipe and could be a dependency for
Role
Role is a deliberate tag, assigned to each node
individually making it possible for every node
in a cluster to demonstrate and individually
recognize themselves. Roles usually allow us to
group individual nodes of the cluster to be
recognized based upon the task we’re supposed
to be taken from them.
Run List
● Should exists in node (`chef-client`).
● run_list occupies `recipe` and `roles`
related to the node.
● “run_list”: [
“role[api]”,
“recipe[apt]”, “recipe[redis]”
]
Flow
Abbr
● package: Used to manage packages on a node.
● service: Used to manage service on a node.
● user: Manage user on a node.
● group: Manager user groups.
● template: Manage files with ruby templates.
● cookbook_file: Transfer file from cookbook to node.
● file: manage content of a file on node.
● directory: manage directories on a node.
● execute: Executes a command on a node.
● CRON: Edit an existing cron file on a node.
Installing Chef-
solo
$ curl -L https://www.opscode.com/chef/install.sh | bash
$ wget http://github.com/opscode/chef-repo/tarball/master
$ mv ./chef* ~/chef-repo
$ cd ~/chef-repo
$ mkdir -p .chef
$ echo "cookbook_path [ '/root/chef-repo/cookbooks' ]" >
.chef/knife.rb
$ knife cookbook create redis
$ nano cookbooks/redis/recipes/default.rb
bash "install_redis" do
user 'root'
cwd "/home/hamza"
code <<-EOH
wget http://download.redis.io/releases/redis-3.0.0.tar.gz
tar -xvf redis-3.0.0.tar.gz
cd redis-3.0.0/
make install
EOH
end
execute "Start Redis Server" do
command "redis-server &"
end
$ nano ~/chef-repo/solo.rb
file_cache_path "/root/chef-solo"
cookbook_path "/root/chef-repo/cookbooks"
$ nano ~/chef-repo/web.json
{
“run_list”: [
“recipe[redis]”
]
}
$ chef-solo -c solo.rb -j web.json
Starting Chef Client, version 11.4.0
… … … … … …
… … … … … …
… … … … … …
Chef Client finished, 1 resources updated
Installing Chef
Server
$ apt-get install curl wget build-essential git -y
$ rpm -ivh https://opscode-omnibus-
packages.s3.amazonaws.com/el/6/x86_64/chef-server-
11.0.8-1.el6.x86_64.rpm
$ chef-server-ctl reconfigure
// Installs Erchef, RabbitMQ, PostgreSQL and all the
related dependencies
$ chef-server-ctl test; //Stop apache first.
Installing `chef` on
workstation
$ curl -L https://www.opscode.com/chef/install.sh | bash
…. …. …. …. …. …. …. …. …. …. …. …. …. …. …. …. …. ….
$ chef-client -v
Chef: [VERSION]
$ mkdir -p ~/.chef
// Copy Certificate keys from Chef Server.
$ scp root@10pearls-chef:/etc/chef-server/admin.pem
~/.chef
$ scp root@10pearls-chef:/etc/chef-server/chef-
validator.pem ~/.chef
$ knife configure -i
// It will prompt for values for chef-server url, `user` name,
admin name, location of keys and etc
$ cat ~/.chef/knife.rb
log_level :info
log_location STDOUT
node_name 'knife-user1'
client_key '/root/.chef/knife-user1.pem'
validation_client_name 'chef-validator'
validation_key '/root/.chef/admin.pem'
chef_server_url 'https://chef-server.example.com:443/'
syntax_check_cache_path '/root/.chef/syntax_check_cache'
$ knife client list
// chef-validator , chef-webui
$ knife user list
admin user1 (assuming user1 is what we created with `knife configure -i`)
Writing your first
Cookbook!
$ mkdir -p ~/chef-repo && cd $_;
// Assuming, you have `knife` installed
$ knife cookbook create nginx
$ cd cookbooks/nginx;
// ls: attributes, CHANGELOG.md, definitions, files, libraries, metadata.rb, providers, README.md,
recipes, resources, templates
$ nano recipes/default.rb;
package ‘nginx’ do
action :install
end
service ‘nginx’ do
action [ :enable, :start ]
end
cookbook_file “/usr/share/nginx/www/index.html” do
source “index.html”
mode “0644”
end
Upload to Chef-Server
Once, we’re done with all the basic
configurations and writing our recipes inside
cookbook - it’s now ready to be uploaded to
Chef Server.
PS: `chef-client` (node) will pull the cookbook
from Chef Server
$ cd files/default
$ nano index.html
<html>
<head>
<title>Chef’s alive!</title>
</head>
<body>
<h1>Portland’s Macho! </h1>
</body>
</html>
$ nano metadata.rb
name 'nginx'
maintainer '10Pearls'
maintainer_email 'hamza.waqas@10pearls.com'
license 'All rights reserved'
description 'Installs/Configures nginx'
long_description IO.read(File.join(File.dirname(__FILE__),
'README.md'))
version '0.1.0'
depends "build-essential"
$ knife cookbook upload -a
// OR
$ knife cookbook upload nginx
Deploying
cookbook!
$ chef-client
// from the `node` instance.
The story is over now!
Follow me on Twitter:
https://twitter.com/HamzaWaqas
Follow me on Github:
http://github.com/Arkeolo
geN

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Introduction to chef framework
Introduction to chef frameworkIntroduction to chef framework
Introduction to chef framework
 
The Berkshelf Way
The Berkshelf WayThe Berkshelf Way
The Berkshelf Way
 
Chef
ChefChef
Chef
 
IT Automation with Chef
IT Automation with ChefIT Automation with Chef
IT Automation with Chef
 
Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails App
 
[MDBCI] Mariadb continuous integration tool
[MDBCI] Mariadb continuous integration tool[MDBCI] Mariadb continuous integration tool
[MDBCI] Mariadb continuous integration tool
 
Cook Infrastructure with chef -- Justeat.IN
Cook Infrastructure with chef  -- Justeat.INCook Infrastructure with chef  -- Justeat.IN
Cook Infrastructure with chef -- Justeat.IN
 
Server Installation and Configuration with Chef
Server Installation and Configuration with ChefServer Installation and Configuration with Chef
Server Installation and Configuration with Chef
 
Deploying Rails Apps with Chef and Capistrano
 Deploying Rails Apps with Chef and Capistrano Deploying Rails Apps with Chef and Capistrano
Deploying Rails Apps with Chef and Capistrano
 
Chef, Devops, and You
Chef, Devops, and YouChef, Devops, and You
Chef, Devops, and You
 
Cooking chef
Cooking chefCooking chef
Cooking chef
 
Using Test Kitchen for testing Chef cookbooks
Using Test Kitchen for testing Chef cookbooksUsing Test Kitchen for testing Chef cookbooks
Using Test Kitchen for testing Chef cookbooks
 
How to Write Chef Cookbook
How to Write Chef CookbookHow to Write Chef Cookbook
How to Write Chef Cookbook
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 
Chef: Smart infrastructure automation
Chef: Smart infrastructure automationChef: Smart infrastructure automation
Chef: Smart infrastructure automation
 
Automating your infrastructure with Chef
Automating your infrastructure with ChefAutomating your infrastructure with Chef
Automating your infrastructure with Chef
 
The story became happy with itamae
The story became happy with itamaeThe story became happy with itamae
The story became happy with itamae
 
The Environment Restaurant
The Environment RestaurantThe Environment Restaurant
The Environment Restaurant
 
CLUG 2014-10 - Cookbook CI with Jenkins
CLUG 2014-10 - Cookbook CI with JenkinsCLUG 2014-10 - Cookbook CI with Jenkins
CLUG 2014-10 - Cookbook CI with Jenkins
 
Test Driven Development with Chef
Test Driven Development with ChefTest Driven Development with Chef
Test Driven Development with Chef
 

Ähnlich wie Kickstarter - Chef Opswork

Chef for Openstack
Chef for OpenstackChef for Openstack
Chef for Openstack
Mohit Sethi
 
Introduction To Continuous Compliance & Remediation
Introduction To Continuous Compliance & RemediationIntroduction To Continuous Compliance & Remediation
Introduction To Continuous Compliance & Remediation
Nicole Johnson
 

Ähnlich wie Kickstarter - Chef Opswork (20)

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
 
Chef for openstack
Chef for openstackChef for openstack
Chef for openstack
 
Learning chef
Learning chefLearning chef
Learning 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 for Openstack
Chef for OpenstackChef for Openstack
Chef for Openstack
 
2015 08-11-scdo-meetup
2015 08-11-scdo-meetup2015 08-11-scdo-meetup
2015 08-11-scdo-meetup
 
Chef introduction
Chef introductionChef introduction
Chef introduction
 
Chef or how to make computers do the work for us
Chef or how to make computers do the work for usChef or how to make computers do the work for us
Chef or how to make computers do the work for us
 
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
 
Chef
ChefChef
Chef
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 
AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013
AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013
AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013
 
Introduction to chef
Introduction to chefIntroduction to chef
Introduction to chef
 
Chef, Vagrant and Friends
Chef, Vagrant and FriendsChef, Vagrant and Friends
Chef, Vagrant and Friends
 
Chef - Administration for programmers
Chef - Administration for programmersChef - Administration for programmers
Chef - Administration for programmers
 
Chef vs puppet
Chef vs puppetChef vs puppet
Chef vs puppet
 
Chef fundamentals
Chef fundamentalsChef fundamentals
Chef fundamentals
 
Habitat Managed Chef
Habitat Managed ChefHabitat Managed Chef
Habitat Managed Chef
 
DevOps hackathon Session 2: Basics of Chef
DevOps hackathon Session 2: Basics of ChefDevOps hackathon Session 2: Basics of Chef
DevOps hackathon Session 2: Basics of Chef
 
Introduction To Continuous Compliance & Remediation
Introduction To Continuous Compliance & RemediationIntroduction To Continuous Compliance & Remediation
Introduction To Continuous Compliance & Remediation
 

Kürzlich hochgeladen

Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 

Kürzlich hochgeladen (20)

WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 

Kickstarter - Chef Opswork

  • 1. Chef Opswork Horizontal Scaling, made simple! - Hamza Waqas
  • 2. High-level Overview ● A library for configuration management. ● A configuration management system. ● A system integration platform. ● An API for your entire infrastructure. ● Change Management made simple.
  • 3. Principles ● Idempotent ● Reliability ● Reasonability ● pre-configured defaults settings. ● Hackability. ● Re-usability.
  • 4. Problems ● You are just an engineer. ● DevOps were never meant to you. ● ~N horizontal scaling nodes. ● System in Production, Images aren’t synced. ● Reflect a change to all nodes without doing that manually. ● Generic practice missing.
  • 5. More problems? ● OS packages been updated frequently. ● Inject / Reject any dependency anytime from entire cluster. ● Multiple clusters of differentiated stack i.e (App Cluster, MySQL Cluster, glusterFS cluster). ● Tired of manual SSH connections to each machine.
  • 6. Infrastructure Specs ● Manages configuration as Idempotent Resources. ● Merge them together in Recipe. ● Version Control System on the bottom. ● Keeps underlying generic configuration separate from `client` environment. ● Extendable and replicable.
  • 7. Infrastructure as Code A technical domain revolving around building and managing infrastructure programmatically. Enables the reconstruction of the business from nothing but a source code repository, an application data backup and bare metal resources. All you’ve to do is to take care of middleware building your stack instead of nodes, itself.
  • 8. Chef Client ● CLI deployed over node. ● Communicates with Chef Server to pull configuration and updates. ● Should exists on each node apart of the belonging role cluster. ● Carries unique IP and name providing independent identity in server
  • 9. Chef Server Chef Server is the major man in the entire workflow. It communicates with `knife` and `chef-client` and at the mean time, it also collaborate to persist recipes and cookbooks of configuration with versioning so that, `chef- client` could ask for relevant configuration later.
  • 10. Knife `Knife` is a command-line tool, providing an ability to communicate with Chef Server and indirectly with chef-client. If you actually want to make changes over each ~N node configured in your Chef- `knife` would be responsible for passing an argument to `Chef Server` and that will take care of `chef-client` (nodes) itself.
  • 11. Cookbook A cookbook is the fundamental unit of configuration and policy distribution. A cookbook defines a scenario and contains everything that is required to support that scenario. Measuring Recipes, Attributes, File distribution and Templates.
  • 12. Recipe Its a fundamental unit of cookbook. It should reside inside `cookbook` respectively. However, `Recipe` could be written using `Ruby` language exposing the behavior to be done on the client. It should define everything that is required to configure part of a system. Recipe could be inherited or included inside another recipe and could be a dependency for
  • 13. Role Role is a deliberate tag, assigned to each node individually making it possible for every node in a cluster to demonstrate and individually recognize themselves. Roles usually allow us to group individual nodes of the cluster to be recognized based upon the task we’re supposed to be taken from them.
  • 14. Run List ● Should exists in node (`chef-client`). ● run_list occupies `recipe` and `roles` related to the node. ● “run_list”: [ “role[api]”, “recipe[apt]”, “recipe[redis]” ]
  • 15. Flow
  • 16. Abbr ● package: Used to manage packages on a node. ● service: Used to manage service on a node. ● user: Manage user on a node. ● group: Manager user groups. ● template: Manage files with ruby templates. ● cookbook_file: Transfer file from cookbook to node. ● file: manage content of a file on node. ● directory: manage directories on a node. ● execute: Executes a command on a node. ● CRON: Edit an existing cron file on a node.
  • 18. $ curl -L https://www.opscode.com/chef/install.sh | bash $ wget http://github.com/opscode/chef-repo/tarball/master $ mv ./chef* ~/chef-repo $ cd ~/chef-repo $ mkdir -p .chef $ echo "cookbook_path [ '/root/chef-repo/cookbooks' ]" > .chef/knife.rb $ knife cookbook create redis $ nano cookbooks/redis/recipes/default.rb
  • 19. bash "install_redis" do user 'root' cwd "/home/hamza" code <<-EOH wget http://download.redis.io/releases/redis-3.0.0.tar.gz tar -xvf redis-3.0.0.tar.gz cd redis-3.0.0/ make install EOH end execute "Start Redis Server" do command "redis-server &" end
  • 20. $ nano ~/chef-repo/solo.rb file_cache_path "/root/chef-solo" cookbook_path "/root/chef-repo/cookbooks"
  • 22. $ chef-solo -c solo.rb -j web.json Starting Chef Client, version 11.4.0 … … … … … … … … … … … … … … … … … … Chef Client finished, 1 resources updated
  • 24. $ apt-get install curl wget build-essential git -y $ rpm -ivh https://opscode-omnibus- packages.s3.amazonaws.com/el/6/x86_64/chef-server- 11.0.8-1.el6.x86_64.rpm $ chef-server-ctl reconfigure // Installs Erchef, RabbitMQ, PostgreSQL and all the related dependencies $ chef-server-ctl test; //Stop apache first.
  • 26. $ curl -L https://www.opscode.com/chef/install.sh | bash …. …. …. …. …. …. …. …. …. …. …. …. …. …. …. …. …. …. $ chef-client -v Chef: [VERSION] $ mkdir -p ~/.chef // Copy Certificate keys from Chef Server. $ scp root@10pearls-chef:/etc/chef-server/admin.pem ~/.chef $ scp root@10pearls-chef:/etc/chef-server/chef- validator.pem ~/.chef
  • 27. $ knife configure -i // It will prompt for values for chef-server url, `user` name, admin name, location of keys and etc $ cat ~/.chef/knife.rb log_level :info log_location STDOUT node_name 'knife-user1' client_key '/root/.chef/knife-user1.pem' validation_client_name 'chef-validator' validation_key '/root/.chef/admin.pem' chef_server_url 'https://chef-server.example.com:443/' syntax_check_cache_path '/root/.chef/syntax_check_cache'
  • 28. $ knife client list // chef-validator , chef-webui $ knife user list admin user1 (assuming user1 is what we created with `knife configure -i`)
  • 30. $ mkdir -p ~/chef-repo && cd $_; // Assuming, you have `knife` installed $ knife cookbook create nginx $ cd cookbooks/nginx; // ls: attributes, CHANGELOG.md, definitions, files, libraries, metadata.rb, providers, README.md, recipes, resources, templates $ nano recipes/default.rb; package ‘nginx’ do action :install end service ‘nginx’ do action [ :enable, :start ] end cookbook_file “/usr/share/nginx/www/index.html” do source “index.html” mode “0644” end
  • 31. Upload to Chef-Server Once, we’re done with all the basic configurations and writing our recipes inside cookbook - it’s now ready to be uploaded to Chef Server. PS: `chef-client` (node) will pull the cookbook from Chef Server
  • 32. $ cd files/default $ nano index.html <html> <head> <title>Chef’s alive!</title> </head> <body> <h1>Portland’s Macho! </h1> </body> </html>
  • 33. $ nano metadata.rb name 'nginx' maintainer '10Pearls' maintainer_email 'hamza.waqas@10pearls.com' license 'All rights reserved' description 'Installs/Configures nginx' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version '0.1.0' depends "build-essential"
  • 34. $ knife cookbook upload -a // OR $ knife cookbook upload nginx
  • 36. $ chef-client // from the `node` instance.
  • 37. The story is over now! Follow me on Twitter: https://twitter.com/HamzaWaqas Follow me on Github: http://github.com/Arkeolo geN