SlideShare a Scribd company logo
1 of 38
Download to read offline
Rails Machine




Thursday, January 15, 2009
The State of Rails
                             Application Deployment




Thursday, January 15, 2009
It’s easy, I’ll just use
                                  Capistrano.


Thursday, January 15, 2009
ssh m
                        e@myn
                              e wserv
                                     er.co
                                          m




                             It’s easy, I’ll just use
                                  Capistrano.


Thursday, January 15, 2009
ssh m
                        e@myn
                              e wserv
                                     er.co
                                          m




                             It’s easy, I’ll just use
                                  Capistrano.
     apt
        ‐ge
            t              in
                         lib stal
                            mag l l
                               ick ibm
                                  9‐d agi
                                          ck1
                                     ev
                                              0 
Thursday, January 15, 2009
ssh m
                        e@myn
                              e      wserv
                                          er.co
                                                 m
                                           ick
                                        ag
                                     rm
                                  l 
                                al
                             nst
                 i
                              It’s easy, I’ll just use
             em
         g

                                   Capistrano.
     apt
        ‐ge
            t              in
                         lib stal
                            mag l l
                               ick ibm
                                  9‐d agi
                                          ck1
                                     ev
                                              0       
Thursday, January 15, 2009
l‐
     ssh m                                                  ysq  
                  e@myn                                   m by
                                                      all ‐ru
                        ewser
                                                    st ql
                               ver.c              in ys          ev
                                                t  bm
                                      om
                                                             5‐d
                                             ge li
                                          t‐ r            t1
                                         p             en
                                     k a rve
                                                    cli
                                 gic      se ysql
                              ma
                          l r                 bm
                        l                  li
                     ta
                 ins
               m 
                             It’s easy, I’ll just use
             e
         g

                                  Capistrano.
     apt
        ‐ge
            t              in
                         lib stal
                            mag l l
                               ick ibm
                                  9‐d agi
                                          ck1
                                     ev
                                              0 
Thursday, January 15, 2009
l‐
     ssh m                                                  ysq  
                  e@myn                                   m by
                                                      all ‐ru
                        ewser
                                                    st ql
                               ver.c              in ys          ev
                                                t  bm
                                      om
                                                             5‐d
                                             ge li
                                          t‐ r            t1
                                         p             en
                                     k a rve
                                                    cli
                                 gic      se ysql
                              ma
                          l r                 bm
                        l                  li
                     ta
                 ins
               m 
                             It’s easy, I’ll just use
             e
         g

                                  Capistrano. /my.cnf
     apt
        ‐ge
                                                        etc
            t              in                         /
                                                  vi
                              sta
                         lib
                             mag ll l
                                ick ibm
                                   9‐d agi
                                           ck1
                                      ev
                                               0 

Thursday, January 15, 2009
l‐
     ssh m                                                  ysq  
                  e@myn                                   m by
                                                      all ‐ru
                        ewser
                                                    st ql
                               ver.c              in ys          ev
                                                t  bm
                                      om
                                                             5‐d
                                             ge li
                                          t‐ r            t1
                                         p             en
                                     k a rve
                                                    cli
                                 gic      se ysql
                              ma
                          l r                 bm
                        l                  li
                     ta
                 ins
               m 
                             It’s easy, I’ll just use
             e
         g

                                  Capistrano. /my.cnf
     apt
        ‐ge
                                                         etc
            t              in                          /
                                                   vi
                              sta
                         lib
                             mag ll l     /etc/
                                                init.
                                      ibm
                                ick                    d/mys
                                    9‐d agi                  ql st
                                                                   art
                                            ck1
                                       ev
                                                0 

Thursday, January 15, 2009
UR SHIPMENT OF FAIL HAS ARRIVED
Thursday, January 15, 2009
What is
                             deployment?




Thursday, January 15, 2009
A Series of
                             Dependencies
                    • Rails v2.2.2, v1.2.3, etc
                     • Ruby/Ruby Enterprise
                     • Apache/Nginx
                     • Passenger/Thin/Mongrel
                     • MySQL/PostgreSQL
                     • system user
