On 07/17/2011 12:45 PM, S Ahmed wrote:
So I ran through a server setup on ec2, and have a text file of all the commands I used to get the server to where I wanted it.

step 1: turn your list of commands into an idempotent script

#! /bin/sh

site=http://rubyenterpriseedition.googlecode.com/files
name=ruby-enterprise-1.8.7-2011.03
archive=$name.tar.gz
prepath="/opt/ruby/bin"
downloads=/root/downloads
wanted="
        mysql-server
        libmysqlclient15-dev
        libreadline5-dev
        libssl-dev
"

apt-get install $wanted

mkdir -p $downloads

[ ! -d $downloads/$archive ] && cd $downloads && wget $site/$archive
[ ! -d $downloads/$name ] && cd $downloads && tar xzf $archive

[ ! -f /opt/ruby/bin/ruby ] && ./$name/installer --auto /opt/ruby/
grep -q "$prepath" ~/.profile || echo "export PATH=$prepath:$PATH" >> ~/.profile

exit 0


step 2: puppetize it

class ruby_from_src {
$site ="http://rubyenterpriseedition.googlecode.com/files";
        $name           ="ruby-enterprise-1.8.7-2011.03"
        $archive        ="${name}.tar.gz"
        $prepath        ="/opt/ruby/bin"
        $downloads      ="/root/downloads"

        $wanted = [
                "mysql-server",
                "libmysqlclient15-dev",
                "libreadline5-dev",
                "libssl-dev",
                ]

        package { $wanted:
                ensure => installed,
        } ->

        file { $downloads:
                ensure => directory,
        } ->

        exec { "ruby from source download":
                command => "wget ${site}/${archive}",
                cwd     => $downoads,
                creates => "${dir}/${archive}",
        } ->

        exec { "ruby from source extract":
                command => "tar xzf ${archive}",
                cwd     => $downloads,
                creates => "${name}",
        } ->

        exec { "ruby from source install":
                command => "./${name}/installer --auto /opt/ruby/",
                cwd     => $downloads,
                creates => "/opt/ruby/bin/ruby",
        }

        file { "ruby from source PATH":
                path     => "/etc/profile.d/puppet_ruby_from_src.sh",
                content  => "PATH=${prepath}:\$PATH",
                mode     => 644,
        }

}

step 3: run it and fix the bugs  :-)

I have not tested it, so there might be bugs.  But that's the general idea.
There's room for improvement though:

- parameterise the class so you can pass in the version, site, etc
- move some of the dependencies to other classes
        mysql stuff belongs in a mysql_dev class
        libssl-dev probably belongs in a network_dev class
        *_dev classes should include a build_tools class

But, the biggest improvement would be to make your own package and install that
instead of fiddling around with this low level stuff in the manifests.

--
vagn

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to