Download - Ruby projects of interest for DevOps
![Page 2: Ruby projects of interest for DevOps](https://reader035.vdocuments.site/reader035/viewer/2022062513/55568368d8b42abc5a8b54eb/html5/thumbnails/2.jpg)
Operations Architect for PlayHaven
Started with Ruby/Rails in late 2008
Networking guy prior to that• Linux/Unix, kernel+user software development
• C/C++, Routers/Switches, …
![Page 3: Ruby projects of interest for DevOps](https://reader035.vdocuments.site/reader035/viewer/2022062513/55568368d8b42abc5a8b54eb/html5/thumbnails/3.jpg)
Short Ruby Intro
Ruby projects
Ruby Lab
![Page 4: Ruby projects of interest for DevOps](https://reader035.vdocuments.site/reader035/viewer/2022062513/55568368d8b42abc5a8b54eb/html5/thumbnails/4.jpg)
Created by Yukihiro “Matz” MatsumotoFirst release 1995, renassaince 2005 Influenced by Python, Perl, and LispFocus on simplicity, productivity, and
developer happinessPrinciple of least surpriseMany interpreters
• MRI, YARV, Jruby, Rubinius, IronRuby, REE, MacRuby, MagLev, …
“Rubyist” are passionate and friendly people (Culture)
![Page 5: Ruby projects of interest for DevOps](https://reader035.vdocuments.site/reader035/viewer/2022062513/55568368d8b42abc5a8b54eb/html5/thumbnails/5.jpg)
Object-Oriented With inheritance, mixins, and metaclasses
Interpreted
Dynamic typing and Duck typing
Everything is an object, no primitives
and many more “conventions”
![Page 6: Ruby projects of interest for DevOps](https://reader035.vdocuments.site/reader035/viewer/2022062513/55568368d8b42abc5a8b54eb/html5/thumbnails/6.jpg)
Created by DHH (released 2004)
Web application framework
Model-View-Controller (MVC) pattern
Stable 2.3.8, Beta 3.0 RC (just released)
Principles• Convention over Configuration (CoC)
• Don‟t Repeat Yourself (DRY)
REST (Representational State Transfer)
![Page 7: Ruby projects of interest for DevOps](https://reader035.vdocuments.site/reader035/viewer/2022062513/55568368d8b42abc5a8b54eb/html5/thumbnails/7.jpg)
HTTP
Request
Router
Controller
Action
Parameters
Controller
Action
Action
Action
Model
Model
Model
Database
View
<h2>List of items:
<% @items.each do |item| %>
<li> Item: <%= item %></li>
<% end %>
</h2>
HTTP
Response
![Page 8: Ruby projects of interest for DevOps](https://reader035.vdocuments.site/reader035/viewer/2022062513/55568368d8b42abc5a8b54eb/html5/thumbnails/8.jpg)
Request made from browser to URL
http://localhost:3000/users/show/1
Rails receives request on port 3000• Server invokes dispatcher (routing)
:controller = users, :action = show, :id = 1
• Action fetches model object from database
• Action renders view which generates HTML
Rails sends response (HTML page) back
![Page 9: Ruby projects of interest for DevOps](https://reader035.vdocuments.site/reader035/viewer/2022062513/55568368d8b42abc5a8b54eb/html5/thumbnails/9.jpg)
ActiveRecord
ActionController
ActionView
ActionMailer
ActiveSupport
… is all morphing as Rails3 is introduced
![Page 10: Ruby projects of interest for DevOps](https://reader035.vdocuments.site/reader035/viewer/2022062513/55568368d8b42abc5a8b54eb/html5/thumbnails/10.jpg)
Command line tool • Install multiple ruby interpreters/versions E.g.: ruby (1.8.6-p399, 1.8.7-p187, …); jruby, rubinius
• Manage sets of gems („gemsets‟)
• Perform operations over installed interpreters/gemsets Avail for all *nix systems (require „bash‟) Quick examples (no sudo needed!)
• $ rvm install ruby-1.9.2, jruby Install• $ rvm use 1.9.1 Switching
• $ rvm gemset use rails3 Managing Gems• $ rvm 1.8.7, 1.9.1, jruby tests Running tests• $ rvm 1.8.7, 1.9.1 rake do:all Running rake task
http://rvm.beginrescueend.com
![Page 11: Ruby projects of interest for DevOps](https://reader035.vdocuments.site/reader035/viewer/2022062513/55568368d8b42abc5a8b54eb/html5/thumbnails/11.jpg)
Tool for building and distributing virtualized development environments
Uses Oracle‟s VirtualBoxMain features
• Automated provisioning using chef• Forward port to host machine• Full SSH access to created environments• Shared folders between host/guest(s)• Package environments into distributable boxes
Great for distributable dev/qa environmentsTo install: # gem install vagranthttp://vagrantup.com
![Page 12: Ruby projects of interest for DevOps](https://reader035.vdocuments.site/reader035/viewer/2022062513/55568368d8b42abc5a8b54eb/html5/thumbnails/12.jpg)
Task automation tool on remote servers Features
• Restart particular service on multiple servers once
$ cap HOSTS=„www-1,www-2‟ COMMAND=„/etc/init.d/apache2 restart” invoke
• Check state of service/resource (memory,cpu) that is not monitored
$ cap HOSTS=„www-1,www-2‟ COMMAND=„grep MemTotal/proc/meminfo‟ invoke
• Run command in multiple servers and monitor output
• Systems deployment tasks (e.g., Rails deployments)
To install: # gem install capistrano http://capify.org
![Page 13: Ruby projects of interest for DevOps](https://reader035.vdocuments.site/reader035/viewer/2022062513/55568368d8b42abc5a8b54eb/html5/thumbnails/13.jpg)
Problem: how to manage many servers Solution: consolidate access to infrastructure data for
all nodes („systems integration‟) Chef provides configuration, integration, and
operations as code (written in Ruby)• Treat infrastructure like software development projects
Modes: solo, client/server Concepts
• Nodes, Roles, Cookbooks, Recipes, Resources, Attributes Opscode offerings
• Chef - Server Configuration Management Tool (API & DSL)
• Opscode Platform (hosted chef server) http://www.opscode.com
![Page 14: Ruby projects of interest for DevOps](https://reader035.vdocuments.site/reader035/viewer/2022062513/55568368d8b42abc5a8b54eb/html5/thumbnails/14.jpg)
Books• Programming Ruby 1.9
• The Ruby Programming Language
• Practical Ruby for Systems Administration
• Everyday Scripting with Ruby
Online Learning• http://rubylearning.org (Free course)
• http://github.com/edgecase/ruby_koans (FUN)
Blogs• http://rubyinside.com
• http://rubyflow.com
![Page 15: Ruby projects of interest for DevOps](https://reader035.vdocuments.site/reader035/viewer/2022062513/55568368d8b42abc5a8b54eb/html5/thumbnails/15.jpg)
Installation (all platforms)• http://www.wiki.devchix.com/index.php?title=Work
shop_Installation_Notes
Ruby, RubyGems
Editor (your choice)
Exercise• Open irb
$ irb
>> puts “Hello world”
• Save previous line on hello.rb, chmod +x, and run
$ ruby hello.rb