Thursday, January 15, 2009
A Series of
                                  Dependencies
                             • rmagick
                              • libmagick10 libmagick9-dev
                             • thinking-sphinx
                              • compile by hand
                             • memcached
                              • libmemcached, rubygem, service
Thursday, January 15, 2009
Satisfying these dependencies via
                               shell commands is backwards




Thursday, January 15, 2009
• impossible to verify
                    • not revisioned
                    • no ‘migrations’
                    • not DRY
                    • not testable

Thursday, January 15, 2009
Not “The Rails Way”




Thursday, January 15, 2009
script/plugin install moonshine_rails*
                 script/generate moonshine




Thursday, January 15, 2009
Moonshine::Manifest

 #config/moonshine/default.rb
 class Moonshine::Manifest::Rails::Production < Moonshine::Manifest::Rails
   #packages(%w(vim curl))

   #service('memcached', %w(memcache libmemcached))

   #puppet.exec 'foo',
   #  :command => quot;echo 'normal puppet stuff' > /tmp/testquot;
 end




Thursday, January 15, 2009
Opinionated Software
Thursday, January 15, 2009
Opinionated Deployment
Thursday, January 15, 2009
Decisions We’ve
                                  Made For You
                    •        Ubuntu

                    •        Apache

                    •        Passenger

                    •        Ruby Enterprise Edition

                    •        MySQL

                    •        ‘rails’ user

                    •        /srv/rails


Thursday, January 15, 2009
Look at all the choices
                                I’m not making
                     class Moonshine::Manifest::Rails < Moonshine::Manifest
                       requires [
                         :user,
                         :ruby,
                         :rubygems,
                         :db,
                         :web,
                         :rails,
                         :deploy
                       ]
                       provides :user, 'rails'
                       provides :ruby, 'enterprise_ruby'
                       provides :rubygems, 'enterprise_rubygems'
                       provides :db, 'mysql'
                       provides :web, 'apache2'
                       provides :rails, 'passenger'
                       provides :deploy, 'git'
                     end


Thursday, January 15, 2009
On your server...


Thursday, January 15, 2009
sudo apt‐get install moonshine*
                                 sudo moonshine




Thursday, January 15, 2009
Answer some questions
                    • application name
                    • git repo
                    • branch to deploy from
                    • user to create
                     • generates SSH key for git host
                    • server ‘tags’
Thursday, January 15, 2009
Moonshine goes to
                                   work
                    • clones your repo
                    • parses and executes generated moonshine
                             manifests
                             • installs needed gems
                             • install dependencies
                             • migrates your db
                             • deploys your app
Thursday, January 15, 2009
Gem Dependencies
                   gem_dependencies do |gem|

                     #lots of dependencies are specified for you already
                     #gem.packages 'mysql', %w(mysql‐dev libmysqlclient5‐dev)
                     #gem.packages 'rmagick', %w(ruby‐dev libmagick9‐dev)
                     #...

                     #can specify a mini‐manifest to satisfy before
                     #installation of this gem 
                     gem.custom 'urgem' do |puppet|
                       puppet.file '/file/needed/by/ur/gem',
                         :ensure   => 'present',
                         :content  => 'foo'

                       build_tarball('http://whatever.com/lib‐something.tgz')
                     end

                   end


Thursday, January 15, 2009
#need to deploy again?
                                 sudo moonshine




Thursday, January 15, 2009
On subsequent runs
                    • updates your repo
                    • parses and executes updated moonshine
                             manifests
                             • verifies needed gems
                             • verifies dependencies
                             • migrates your db
                             • deploys your app
Thursday, January 15, 2009
Deployment is now...
                    • Reproducible
                    • Verified from top-bottom on each deploy
                    • Versionable with your application
                     • same commit can contain, for example,
                             thinking sphinx and installation of the
                             sphinx searchd daemon
                    • DRY
Thursday, January 15, 2009
Puppet Based
                             class MysqlMain < Moonshine::Manifest
                               puppet.file '/etc/my.cnf',
                                 :ensure => 'present',
                                 :content => quot;quot;quot;
                             [client]
                             port      = 3306
                             socket    = /var/run/mysqld/mysqld.sock
                             [mysqld]
                             default‐character‐set = utf8
                             key_buffer            = 16M
                             max_allowed_packet    = 16M
                             thread_stack          = 128K
                             thread_cache_size     = 8
                             quot;quot;quot;
                             end




