I'm looking for a way to call a single Capistrano task to perform different things to different roles. Is Capistrano able to do this, or do I have write a specific task for each role?
相关问题
- How to specify memcache server to Rack::Session::M
- Why am I getting a “C compiler cannot create execu
- reference to a method?
- ruby 1.9 wrong file encoding on windows
- gem cleanup shows error: Unable to uninstall bundl
相关文章
- Ruby using wrong version of openssl
- Difference between Thread#run and Thread#wakeup?
- how to call a active record named scope with a str
- “No explicit conversion of Symbol into String” for
- Segmentation fault with ruby 2.0.0p247 leading to
- How to detect if an element exists in Watir
- uninitialized constant Mysql2::Client::SECURE_CONN
- ruby - simplify string multiply concatenation
Use namespacing: https://github.com/leehambley/capistrano-handbook/blob/master/index.markdown#namespacing-tasks
these tasks show up in a cap -T as
Only for the record, this could be a solution using Capistrano 3:
The sever definition to perform "do_something" task in a application server would be something like:
Then you can call the task (there are several ways to do it) and the task will execute specific instructions according to the "app_role".
Actually no:
The :roles param is passed further to run command etc but does not seem to affect whether the task is actually fired.
Sorry, didn't find the way to put a comment on comment so I've written it here.
The standard way to do this in Capistrano:
So yes, you do need to write separate tasks, but you can call them from a parent task and they will filter appropriately.
You can also do
There is a way, kind of. Check: http://weblog.rubyonrails.org/2006/8/30/capistrano-1-1-9-beta/ and you'll see that you can override the default roles using the ROLES environment variable.
I have a task defined as:
The
:test
role is assigned to one server.On the command line, I can run:
And the task will now run on the lots_of_servers role.
I have not verified that this works inside a ruby script by updating the
ENV
hash, but this is a good start.