Skip to content

Commit

Permalink
Merge pull request #81 from bibendi/master
Browse files Browse the repository at this point in the history
feature: Use ssh_password in remote helper
  • Loading branch information
bibendi authored Jul 6, 2016
2 parents 0a948bd + 112a4b3 commit 08d2df6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Sphinx::Integration::Extensions::ThinkingSphinx::Configuration
extend ActiveSupport::Concern

included do
attr_accessor :remote, :user, :password, :exclude, :ssh_port,
attr_accessor :remote, :user, :password, :exclude, :ssh_port, :ssh_password,
:log_level, :mysql_read_timeout, :mysql_connect_timeout

alias_method_chain :shuffled_addresses, :integration
Expand Down
14 changes: 9 additions & 5 deletions lib/sphinx/integration/helper_adapters/remote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ module Integration
module HelperAdapters
class SshProxy
DEFAULT_SSH_OPTIONS = {
user: "sphinx",
port: 22,
quiet: false,
info: true,
safe: false,
debug: false,
forward_agent: true
forward_agent: true,
password_prompt: false
}.freeze

delegate :file_upload, to: "@servers"
Expand All @@ -18,13 +21,14 @@ class SshProxy
# :hosts - Array of String (required)
# :port - Integer ssh port (default: 22)
# :user - String (default: sphinx)
# :password - String (optional)
def initialize(options = {})
options.reverse_merge!(user: "sphinx", port: 22)

@servers = Rye::Set.new("servers", parallel: true)

ssh_options = options.slice(:user, :port, :password).select { |_, value| !value.nil? }

Array.wrap(options.fetch(:hosts)).each do |host|
server = Rye::Box.new(host, DEFAULT_SSH_OPTIONS.merge(options.slice(:user, :port)))
server = Rye::Box.new(host, DEFAULT_SSH_OPTIONS.merge(ssh_options))
server.stdout_hook = proc { |data| ::ThinkingSphinx.info(data) }
server.pre_command_hook = proc { |cmd, *| ::ThinkingSphinx.info(cmd) }
@servers.add_box(server)
Expand Down Expand Up @@ -66,7 +70,7 @@ class Remote < Base
def initialize(*)
super

@ssh = SshProxy.new(hosts: hosts, port: config.ssh_port, user: config.user)
@ssh = SshProxy.new(hosts: hosts, port: config.ssh_port, user: config.user, password: config.ssh_password)
end

def running?
Expand Down

0 comments on commit 08d2df6

Please sign in to comment.