Created
August 24, 2011 02:18
-
-
Save sotarok/1167149 to your computer and use it in GitHub Desktop.
inherit previous roles of a task for capistrano server selection.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# based on: http://pastie.org/293845 | |
module Capistrano | |
class Configuration | |
module Servers | |
alias_method :original_find_servers, :find_servers | |
def find_servers(options={}) | |
servers = original_find_servers options | |
stack_roles = task_call_frames.collect {|frame| frame.task.options[:roles]}.compact.flatten | |
servers = servers.select do |server| | |
if not stack_roles.empty? | |
stack_roles.any? { |role| self.roles[role].include?(server) } | |
else | |
true | |
end | |
end | |
servers.uniq | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment