Share
Embed
Chef Recipies and Fabric to automate Provisioning & Deployment
A guide to introduce Chef Architecture to automate provisioning and fabric to automate deployment.
Saket Bhushan
May 10, 2012
Transcript
24 slides
-
Using Chef Recipes, to automate provisioning of cloud server and
Fabric for deployment. -
Brief Overview • Few Basics for better comprehension. • Non
Chef approach to provision a server. • Chef Concepts in Detail. • Working with Chef Solo in Detail. • Why, What and How of Fabric? • No Provisioning demo, but a fabric demo, if time permits. -
Few Basics Provisioning - the act of preparing the system
for the use of a service by a consumer. Deployment - is all of the activities that make a software system available for use. Infrastructure - All your servers. -
Without Chef.. Login and OS Updation: a. $ ssh root@{your_ip}
b. # apt-get update c. # apt-get upgrade d. # apt-get dist-upgrade e. # dpkg-reconfigure tzdata #choose your time zone -
Without Chef.... Setup Users and Permissions: • # useradd username
• # mkdir /home/username • # chown username:username /home/username • # passwd username //choose a password • # chsh username -s /bin/bash //choose a shell • # visudo //lets give sudo access to the user username • root ALL=(ALL) ALL • username ALL=(ALL) ALL • # su username // switch from root to username -
Without Chef..install packages and create a dev environment: ◦ $
sudo apt-get install python-pip git mysql-client mysql-server ◦ $ python-mysqldb emacs ◦ $ pip install virtualenv ◦ $ virtualenv projhq // creates a project directory, ◦ $ cd projhq ◦ $ projhq source /bin/activate ◦ (projhq)$ pip install django gunicorn -
Without Chef.... • Configure some reverse proxy tool • Configure
your server • Create database • Write a server start/stop script. DO IT EVERYTIME ..aahhh... -
Introducing Chef A library for: • Configuration management. • System
integration platform. • serving as an API for your entire infrastructure. It helps you: • Manage configuration as idempotent Resources. • Put them together in recipes. • Track it like source code. • Configure your servers. -
Why Chef? - Manageability Publicity hits -> load balancers ->
add more web servers, still things are slower -> multiple databases -> probably re-architect the app -> caching and re-caching -> database partitioning -> horizontal scaling - > vertical scaling -> more pain -> more sys admins -> more worry -> panic -> IT HURTS!! -
Chef Concepts - Architecture chef solr is a thin wrapper
around the Apache Solr search engine. Chef Solr allows you to find your way around your infrastructure by querying its metadata. -
Chef Concepts - The Client Includes • Chef Solo ◦
client application ◦ works entirely from on disk data ◦ lightweight alternative to full client-server application • Chef Client ◦ It communicates with the Chef Server via REST, authenticates via Signed Header Authentication, and compiles and executes Cookbooks. • Shef ◦ the interactive Chef shell. ◦ helps you to you to write, run, and debug recipes interactively ◦ programmatic interface for viewing and editing data on Chef Server. -
Chef Concepts- Flavours of Chef • Hosted Chef - service
by OpsCode • Private Chef - your company maintains chef servers and nodes • Chef Solo - for those of you who are single -
Chef Concepts : Core Components • Resources • Recipes •
Metadata • Attributes • Databags • Roles • Cookbook • Environments -
Getting Started with Chef Solo solo.rb: file_cache_path "/var/chef-solo" cookbook_path "/var/chef-solo/cookbooks"
json_attribs "http://www.example.com/node.json" recipe_url "http://www.example.com/chef-solo.tar.gz" node.json: { "resolver": { "nameservers": [ "10.0.0.1" ], "search":"int.example.com" }, "run_list": [ "recipe[nginx]" ] } -
Solo Chef is no more lonely • github.com/trotter/Spatulla • github.com/tobalmi/littlechef
• github.com/mkocher/soloist • github.com/matschaffer/knife-solo -
Working with knife-solo 1. sudo apt-get install chef 2. gem
install knife-solo 3. knife configure -r . --defaults //create a basic knife configuration file 4. knife kitchen testsolo // hold the files to be used 5. knife prepare username@ipaddress 6. knife cook username@ipaddress -
Fabric - basic steps for deployment • Copy Code and
Media • Run Database Migrations • Start WSGI Daemons -
Fabric Basics from fabric.api import * from fabric.context_managers import prefix
import os def git_pull(): with cd(ROOT_PATH): run("git pull origin master")