You _can_ get at the individual servers, but note that things like
'put' work on all servers configured for the current task, not on
specific servers, so you'd have to jump through a lot of hoops. A
better way would probably be to do something like this:
task :config_mysql_replication_for_db1, :hosts =>
"db1.example.com" do
...
end
task :config_mysql_replication_for_db2, :hosts =>
"db2.example.com" do
...
end
And so forth. Judicial use of metaprogramming can make that much drier:
DB_SERVERS = %w(db1 db2)
primary = true
DB_SERVERS.each do |server|
role :db, "#{server}.example.com", :primary => primary
primary = false
task :"config_mysql_replication_for_#{server}", :hosts => "#
{server}.example.com" do
...
end
end
task :config_mysql_replication do
DB_SERVERS.each do |server|
send "config_mysql_replication_for_#{server}"
end
end
THAT SAID, there is probably an even cleaner way of doing it. If you
have a script on each server that knows how to build my.cnf for its
current host, doing this all from cap is as easy as:
task :config_mysql_replication, :roles => :db do
run "/path/to/builder_script.rb"
end
- Jamis
Thanks for the quick reply. I'll pursue the judicial use of
metaprogramming ;-)
Dave
To retain parallellism you really need to look at deploying scripts to
the server that handle the server specific stuff.
My favourite approach is to upload a YML file that has the data for
*all* the servers in it and then use my 'std.ruby' command from the
'vmbuilder_plugins' Gem to run some ruby on the remote server that
loads the YML file and accesses the data specific the server based on
the result of a 'hostname' call.
NeilW