Hello,
We are currently using CfEngine to deploy our complex application
(complex because a lot of different components to be installed and
configured according to one or more roles for each host). I ran into
so many problems with CfEngine (it might be a good tool, but it is
definitely not the tool for our needs). I would like to replace it
with Capistrano.
I am using Capistrano (1.99.1) to deploy a complex application on a
set of hosts. Deploying the application means installing RPM and GEM
packages, customized configuration (generated previously, customized
according to hosts roles), and creating several directories, crontab
entries, etc...
I wrote a set of tasks for deploying each set of components
(installing dependencies, application components, configuration
files, system configuration, etc...). Each task handles one or more
roles. All that is pretty standard I think.
I started facing a problem when I tried to associate tasks with roles
that are not necessarily declared. Capistrano raises an error when
declaring a task for a role that is not declared or when declaring an
empty role.
Our application is installed of a platform which size may greatly
differ. We can build a test platform on one single host for instance,
or on twenty hosts for a production platform. Some roles that run
statistic servers, SIP registrar, etc... are mandatory. Because the
combinations are numerous, I wanted to handle them in a simple way: a
task linked to a role is executed if at least one host belongs to
this role, if not it is just discarded.
I am currently patching the Capistrano instance to be able to handle
this case:
def instanciate_capistrano
cap = Capistrano::Configuration.new
cap.logger.level = Capistrano::Logger::INFO
cap.set(:password) { Capistrano::CLI.password_prompt }
cap.load(File.dirname(__FILE__) + "/../lib/recipes.rb")
# patch role_list_from to allow empty roles
cap.instance_eval do
alias orig_role_list_from role_list_from
def role_list_from(roles)
roles = roles.split(/,/) if String === roles
Array(roles).map do |role|
role = String === role ? role.strip.to_sym : role
role
end
end
alias orig_execute_task execute_task
def execute_task(task)
orig_execute_task(task) unless find_servers_for_task
(task).empty?
end
end
return cap
end
I was wondering if some of you guys had already faced the same
problem, and how you did handle it. Why isn't it allowed to declare a
task for a role that doesn't exist?
Thanks!
Mathieu
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---