Module: LeapCli::Util::RemoteCommand
- Extended by:
- RemoteCommand
- Included in:
- Commands, RemoteCommand
- Defined in:
- lib/leap_cli/util/remote_command.rb
Instance Method Summary collapse
-
#ssh_connect(nodes, options = {}, &block) ⇒ Object
FYI Capistrano::Logger::IMPORTANT = 0 Capistrano::Logger::INFO = 1 Capistrano::Logger::DEBUG = 2 Capistrano::Logger::TRACE = 3.
Instance Method Details
#ssh_connect(nodes, options = {}, &block) ⇒ Object
FYI
Capistrano::Logger::IMPORTANT = 0
Capistrano::Logger::INFO = 1
Capistrano::Logger::DEBUG = 2
Capistrano::Logger::TRACE = 3
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/leap_cli/util/remote_command.rb', line 11 def ssh_connect(nodes, ={}, &block) ||= {} node_list = parse_node_list(nodes) cap = new_capistrano cap.logger = LeapCli::Logger.new(:level => [LeapCli.log_level,3].min) user = [:user] || 'root' cap.set :user, user cap.set :ssh_options, # ssh options common to all nodes cap.set :use_sudo, false # we may want to change this in the future # Allow password authentication when we are bootstraping a single node # (and key authentication fails). if [:bootstrap] && node_list.size == 1 hostname = node_list.values.first.name if [:echo] cap.set(:password) { ask "Root SSH password for #{user}@#{hostname}> " } else cap.set(:password) { Capistrano::CLI.password_prompt " * Typed password will be hidden (use --echo to make it visible)\nRoot SSH password for #{user}@#{hostname}> " } end end node_list.each do |name, node| cap.server node.domain.full, :dummy_arg, (node, [:ssh_options]) end yield cap rescue Capistrano::ConnectionError => exc # not sure if this will work if english is not the locale?? if exc. =~ /Too many authentication failures/ at_exit {} end raise exc end |