Slide 1

Slide 1 text

Building production server of ruby on modern way RubyConf Taiwan 2012 Shinya Tsunematsu ( @tnmt ) @ paperboy&co. Inc,

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

installing rbenv Overview puppet master target server

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

installing rbenv Overview puppet master target server 1. puppet agent run 2. git clone rbenv to /usr/local/rbenv

Slide 7

Slide 7 text

installing rbenv puppet manifest

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

installing specific ruby version Overview puppet master target server

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

installing specific ruby version puppet manifest

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

using rbenv module

Slide 16

Slide 16 text

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 ?

Slide 17

Slide 17 text

Jenkins to manage gems • update ruby tar.gz by using Jenkins integrally

Slide 18

Slide 18 text

Using Jenkins to manage gem Overview Your machine Git repository Jenkins

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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)

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

Jenkins task to install gem

Slide 25

Slide 25 text

Jenkins task detail written by simple shell script

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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.

Slide 28

Slide 28 text

No content