Using Capistrano for Non Rails SYS/DBA admin type tasks.

10 views
Skip to first unread message

Amr Malik

unread,
Feb 5, 2007, 5:22:04 PM2/5/07
to Capistrano
Hello,

This is a completely non-rails related question.

For my current client, I have to refresh oracle databases from
production source systems. Usually I just ssh in and ftp the exports
and run a stack of shell scripts I have one by one. The
"deployment" (or refresh, to be exact) scenario is always the same.

SRC = Production db box
TGT = Development db box

shutdown db (TGT)
shutdown app/web servers (NOT rails)
ssh into target:
===> copy latest export from SRC
===> drop objects in local dev db (TGT)
===> import db (TGT)
===> rebuild indexes (TGT)
===> clear app/web caches (TGT)
===> restart web/app (Tuxedo) (TGT)
===> Invoice the client :-)

Now, I can manage the very last step manually, LoL, but I'd like to be
able to automate the rest of the steps in this simple task using
capistrano running from my local windows machine (and perhaps leave
this setup for the client to run it later on after my contract is
finished?)

Is this something which is doable without too much pain and/or code
contortions? I'm getting the sense that it is, I saw the "Fortran
Farm" post below, so it gives me hope, but I'm wondering if I can use
Capistrano for something completely non-related to Rails or Coding/SVN
or what have you... (the boxes are HP/UX btw, but that shouldn't
matter too much I presume?)

Do I still need to setup the "required" parameters albeit as dummies
because most of them are meaningless in a non-developer non-rails
enviornment??

I have seen the slingshot rails-stack setup script (
http://svn.highgroove.com:8080/deployment/trunk/) , but I'm not sure
if can pick and choose and just use the capistrano parts which let me
do remote-ssh'ing with the local ruby-scripting-goodness for general
db/sysadmin tasks.

Any hints or pointers or comments by people already doing this sort of
thing would be appreciated!

Thanks,

Amr

Charles Brian Quinn

unread,
Feb 5, 2007, 5:32:36 PM2/5/07
to capis...@googlegroups.com
On 2/5/07, Amr Malik <amrm...@gmail.com> wrote:
> I have seen the slingshot rails-stack setup script (
> http://svn.highgroove.com:8080/deployment/trunk/) , but I'm not sure
> if can pick and choose and just use the capistrano parts which let me
> do remote-ssh'ing with the local ruby-scripting-goodness for general
> db/sysadmin tasks.

Oh, but you can do all that and more. I had a shell script that
installed everything that I used to run, and then moved it all over to
ruby, executed using net/ssh (and through capistrano). You get for
free, commands like run and sudo (and can do things with their output
using net/ssh), including error recovery.

I would go ahead and start with capistrano as your base, just knowing
that you'll never use "deploy" or any of the standard recipes that are
automatically loaded. You can pretty much start with a clean
deploy.rb file to load any variables you want to pass. Jamis is
working on abstracting out the core-capistrano which is task based,
role-based command execution, but until then, you'll just have to use
it in a rails context.

For running that script, I often time just drop it in a base rails app
with nothing in it, but newer capistrano setups can use your global
/etc/capistrano.conf (don't quote me on that file name) for recipes
and tasks.

> Any hints or pointers or comments by people already doing this sort of
> thing would be appreciated!

Definitely dig through that script, and let me know if you have any
questions/problems. So many have been using, I setup a trac for it:

http://trac.highgroove.com/deployment

any feedback is appreciated, hope you get some good use out of 'em.
deprec and the railsmachine folk all have similar tools, too....
might be worth a look.
--
Charles Brian Quinn
self-promotion: www.seebq.com
highgroove studios: www.highgroove.com
slingshot hosting: www.slingshothosting.com
main: 678.389.9462 fax: 678.826.0969

Ruby on Rails Bootcamp at the Big Nerd Ranch
Intensive Ruby on Rails Training:
http://www.bignerdranch.com/classes/ruby.shtml

Amr Malik

unread,
Feb 5, 2007, 8:39:45 PM2/5/07
to Capistrano
Thanks for your response Charles!
Your explanation clears up a couple of things that were confusing
me. I guess I can just have a plain rails install so that Capistrano
doesn't complain too much and then just use sudo and run for bulk of
the sysadmin tasks.

I think the core capistrano with sole focus on generic tasks would be
a boon for us sysadmins/dba types .

Thanks for providing me a starting point and the helpful hints, I will
post back my progress once I get something cooked for oracle database
cloning and refresh using capistrano

Thanks,

Amr

On Feb 5, 5:32 pm, "Charles Brian Quinn" <cbqu...@gmail.com> wrote:

Mike Bailey

unread,
Feb 6, 2007, 6:18:19 AM2/6/07
to capis...@googlegroups.com
WIth the latest Capistrano, you don't need a rails project at all.

Put your recipes into any of the following files:

- /etc/capistrano.conf  (windows: #{ENV["HOMEDRIVE"]}#{ENV["HOMEPATH"]}")
- ~/.caprc (windows: ENV["SystemRoot"])
- config/deploy.rb (windows: config\deploy.rb)

The are read in the order listed and so you can override a systemwide
recipe with your own person version of it if you like. 

I am starting to put config/deploy.rb's into my configuration repository.
So I can run cap restart_postfix from within it without cluttering up my
'cap show tasks'.

You can also require other people recipes in your ~/.caprc or /etc/capistrano.conf
One example is deprec.

When you get into writing your own tasks, check out Neil Wilsons vmbuilder plugins.
It gives you nice functions to install packages using rubygems and apt as well as
some other handy capistrano functions.
 
- Mike

Jamis Buck

unread,
Feb 6, 2007, 9:31:11 AM2/6/07
to capis...@googlegroups.com
Even better: if capistrano finds a file named 'capfile' in the
current directory, it'll read that automatically. 'config/deploy.rb'
is intended specifically for rails projects, so for non-rails
projects it's kind of klunky. Use 'capfile' for those instead.

- Jamis

Reply all
Reply to author
Forward
0 new messages