2. Our 5 Course meal for today :)
➔ What is chef
➔ How chef works?
➔ How to use it?
➔ Chef alternatives
➔ Lets cook :)
3. 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.
13. ➔ 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?
14.
15. 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
16. 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
18. Cont.
➔ From the command line, copy knife.rb to your ~/learn-chef/.chef directory
eg. cp ~/Downloads/arpitkulria.pem ~/learn-chef/.chef
19. ➔ 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.
20. ➔ You can see all the uploaded cookbooks by command
➔ $ knife cookbook list
Cont.
21. ➔ 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
22. ➔ 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.
23. ➔ 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 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.
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..
Port will be SSH 2222
And IDENTITY_File is location of file
/home/apit/.vagrant/machines/default/virtualbox/private_key
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
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
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
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