On Wed, Jan 16, 2013 at 4:15 PM, Nick Roosevelt <[email protected]> wrote:

> Not sure if this is covered here, or how to search for it.  Please excuse
> me and send me a link if it has been covered.
>
> I am working on a deployment strategy for 50+ apps (7 different ones,
> multiple instances of some of them) into a secure, HA production
> environment.  I am not keen on making the production administrators have
> and maintain dev trees for each app at the colo, so I am working on a
> separate deployment project that will deploy the apps.  I am happy to hear
> from anyone who has ideas or solutions for me.  Thanks!


It's doable with Capistrano.  Where I am working now we have 1 app, with
hundreds (almost 1000) separate instances, spread across two of our own
managed data centers *plus* over 20 separate clients who have chosen to
install our app locally (but I wouldn't recommend that last part).  Each
app could potentially be running a different version of our software,
further complicating things.

The trick is to load in the instance-specific variables (:roles and :user
especially come to mind) from external file(s).  If you have multiple users
that you need to manage, each one can have their own iterations of the
external file(s), or alternately you can tie in their logged-in user names
(especially easy if using LDAP) in some creative way, obviating the need
for each person to manage their own config trees.

Each instance can have its own external file; we chose to use a single yaml
for all app instances because it was easier to write a middle layer to
manage the yaml itself (also can be done from Capistrano fairly easily).
 I'd share our yaml-based code, but right now it's highly proprietary and a
sample bit of code would be really long and highly obtrusive to the list.
 I've added a sample load sequence below that shows multiple external ruby
files and then the Capistrano code to load it in.  The code below is
dependent on having a $APPTARGET environment variable; thus in order to use
the below, you would basically:

== USAGE ==

$ cd /path/to/Capistrano/
$ export APPTARGET =instances/{external_rb_file}.rb
$ cap {some_task}

== FILES ==

# == /path/to/Capistrano/instances/app1.rb == #
set :instance_name, "app1"
set :instance_url, "app1.domain.com"
set :user, "app1_user1"
role :web, "server1a.domain.com", "server1b.domain.com"

# == /path/to/Capistrano/instances/app2.rb == #
set :instance_name, "app2"
set :instance_url, "app2.domain.com"
set :user, "app2_user1"
role :web, "server2a.domain.com", "server2b.domain.com"

# == /path/to/Capistrano/Capfile == #
# The below should be at or near the top of Capfile to make sure the
instance-specific vars
# are read in correctly.
if !ENV['APPTARGET']
  raise "You need to define a valid target to control.  like
'export APPTARGET =instances/name_of_site.rb'"
end
if FileTest.exist?( ENV['APPTARGET'] )
  instance_eval(File.open(ENV['APPTARGET']).read)
else
  raise "The configuration file you specified does not exist.  Please check
to make sure it is there."
end

HTH,
Chris

-- 
* You received this message because you are subscribed to the Google Groups 
"Capistrano" group.
* To post to this group, send email to [email protected]
* To unsubscribe from this group, send email to 
[email protected] For more options, visit this group at 
http://groups.google.com/group/capistrano?hl=en

Reply via email to