Rake task for rsync deployment and rails wiki

Hello.

I’ve looked around the net today for the nicely integrated into rails
solution
for rsync-based deployment but failed to find anything good enough so
I’ve
just moved on and create my own rake task. It allows to deploy
applications
to a number of different servers configured in config/rsync.yml file and
supports exclusions listed as the plain text file in
config/rsync_exclude.txt.
Iniatilly I wanted to share this thing on rails’ wiki but the current
page
related to the same tasks seems to have some problems and previous posts
on
this maillist suggests that wiki doesn’t feel itself good nowdays
because of
all the spam.

So if anyone is interested in this code - I can post it here in the
maillist
with relevant description. Does anyone need it?


WBR, Oleg Ivanov
ICQ #69991809
Jabber: [email protected]

I don’t need it, but I’m sure that at some point there will definitely
be someone who searches this mailing list for something like this! You
should post it :wink: Good work, and thanks!

-Ben L.

Ok, so attached is the rake file that should be saved in the lib/tasks/
folder
as usual. It provides a new rake task called “sync” that synchronizes
the
application’s RAILS_ROOT with the specified directory on remote server.
It
uses rsync running over ssh remote shell transport.

To use this task you should first define the parameters of a remote
servers in
config/rsync.yml file. Let’s see an example:


default_target: production

production:
host: test.server.net
port: 22
user: tester
dir: /home/tester/railsapp

test:
host: google.com
user: root
dir: /etc

In the first line default_target defines a default sync target that will
be
used if no explicit target is given on the command line.
Then all required servers are listed under their nicknames in the shown
format. Parameters host, user and dir are required and port is optional.

To run the task in the dry-run mode without actually forcing any changes
on
the remote server do:
% rake sync
It will give you back the rsync’s log. If you are sure that everything
is fine
and you want to actually deploy your app do:
% rake sync go=
and every time you need to roll out your changes on the server - just
type “rake sync go=” again and you’re done.

In this form task uses default target set in your config file. If you
want to
deploy to any other server from you configuration add the argument “to”:
% rake sync to=test go=
Of course, you can skip “go” arg and do a dry run:
% rake sync to=test

And the last thing - if you don’t want some of your local directories to
be
synchronized (log, tmp, etc) you can list them in the
config/rsync_exclude.txt file.
The sample rsync_exclude.txt looks like:

tmp
log
.svn
*.swp

Hope that will be helpful to someone, ask me if you have any
problems/suggestions relates to this thing.

PS: this task was hugely inspired by the similar task from Symfony PHP
framework though improved a bit by me to be more convenient.


WBR, Oleg Ivanov
ICQ #69991809
Jabber: [email protected]

Hi.

I was interested in looking at the rake task referred to in this post,
but never could find it.

I know this is an old topic, but if anyone else caught it, I’d
appreciate it if you could forward or repost.
Thx.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs