The optimal approach would be to use Capistrano's render task:
http://manuals.rubyonrails.com/read/chapter/104#page294
At a prior employer we built a token DB that used "data inheritance"
and CVS versioned changes to do this. With YAML + Capistrano you
could achieve a powerful solution without complexity.
The less attractive kludge I use instead follows ;-) Hope this helps,
Peter
# Config file generator
require "erb"
environments = [ 'qa1', 'drn','stg', 'prd']
targets = ['httpd.conf','workers.properties']
environments.each { |env|
require env
include Configs
targets.each { |tgt|
outfile = "./Generated/" << tgt << "." << env
templateFile = "./" << tgt << ".template"
template = ERB.new(File.read(templateFile))
generatedStream = template.result(binding)
out = File.new(outfile,"w")
out.print(generatedStream)
out.close
}
}
where each file of variables is executable Ruby code:
# Concrete Configurations for QA1 environment
module Configs
# Standard Configs
Warning = %q{# WARNING: This file is machine generated .
#
# Any local changes WILL be overwritten.
}
ServerRoot = '/usr/local/apache'
DocumentRoot = '/usr/local/apache/htdocs'
end
and the template file looks like so:
# httpd daemons, you will need to change at least LockFile and PidFile.
#
ServerRoot <%= ServerRoot %>
On Mar 11, 2007, at 11:53 AM, chwilson wrote:
>
> Currently, for files that are environment-specific (but not machine
> specific), I keep a version of the config files with '-staging' and '-
> production' appended in the repository. Then my capistrano task
> copies over and renames the files depending on where I am deploying.
>
> However, there are situations where the config must be machine
> specific, with nginx and monit confs containing the ip address of the
> box.
>
> Is anyone doing this now and what is the best way to handle it?
>
>
> Regards,
>
> Christopher Wilson
>
>
> >
Peter Booth
[EMAIL PROTECTED]
917 445 5663
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---