Sysops cu Chef
infrastructură sub formă de cod




             Istvan Hoka
          Cluj.rb - clujrb.org
          www.zencash.com
Intro

1. Chef: ce problema rezolva si cum o
   rezolva
2. Un mod usor de a incerca Chef
3. Folosire Chef la infrastructura
   pentru inceput
Chef
http://www.opscode.com/chef/
"An open-source systems
 integration framework built
specifically for automating the
            cloud."
automating the
    cloud
automating the
    cloud
      ?
Rails app
• Nginx      • Solr
• Unicorn    • Monit
• Rails      • Cron
• MySQL      • Amazon EC2
• Redis      • Ubuntu
• Memcache   • Sysadmin: Gigel
The Server
Jackpot!
Mission
accomplished




    The Server
Scaling
Take #2




App             DB
Scaling!
Take #3
                            Load balancer




 App 1              App 2                   App 3             App 4



                                                    Cache 1         Cache 2


Index 1        DB Master            Redis Master
                                                          Cache 3



          Slave 1    Slave 2          Slave
Cum rezolvă Chef
   problema?
Chef server
                                   Node. Role:
                                      LB




Node. Role: App      Node. Role: App      Node. Role: App      Node. Role: App



                                                               Cache 1           Cache 2


   Index 1             DB Master          Redis Master
                                                                       Cache 3



                  Slave 1   Slave 2          Slave
Cookbooks
                            Chef Server
                                               Roles
                                             Data Bags

                Cookbooks                 Nodes
                  Nodes
                Data Bags
                  Roles
                                                                  Node
                                                               (chef-client)

                    Commands

                                                      Node                    Node
   knife                                           (chef-client)           (chef-client)
(chef-client)
Chef Server
•   HTTP API
    ‣   knife

    ‣   chef-solo
•   CouchDB
    ‣   cookbooks: libraries, attributes, definitions, recipes
    ‣   nodes
    ‣   roles

    ‣   data bags
•   RabbitMQ
•   Solr
•   Web UI
chef-client run
•   Convergence

    ‣   Build, Register, and Authenticate the Node

    ‣   Synchronize Cookbooks

•   Compile

    ‣   Assemble Libraries, Attributes, Definitions, Recipes

•   Execute

    ‣   Converge

    ‣   Save node

    ‣   Run notifications
Cookbooks
• Attributes
• Definitions
• Libraries
• Templates
• Metadata
• Recipes
• Ruby, JSON, ERB
Chef “Hello World”?

• Chef Server
• Chef client
• Chef workstation
Chef Hello World


1. Hosted Chef + AWS EC2
2. Virtualization
Vagrant
http://vagrantup.com/
Vagrant


• Oracle VirtualBox - virtualbox.org
• Chef Solo
Vagrant setup
1. Install VirtualBox
2. Install Vagrant
3. Setup
Vagrantfile
Vagrant
                        Apache
                        MySQL
                       Memcache
                         Redis



`pwd`                   /vagrant


                   Guest OS (VirtualBox): Linux




           Host OS: Windows, OSX, Linux
Cookbooks
• https://github.com/opscode-
  cookbooks

• https://github.com/37signals/
  37s_cookbooks

• https://github.com/engineyard/ey-
  cloud-recipes

• https://github.com/cookbooks
Vagrant

• Web dev pe Linux de pe Windows,
  OSX

• Izolare
• Configuratie repetabila
Chef Solo +
Capistrano
Chef

• Infrastructura ca si cod
• Configuratie repetabila
• Scalabil

Sysops cu Chef