Arpit Suthar
Software Consultant
Knoldus Software LLP
Arpit Suthar
Software Consultant
Knoldus Software LLP
Our 5 Course meal for today :)
➔ What is chef
➔ How chef works?
➔ How to use it?
➔ Chef alternatives
➔ Lets cook :)
What is chef
Chef is a powerful automation platform that transforms
complex infrastructure into code, Chef automates how
applications are configured, deployed, and managed across
your network, no matter its size.
Why chef?
Chef Components
➔ Recipe
➔ Cookbook
➔ Node
➔ Chef-client
➔ Workstation
➔ Chef-server
➔ Chef Supermarket
➔ Knife
What is the problem???What is the problem???
The real problem is STATE.The real problem is STATE.
How to use chef?How to use chef?
➔ Download Chef Development Kit
(https://downloads.chef.io/chef-dk/)
➔Create a repo eg. chef-repo (mkdir learn-chef)
➔Create a folder to keep cookbooks (mkdir cookbooks)
➔Now create a cook book eg. (chef generate cookbook learn_chef)
➔ Download Chef Development Kit
(https://downloads.chef.io/chef-dk/)
➔Create a repo eg. chef-repo (mkdir learn-chef)
➔Create a folder to keep cookbooks (mkdir cookbooks)
➔Now create a cook book eg. (chef generate cookbook learn_chef)
How to use chef?How to use chef?
Cont.
Now there is a question where will I upload my recipes (chef server)
➔ Go to https://manage.chef.io/ and create a account on chef.io
➔ Create an organization
➔ Configure your workstation to communicate with the Chef server with knife
➔ knife requires two files to communicate with the Chef server – an RSA private key and a
configuration file.
➔ Every request to the Chef server is authenticated through an RSA public key-pair. The Chef
server holds the public part; you hold the private part.
➔ The configuration file is typically named knife.rb. It contains information such as the Chef
server's URL, the location of your RSA private key, and the default location of your cookbooks.
➔ The next step is to create the ~/learn-chef/.chef directory and add your RSA private key and
knife configuration files. Eg mkdir ~/learn-chef/.chef
Cont.
➔ Generate your knife configuration file
➔ From the command line, copy knife.rb to your ~/learn-chef/.chef directory
eg. cp ~/Downloads/knife.rb ~/learn-chef/.chef
Cont.
➔ Generate your RSA private key file
Cont.
➔ From the command line, copy knife.rb to your ~/learn-chef/.chef directory
eg. cp ~/Downloads/arpitkulria.pem ~/learn-chef/.chef
➔ Run these commands to download the cookbook from Chef Supermarket and
extract it to your ~/learn-chef/cookbooks directory.
$ knife cookbook site download java
➔ In cookbook dir run this command
$ tar -zxvf java-1.39.0.tar.gz
➔ Upload your cookbook to the Chef server
$ knife cookbook upload java
➔ After uploading you can see your cookbooks on https://manage.chef.io/ under
policy tab
Cont.
➔ You can see all the uploaded cookbooks by command
➔ $ knife cookbook list
Cont.
➔ Set up an Ubuntu server, called a node, and prepare your node to be configured by
Chef remotely from your workstation is called bootstrapping a node
We will be doing this on virtual machine
For that you have to download virtual machine from here
➔ and vagrant from here
The next step is to download a base virtual machine image, called a box. Here's how to
download an Ubuntu 14.04 box
$ vagrant box add ubuntu-14.04 http://opscode-vm-
bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-
provisionerless.box
Get a node to bootstrap
➔ Run these commands to bring up an Ubuntu 14.04 instance.
$ vagrant init ubuntu-14.04
$ vagrant up –provider=virtualbox
➔ Now we can connect to our virtual instance by
$ vagrant ssh
➔ If you are using a real instance then you can follow steps from here
➔ Bootstrap the node by
$knife bootstrap localhost --ssh-port PORT --ssh-user vagrant --sudo
--identity-file IDENTITY_FILE_LOCATION --node-name node1 --run-list
'recipe[java]'
Cont.
➔ Now that your updated cookbook is on the Chef server, you can run chef-client on your
node. The chef-client command pulls from Chef server the latest cookbooks from the
node's run-list and applies the run-list to the node.
➔ On virtual machine we can do this by
$ knife ssh localhost --ssh-port PORT 'sudo chef-client' --manual-list --ssh-user vagrant
--identity-file IDENTITY_FILE_LOCATION
Run the cookbook on your node
Chef alternatives
➔ Puppet
➔ Ansible
➔ Salt
➔ Rundeck
Lets cook :)Lets cook :)
Questions and Answers.getOrElse(“You'll get ASAP”)Questions and Answers.getOrElse(“You'll get ASAP”)
Thank youThank you
ReferencesReferences
● https://www.chef.io/
●http://www.slideshare.net/JoshPadnick/introduction-to-chef-autom
●http://www.slideshare.net/jweiss/infrastructure-automation-withch
● https://www.chef.io/
●http://www.slideshare.net/JoshPadnick/introduction-to-chef-autom
●http://www.slideshare.net/jweiss/infrastructure-automation-withch