Thursday, January 15, 2009
But Ruby

             class MysqlMain < Moonshine::Manifest
               puppet.file '/etc/my.cnf',
                 :ensure   => 'present',
                 :content  => ArbitraryKlass.arbitrary_function('foo')
             end




Thursday, January 15, 2009
Modular
                    UrClass < Moonshine::Manifest::Rails < Moonshine::Manifest




                    • easy to create your own reusable
                             server manifests

                    • extend existing ones with modules


Thursday, January 15, 2009
Sample ‘plugin’
                       module MoonshineOrderedPackages
                         def packages(array_or_name, params = {})
                           package_array = array_or_name.to_a
                           params = {
                             :ensure => 'installed'
                           }.merge(params)

                           package_array.each_with_index do |name,index|
                             #ensure packages are installed in order given
                             package_params = params
                             if package_array[index+1]
                               package_params.merge({
                                 :before => package(package_array[index+1])
                               })
                             end
                             puppet.package name.to_s, package_params
                           end
                         end
                       end

                       Moonshine::Manifest::Rails.send(:extend, MoonshineOrderedPackages)



Thursday, January 15, 2009
Coming Soon


                    • screencast demo (blog.railsmachine.com)
                    • source on GitHub


Thursday, January 15, 2009
Questions?



Thursday, January 15, 2009
Jesse Newland



                              jesse@railsmachine.com


Thursday, January 15, 2009
Flickr FTW

                    •        http://www.flickr.com/photos/wolfgangstaudt/2279651479/sizes/o/

                    •        http://www.flickr.com/photos/ramdac/373881476/sizes/o/

                    •        http://www.flickr.com/photos/striatic/2192189572/sizes/o/

                    •        http://www.flickr.com/photos/blakespot/2376243022/sizes/o

                    •        http://www.flickr.com/photos/gravestone/449328990/sizes/l/

                    •        http://www.flickr.com/photos/redglow/410800461/sizes/o/




Thursday, January 15, 2009

More Related Content

Viewers also liked

Arquitectura EspañOla Fines S. Xx
Arquitectura EspañOla Fines S. XxArquitectura EspañOla Fines S. Xx
Arquitectura EspañOla Fines S. XxTomás Pérez Molina
 
8 de marzo, día de la mujer. mujer e historia del arte
8 de marzo, día de la mujer. mujer e historia del arte8 de marzo, día de la mujer. mujer e historia del arte
8 de marzo, día de la mujer. mujer e historia del arteTomás Pérez Molina
 
Mobile Monday London February 2009
Mobile Monday London February 2009Mobile Monday London February 2009
Mobile Monday London February 2009AlexCraxton
 
Mobile Monday London July 2009
Mobile Monday London July 2009Mobile Monday London July 2009
Mobile Monday London July 2009AlexCraxton
 
Mobile Monday London December 08
Mobile Monday London December 08Mobile Monday London December 08
Mobile Monday London December 08AlexCraxton
 
God - Process and Task Monitoring Done Right
God - Process and Task Monitoring Done RightGod - Process and Task Monitoring Done Right
God - Process and Task Monitoring Done Rightjnewland
 
Continuous (Production) Integration: Ruby on Rails Application Monitoring wit...
Continuous (Production) Integration: Ruby on Rails Application Monitoring wit...Continuous (Production) Integration: Ruby on Rails Application Monitoring wit...
Continuous (Production) Integration: Ruby on Rails Application Monitoring wit...jnewland
 
Els transports
Els transportsEls transports
Els transportscalons2
 
PROJECTE "B": QUÈ FEM AL PATI?
PROJECTE "B": QUÈ FEM AL PATI?PROJECTE "B": QUÈ FEM AL PATI?
PROJECTE "B": QUÈ FEM AL PATI?calons2
 
Resultats duatlo escolar
Resultats duatlo escolarResultats duatlo escolar
Resultats duatlo escolarcalons2
 
