Building production server of ruby on modern way

Building production server of ruby on modern way

LT at #rubyconftw2012

D7df6557c6b98f29ac546911e2b1a4d4?s=128

Shinya Tsunematsu

December 31, 2012
Tweet

Transcript

  1. Building production server of ruby on modern way RubyConf Taiwan

    2012 Shinya Tsunematsu ( @tnmt ) @ paperboy&co. Inc,
  2. system administrator’s melancholy • we mainly use RHEL clone distributions

    (CentOS, Scientific Linux) • they of course use rpm as their package system. • packaging newly rpm of ruby is hard • packaging rpm is troublesome job • It’s hard to upgrade ruby version using rpm • It’s very very hard to manage rubygem by using ( packaging into ) rpm • packaging rpm, packaging gem, packaging, packageng......
  3. using rbenv at production server • rbenv • https://github.com/sstephenson/rbenv •

    well known convenient tool to develop ruby • we put rbenv at /usr/local/rbenv ( system-wide ) on production server • everyone who logged in server can use common rbenv environment • we try to use Puppet to place benv
  4. installing rbenv Overview puppet master target server

  5. installing rbenv Overview puppet master target server 1. puppet agent

    run
  6. installing rbenv Overview puppet master target server 1. puppet agent

    run 2. git clone rbenv to /usr/local/rbenv
  7. installing rbenv puppet manifest

  8. rbenv directory tree • /usr/local/rbenv/versions/ • 1.9.3-p327 • 2.0.0-preview1 •

    we can install another version of ruby by distributing files under /usr/local/rbenv/versions/ ( not using `rbenv install 1.9.3-pXXX` ) • using Puppet to distribute files
  9. installing specific ruby version Overview puppet master target server

  10. installing specific ruby version Overview puppet master target server 1.

    puppet agent run
  11. installing specific ruby version Overview puppet master target server 1.

    puppet agent run 2. get tar ball of specific ruby version
  12. installing specific ruby version Overview puppet master target server 1.

    puppet agent run 2. get tar ball of specific ruby version 3. expand tar ball under /usr/local/rbenv/versions
  13. installing specific ruby version puppet manifest

  14. rbenv module of puppet • Install rbenv • place rbenv

    to /usr/local/rbenv • Install specific ruby version • distribute file ( tar.gz, which contains specific version of ruby ) • expands tar.gz under /usr/local/rbenv/versions • specify default version to /usr/local/rbenv version
  15. using rbenv module

  16. How to manage gem ? • gem are installed into

    /usr/local/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems • /usr/local/rbenv/versions/1.9.3-p327/ are managed by puppet and compressed in tar ball • how to add gem’s files to tar ball ?
  17. Jenkins to manage gems • update ruby tar.gz by using

    Jenkins integrally
  18. Using Jenkins to manage gem Overview Your machine Git repository

    Jenkins
  19. Using Jenkins to manage gem Overview Your machine Git repository

    Jenkins 1. commit Gemfile which you want to use system-wide
  20. Using Jenkins to manage gem Overview Your machine Git repository

    Jenkins 1. commit Gemfile which you want to use system-wide 2. Jenkins polling
  21. Using Jenkins to manage gem Overview Your machine Git repository

    Jenkins 1. commit Gemfile which you want to use system-wide 2. Jenkins polling 3. install gem by Gemfile (bundler)
  22. Using Jenkins to manage gem Overview Your machine Git repository

    Jenkins 1. commit Gemfile which you want to use system-wide 2. Jenkins polling 3. install gem by Gemfile (bundler) 4. tar specific version directory and commit
  23. Using Jenkins to manage gem Overview Your machine Git repository

    Jenkins 1. commit Gemfile which you want to use system-wide 2. Jenkins polling 3. install gem by Gemfile (bundler) 4. tar specific version directory and commit 5. push tar ball
  24. Jenkins task to install gem

  25. Jenkins task detail written by simple shell script

  26. Pros • less time to add new ruby version or

    install/upgrade gem than packaging rpm. • rbenv can share same environment over different many servers. • we can use and switchover some ruby versions • coexistence some ruby versions is difficult by using rpm ( rpm always overwrite new version ) • rbenv is developer friendly and simple • It is also easy for operation engineer, system administor
  27. Cons • `git clone` of puppet repository goes slow... •

    committing binary (tar ball of ruby) to git is not good manner maybe. • a little bit exaggerate approach ? • maybe “package” resource type of puppet also work well under rbenv environment. • I try to improve and make sure that Jenkins is needed or not.
  28. None