Introduction to Chef

  • 1.
    Arpit Suthar Software Consultant KnoldusSoftware LLP Arpit Suthar Software Consultant Knoldus Software LLP
  • 2.
    Our 5 Coursemeal for today :) ➔ What is chef ➔ How chef works? ➔ How to use it? ➔ Chef alternatives ➔ Lets cook :)
  • 3.
    What is chef Chefis a powerful automation platform that transforms complex infrastructure into code, Chef automates how applications are configured, deployed, and managed across your network, no matter its size.
  • 4.
  • 5.
    Chef Components ➔ Recipe ➔Cookbook ➔ Node ➔ Chef-client ➔ Workstation ➔ Chef-server ➔ Chef Supermarket ➔ Knife
  • 6.
    What is theproblem???What is the problem???
  • 7.
    The real problemis STATE.The real problem is STATE.
  • 12.
    How to usechef?How to use chef?
  • 13.
    ➔ Download ChefDevelopment Kit (https://downloads.chef.io/chef-dk/) ➔Create a repo eg. chef-repo (mkdir learn-chef) ➔Create a folder to keep cookbooks (mkdir cookbooks) ➔Now create a cook book eg. (chef generate cookbook learn_chef) ➔ Download Chef Development Kit (https://downloads.chef.io/chef-dk/) ➔Create a repo eg. chef-repo (mkdir learn-chef) ➔Create a folder to keep cookbooks (mkdir cookbooks) ➔Now create a cook book eg. (chef generate cookbook learn_chef) How to use chef?How to use chef?
  • 15.
    Cont. Now there isa question where will I upload my recipes (chef server) ➔ Go to https://manage.chef.io/ and create a account on chef.io ➔ Create an organization ➔ Configure your workstation to communicate with the Chef server with knife ➔ knife requires two files to communicate with the Chef server – an RSA private key and a configuration file. ➔ Every request to the Chef server is authenticated through an RSA public key-pair. The Chef server holds the public part; you hold the private part. ➔ The configuration file is typically named knife.rb. It contains information such as the Chef server's URL, the location of your RSA private key, and the default location of your cookbooks. ➔ The next step is to create the ~/learn-chef/.chef directory and add your RSA private key and knife configuration files. Eg mkdir ~/learn-chef/.chef
  • 16.
    Cont. ➔ Generate yourknife configuration file ➔ From the command line, copy knife.rb to your ~/learn-chef/.chef directory eg. cp ~/Downloads/knife.rb ~/learn-chef/.chef
  • 17.
    Cont. ➔ Generate yourRSA private key file
  • 18.
    Cont. ➔ From thecommand line, copy knife.rb to your ~/learn-chef/.chef directory eg. cp ~/Downloads/arpitkulria.pem ~/learn-chef/.chef
  • 19.
    ➔ Run thesecommands to download the cookbook from Chef Supermarket and extract it to your ~/learn-chef/cookbooks directory. $ knife cookbook site download java ➔ In cookbook dir run this command $ tar -zxvf java-1.39.0.tar.gz ➔ Upload your cookbook to the Chef server $ knife cookbook upload java ➔ After uploading you can see your cookbooks on https://manage.chef.io/ under policy tab Cont.
  • 20.
    ➔ You cansee all the uploaded cookbooks by command ➔ $ knife cookbook list Cont.
  • 21.
    ➔ Set upan Ubuntu server, called a node, and prepare your node to be configured by Chef remotely from your workstation is called bootstrapping a node We will be doing this on virtual machine For that you have to download virtual machine from here ➔ and vagrant from here The next step is to download a base virtual machine image, called a box. Here's how to download an Ubuntu 14.04 box $ vagrant box add ubuntu-14.04 http://opscode-vm- bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef- provisionerless.box Get a node to bootstrap
  • 22.
    ➔ Run thesecommands to bring up an Ubuntu 14.04 instance. $ vagrant init ubuntu-14.04 $ vagrant up –provider=virtualbox ➔ Now we can connect to our virtual instance by $ vagrant ssh ➔ If you are using a real instance then you can follow steps from here ➔ Bootstrap the node by $knife bootstrap localhost --ssh-port PORT --ssh-user vagrant --sudo --identity-file IDENTITY_FILE_LOCATION --node-name node1 --run-list 'recipe[java]' Cont.
  • 23.
    ➔ Now thatyour updated cookbook is on the Chef server, you can run chef-client on your node. The chef-client command pulls from Chef server the latest cookbooks from the node's run-list and applies the run-list to the node. ➔ On virtual machine we can do this by $ knife ssh localhost --ssh-port PORT 'sudo chef-client' --manual-list --ssh-user vagrant --identity-file IDENTITY_FILE_LOCATION Run the cookbook on your node
  • 24.
    Chef alternatives ➔ Puppet ➔Ansible ➔ Salt ➔ Rundeck
  • 25.
  • 26.
    Questions and Answers.getOrElse(“You'llget ASAP”)Questions and Answers.getOrElse(“You'll get ASAP”)
  • 27.
  • 28.

Editor's Notes

  • #4 Chef is built around simple concepts: achieving desired state, centralized modeling of IT infrastructure etc. These concepts enable you to quickly manage any infrastructure with Chef. These very same concepts allow Chef to handle the most difficult infrastructure challenges on the planet.
  • #6 Recipe: - Recipes are simple patterns (blocks that define properties and values that map to specific configuration items like packages, files, services, templates, and users) Cookbook: - Collection of recipes Node:- A node is any machine—physical, virtual, cloud, network device, etc.—that is under management by Chef. Chef-client: - A chef-client is installed on every node that is under management by Chef. The chef-client performs all of the configuration tasks that are specified by the run-list and will pull down any required configuration data from the Chef server as it is needed during the chef-client run Workstation : - One (or more) workstations are configured to allow users to author, test, and maintain cookbooks. Cookbooks are uploaded to the Chef server from the workstation. Chef-server:- The Chef server acts as a hub of information. Cookbooks and policy settings are uploaded to the Chef server by users from workstations. Chef Supermarket: - This is the location in which community cookbooks are authored and maintained. Cookbooks that are part of the Chef Supermarket may be used by any Chef user. Knife: - The knife command-line tool to interact with nodes or work with objects on the Chef server..
  • #23 Port will be SSH 2222 And IDENTITY_File is location of file /home/apit/.vagrant/machines/default/virtualbox/private_key
  • #26 Why javascript, why we are bothering to do javascript. beacuse as you know its typical to do web development without javascript. ITs the only language, that's basically supported web browser. So at some point you need javascript code. ITs scripting language, not designed to scale large rich web application
  • #27 Why javascript, why we are bothering to do javascript. beacuse as you know its typical to do web development without javascript. ITs the only language, that's basically supported web browser. So at some point you need javascript code. ITs scripting language, not designed to scale large rich web application
  • #28 Why javascript, why we are bothering to do javascript. beacuse as you know its typical to do web development without javascript. ITs the only language, that's basically supported web browser. So at some point you need javascript code. ITs scripting language, not designed to scale large rich web application
  • #29 Why javascript, why we are bothering to do javascript. beacuse as you know its typical to do web development without javascript. ITs the only language, that's basically supported web browser. So at some point you need javascript code. ITs scripting language, not designed to scale large rich web application