Els nostres-nous-jocs-de-pati-en-català
Els nostres-nous-jocs-de-pati-en-catalàEls nostres-nous-jocs-de-pati-en-català
Els nostres-nous-jocs-de-pati-en-catalàcalons2
 
Better Use Of You Tube
Better Use Of You TubeBetter Use Of You Tube
Better Use Of You TubeDave Briggs
 
Engagement through social networking
Engagement through social networkingEngagement through social networking
Engagement through social networkingDave Briggs
 
Projecte pati
Projecte patiProjecte pati
Projecte paticalons2
 
Guia activitat f_sica_el_pati_del_meu_cole
Guia activitat f_sica_el_pati_del_meu_coleGuia activitat f_sica_el_pati_del_meu_cole
Guia activitat f_sica_el_pati_del_meu_colecalons2
 
Els patis de l'escoles
Els patis de l'escolesEls patis de l'escoles
Els patis de l'escolescalons2
 
Juguem al-pati
Juguem al-patiJuguem al-pati
Juguem al-paticalons2
 

Viewers also liked (20)

EL BARROCO: CONTEXTO HISTÓRICO
EL BARROCO: CONTEXTO HISTÓRICOEL BARROCO: CONTEXTO HISTÓRICO
EL BARROCO: CONTEXTO HISTÓRICO
 
Arquitectura EspañOla Fines S. Xx
Arquitectura EspañOla Fines S. XxArquitectura EspañOla Fines S. Xx
Arquitectura EspañOla Fines S. Xx
 
Arquitectura De Finales El S. Xx
Arquitectura De Finales El S. XxArquitectura De Finales El S. Xx
Arquitectura De Finales El S. Xx
 
8 de marzo, día de la mujer. mujer e historia del arte
8 de marzo, día de la mujer. mujer e historia del arte8 de marzo, día de la mujer. mujer e historia del arte
8 de marzo, día de la mujer. mujer e historia del arte
 
Mobile Monday London February 2009
Mobile Monday London February 2009Mobile Monday London February 2009
Mobile Monday London February 2009
 
Mobile Monday London July 2009
Mobile Monday London July 2009Mobile Monday London July 2009
Mobile Monday London July 2009
 
Mobile Monday London December 08
Mobile Monday London December 08Mobile Monday London December 08
Mobile Monday London December 08
 
God - Process and Task Monitoring Done Right
God - Process and Task Monitoring Done RightGod - Process and Task Monitoring Done Right
God - Process and Task Monitoring Done Right
 
Continuous (Production) Integration: Ruby on Rails Application Monitoring wit...
Continuous (Production) Integration: Ruby on Rails Application Monitoring wit...Continuous (Production) Integration: Ruby on Rails Application Monitoring wit...
Continuous (Production) Integration: Ruby on Rails Application Monitoring wit...
 
Els transports
Els transportsEls transports
Els transports
 
PROJECTE "B": QUÈ FEM AL PATI?
PROJECTE "B": QUÈ FEM AL PATI?PROJECTE "B": QUÈ FEM AL PATI?
PROJECTE "B": QUÈ FEM AL PATI?
 
Resultats duatlo escolar
Resultats duatlo escolarResultats duatlo escolar
Resultats duatlo escolar
 
Els nostres-nous-jocs-de-pati-en-català
Els nostres-nous-jocs-de-pati-en-catalàEls nostres-nous-jocs-de-pati-en-català
Els nostres-nous-jocs-de-pati-en-català
 
Better Use Of You Tube
Better Use Of You TubeBetter Use Of You Tube
Better Use Of You Tube
 
Engagement through social networking
Engagement through social networkingEngagement through social networking
Engagement through social networking
 
Git
GitGit
Git
 
Projecte pati
Projecte patiProjecte pati
Projecte pati
 
Guia activitat f_sica_el_pati_del_meu_cole
Guia activitat f_sica_el_pati_del_meu_coleGuia activitat f_sica_el_pati_del_meu_cole
Guia activitat f_sica_el_pati_del_meu_cole
 
Els patis de l'escoles
Els patis de l'escolesEls patis de l'escoles
Els patis de l'escoles
 
