Slide 1

Slide 1 text

Using Chef Recipes, to automate provisioning of cloud server and Fabric for deployment.

Slide 2

Slide 2 text

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.

Slide 3

Slide 3 text

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.

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

Without Chef.... ● Configure some reverse proxy tool ● Configure your server ● Create database ● Write a server start/stop script. DO IT EVERYTIME ..aahhh...

Slide 8

Slide 8 text

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.

Slide 9

Slide 9 text

Why Chef? - Scalability

Slide 10

Slide 10 text

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!!

Slide 11

Slide 11 text

Word of Wisdom : use chef

Slide 12

Slide 12 text

Chef Concepts - Architecture

Slide 13

Slide 13 text

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.

Slide 14

Slide 14 text

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.

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

Chef Concepts : Core Components ● Resources ● Recipes ● Metadata ● Attributes ● Databags ● Roles ● Cookbook ● Environments

Slide 17

Slide 17 text

Chef Concepts: Summarized

Slide 18

Slide 18 text

Getting Started with Chef Solo

Slide 19

Slide 19 text

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]" ] }

Slide 20

Slide 20 text

Solo Chef is no more lonely ● github.com/trotter/Spatulla ● github.com/tobalmi/littlechef ● github.com/mkocher/soloist ● github.com/matschaffer/knife-solo

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

Fabric - basic steps for deployment ● Copy Code and Media ● Run Database Migrations ● Start WSGI Daemons

Slide 23

Slide 23 text

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")

Slide 24

Slide 24 text

Questions?? contact me : @gamebit07 slides: http://bit.ly/KQAO9i