Thursday, October 6, 2016

DevOps - Chef

Chef is a configuration management and automation platform from Opscode. Chef used to automate, test and replicate infrastructure with ease.

Chef available in two format 
  1   Chef – Solo 
     a   Used to install, configure and manage the packages on single environment
  2   Chef - client and server configuration
     a   Chef – Server will be used 
     b   Chef – Client will deployed on linux/windows machine and configured with server

How to Use Chef – Client and server

Setup Chef Server
  1   Download the latest Chef server core
  2   Install the server
  3   Run the chef-server-ctl command to start the Chef server services
  4   Create a User and Organization to link your Chef server with workstations and nodes


Workstations (Client)
Chef workstation is used create and configure any recipes, cookbooks, attributes, and other changes made to Chef Configurations
  1   Download the latest Chef Development Kit for Windows/Linux 
  2   Install ChefDK (based on DK you downloaded)
  3   Generate the chef-repo 
     a   For Linux - mkdir .chef
  4   Navigate/Move to the newly-created directory (/.chef)
  5   Add the RSA Private Keys (You can download same from chef website)
     a   https://manage.chef.io/login
     b   Open the Chef management console.
     c   Click Policy.
     d   Click Clients.
     e   Click Create.
     f   Copy the private key or download and save the private key locally
 6   Generate knife.rb
 7   Create a knife configuration file by navigating to ~/chef-repo/.chef folder and create a file named knife.rb
 8   Add following details into file and save
log_level                :info
log_location             STDOUT
node_name                'username'
client_key               '~/chef-repo/.chef/username.pem'
validation_client_name   'shortname-validator'
validation_key           '~/chef-repo/.chef/shortname.pem'
chef_server_url          'https://123.45.67.89/organizations/shortname'
syntax_check_cache_path  '~/chef-repo/.chef/syntax_check_cache'
cookbook_path [ '~/chef-repo/cookbooks' ]


Node (Client)
chef-client will be run from node system. 
The chef-client checks the current configuration of the node against the recipes and policies stored in the Chef server and brings the node up to match. 
The process begins with the chef-client checking the node’s run list, loading the cookbooks required, then checking and syncing the cookbooks with the current configuration of the node.


Cookbooks
Cookbooks are the main component of configuring nodes on a Chef infrastructure. Cookbooks are comprised of recipes, metadata, attributes, resources, templates, libraries,

Recipes
Recipes are the fundamental part of cookbooks
Recipes are written in Ruby and contain information in regards to everything that needs to be run, changed, or created on a node

Attributes
Attributes define specific values about a node and its configuration

1 comment:

DevOps Online Training in Hyderabad said...

Chef is a worth learning as it is a great tool to automate, brings its expertise in DevOps into customer companies. The Information Provided By Your Blog is Useful for me and Other DevOps Candidates. Thanks a lot

Best Regards,
CourseIng - DevOps Training in Hyderabad