Juguem al-pati
Juguem al-patiJuguem al-pati
Juguem al-pati
 

Recently uploaded

Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 

Recently uploaded (20)

Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 

Moonshine: Configuration Management and Deployment

  • 2. The State of Rails Application Deployment Thursday, January 15, 2009
  • 3. It’s easy, I’ll just use Capistrano. Thursday, January 15, 2009
  • 4. ssh m e@myn e wserv er.co m It’s easy, I’ll just use Capistrano. Thursday, January 15, 2009
  • 5. ssh m e@myn e wserv er.co m It’s easy, I’ll just use Capistrano. apt ‐ge t  in lib stal mag l l ick ibm 9‐d agi ck1 ev 0  Thursday, January 15, 2009
  • 6. ssh m e@myn e wserv er.co m ick ag rm l  al nst  i It’s easy, I’ll just use em g Capistrano. apt ‐ge t  in lib stal mag l l ick ibm 9‐d agi ck1 ev 0   Thursday, January 15, 2009
  • 7. l‐ ssh m ysq   e@myn  m by all ‐ru ewser st ql ver.c in ys ev t  bm om 5‐d ge li t‐ r  t1 p en k a rve cli gic se ysql ma l r bm l li ta ins m  It’s easy, I’ll just use e g Capistrano. apt ‐ge t  in lib stal mag l l ick ibm 9‐d agi ck1 ev 0  Thursday, January 15, 2009
  • 8. l‐ ssh m ysq   e@myn  m by all ‐ru ewser st ql ver.c in ys ev t  bm om 5‐d ge li t‐ r  t1 p en k a rve cli gic se ysql ma l r bm l li ta ins m  It’s easy, I’ll just use e g Capistrano. /my.cnf apt ‐ge etc t  in  / vi sta lib mag ll l ick ibm 9‐d agi ck1 ev 0  Thursday, January 15, 2009
  • 9. l‐ ssh m ysq   e@myn  m by all ‐ru ewser st ql ver.c in ys ev t  bm om 5‐d ge li t‐ r  t1 p en k a rve cli gic se ysql ma l r bm l li ta ins m  It’s easy, I’ll just use e g Capistrano. /my.cnf apt ‐ge etc t  in  / vi sta lib mag ll l /etc/ init. ibm ick d/mys 9‐d agi ql st art ck1 ev 0  Thursday, January 15, 2009
  • 10. UR SHIPMENT OF FAIL HAS ARRIVED Thursday, January 15, 2009
  • 11. What is deployment? Thursday, January 15, 2009
  • 12. A Series of Dependencies • Rails v2.2.2, v1.2.3, etc • Ruby/Ruby Enterprise • Apache/Nginx • Passenger/Thin/Mongrel • MySQL/PostgreSQL • system user Thursday, January 15, 2009
  • 13. A Series of Dependencies • rmagick • libmagick10 libmagick9-dev • thinking-sphinx • compile by hand • memcached • libmemcached, rubygem, service Thursday, January 15, 2009
  • 14. Satisfying these dependencies via shell commands is backwards Thursday, January 15, 2009
  • 15. • impossible to verify • not revisioned • no ‘migrations’ • not DRY • not testable Thursday, January 15, 2009
  • 16. Not “The Rails Way” Thursday, January 15, 2009
  • 17. script/plugin install moonshine_rails* script/generate moonshine Thursday, January 15, 2009
  • 18. Moonshine::Manifest #config/moonshine/default.rb class Moonshine::Manifest::Rails::Production < Moonshine::Manifest::Rails   #packages(%w(vim curl))   #service('memcached', %w(memcache libmemcached))   #puppet.exec 'foo',   #  :command => quot;echo 'normal puppet stuff' > /tmp/testquot; end Thursday, January 15, 2009
  • 21. Decisions We’ve Made For You • Ubuntu • Apache • Passenger • Ruby Enterprise Edition • MySQL • ‘rails’ user • /srv/rails Thursday, January 15, 2009
  • 22. Look at all the choices I’m not making class Moonshine::Manifest::Rails < Moonshine::Manifest   requires [     :user,     :ruby,     :rubygems,     :db,     :web,     :rails,     :deploy   ]   provides :user, 'rails'   provides :ruby, 'enterprise_ruby'   provides :rubygems, 'enterprise_rubygems'   provides :db, 'mysql'   provides :web, 'apache2'   provides :rails, 'passenger'   provides :deploy, 'git' end Thursday, January 15, 2009
  • 23. On your server... Thursday, January 15, 2009
  • 24. sudo apt‐get install moonshine* sudo moonshine Thursday, January 15, 2009
  • 25. Answer some questions • application name • git repo • branch to deploy from • user to create • generates SSH key for git host • server ‘tags’ Thursday, January 15, 2009
  • 26. Moonshine goes to work • clones your repo • parses and executes generated moonshine manifests • installs needed gems • install dependencies • migrates your db • deploys your app Thursday, January 15, 2009
  • 27. Gem Dependencies gem_dependencies do |gem|   #lots of dependencies are specified for you already   #gem.packages 'mysql', %w(mysql‐dev libmysqlclient5‐dev)   #gem.packages 'rmagick', %w(ruby‐dev libmagick9‐dev)   #...   #can specify a mini‐manifest to satisfy before   #installation of this gem    gem.custom 'urgem' do |puppet|     puppet.file '/file/needed/by/ur/gem',       :ensure   => 'present',       :content  => 'foo'     build_tarball('http://whatever.com/lib‐something.tgz')   end end Thursday, January 15, 2009
  • 28. #need to deploy again? sudo moonshine Thursday, January 15, 2009
  • 29. On subsequent runs • updates your repo • parses and executes updated moonshine manifests • verifies needed gems • verifies dependencies • migrates your db • deploys your app Thursday, January 15, 2009
  • 30. Deployment is now... • Reproducible • Verified from top-bottom on each deploy • Versionable with your application • same commit can contain, for example, thinking sphinx and installation of the sphinx searchd daemon • DRY Thursday, January 15, 2009
  • 31. Puppet Based class MysqlMain < Moonshine::Manifest   puppet.file '/etc/my.cnf',     :ensure => 'present',     :content => quot;quot;quot; [client] port      = 3306 socket    = /var/run/mysqld/mysqld.sock [mysqld] default‐character‐set = utf8 key_buffer            = 16M max_allowed_packet    = 16M thread_stack          = 128K thread_cache_size     = 8 quot;quot;quot; end Thursday, January 15, 2009
  • 32. But Ruby class MysqlMain < Moonshine::Manifest   puppet.file '/etc/my.cnf',     :ensure   => 'present',     :content  => ArbitraryKlass.arbitrary_function('foo') end Thursday, January 15, 2009
  • 33. Modular UrClass < Moonshine::Manifest::Rails < Moonshine::Manifest • easy to create your own reusable server manifests • extend existing ones with modules Thursday, January 15, 2009
  • 34. Sample ‘plugin’ module MoonshineOrderedPackages   def packages(array_or_name, params = {})     package_array = array_or_name.to_a     params = {       :ensure => 'installed'     }.merge(params)     package_array.each_with_index do |name,index|       #ensure packages are installed in order given       package_params = params       if package_array[index+1]         package_params.merge({           :before => package(package_array[index+1])         })       end       puppet.package name.to_s, package_params     end   end end Moonshine::Manifest::Rails.send(:extend, MoonshineOrderedPackages) Thursday, January 15, 2009
  • 35. Coming Soon • screencast demo (blog.railsmachine.com) • source on GitHub Thursday, January 15, 2009
  • 37. Jesse Newland jesse@railsmachine.com Thursday, January 15, 2009
  • 38. Flickr FTW • http://www.flickr.com/photos/wolfgangstaudt/2279651479/sizes/o/ • http://www.flickr.com/photos/ramdac/373881476/sizes/o/ • http://www.flickr.com/photos/striatic/2192189572/sizes/o/ • http://www.flickr.com/photos/blakespot/2376243022/sizes/o • http://www.flickr.com/photos/gravestone/449328990/sizes/l/ • http://www.flickr.com/photos/redglow/410800461/sizes/o/ Thursday, January 15, 2009