capistrano-different-password 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,8 +18,9 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- #capfile
21
+ *capfile*
22
22
 
23
+ ```ruby
23
24
  require 'capistrano-different-password'
24
25
 
25
26
  set :user,'user'
@@ -27,6 +28,13 @@ set :password,"PasSworD"
27
28
 
28
29
  role :admin,"127.0.0.1","127.0.0.2",["127.0.0.3","DifferentPasSwOrd"]
29
30
 
31
+ task :sometask,role: :admin do
32
+ run 'date'
33
+ end
34
+ ```
35
+
36
+ cap sometask
37
+
30
38
  ## Contributing
31
39
 
32
40
  1. Fork it
@@ -1,69 +1,71 @@
1
1
  require "capistrano-different-password/version"
2
2
 
3
- class ::Capistrano::ServerDefinition
4
- attr_reader :password
5
- def initialize(server, options={})
6
- if server.is_a? Array
7
- @password = server[1]
8
- server = server[0]
9
- end
10
- @user, @host, @port = server.match(/^(?:([^;,:=]+)@|)(.*?)(?::(\d+)|)$/)[1,3]
3
+ module ::Capistrano
4
+ class ServerDefinition
5
+ attr_reader :password
6
+ def initialize(server, options={})
7
+ if server.is_a? Array
8
+ @password = server[1]
9
+ server = server[0]
10
+ end
11
+ @user, @host, @port = server.match(/^(?:([^;,:=]+)@|)(.*?)(?::(\d+)|)$/)[1,3]
11
12
 
12
- @options = options.dup
13
- user_opt, port_opt = @options.delete(:user), @options.delete(:port)
13
+ @options = options.dup
14
+ user_opt, port_opt = @options.delete(:user), @options.delete(:port)
14
15
 
15
- @user ||= user_opt
16
- @port ||= port_opt
16
+ @user ||= user_opt
17
+ @port ||= port_opt
17
18
 
18
- @port = @port.to_i if @port
19
+ @port = @port.to_i if @port
20
+ end
19
21
  end
20
- end
21
22
 
22
- class ::Capistrano::SSH
23
- def self.connection_strategy(server, options={}, &block)
24
- methods = [ %w(publickey hostbased), %w(password keyboard-interactive) ]
25
- password_value = nil
23
+ class SSH
24
+ def self.connection_strategy(server, options={}, &block)
25
+ methods = [ %w(publickey hostbased), %w(password keyboard-interactive) ]
26
+ password_value = nil
26
27
 
27
- # construct the hash of ssh options that should be passed more-or-less
28
- # directly to Net::SSH. This will be the general ssh options, merged with
29
- # the server-specific ssh-options.
30
- ssh_options = (options[:ssh_options] || {}).merge(server.options[:ssh_options] || {})
28
+ # construct the hash of ssh options that should be passed more-or-less
29
+ # directly to Net::SSH. This will be the general ssh options, merged with
30
+ # the server-specific ssh-options.
31
+ ssh_options = (options[:ssh_options] || {}).merge(server.options[:ssh_options] || {})
31
32
 
32
- # load any SSH configuration files that were specified in the SSH options. This
33
- # will load from ~/.ssh/config and /etc/ssh_config by default (see Net::SSH
34
- # for details). Merge the explicitly given ssh_options over the top of the info
35
- # from the config file.
36
- ssh_options = Net::SSH.configuration_for(server.host, ssh_options.fetch(:config, true)).merge(ssh_options)
33
+ # load any SSH configuration files that were specified in the SSH options. This
34
+ # will load from ~/.ssh/config and /etc/ssh_config by default (see Net::SSH
35
+ # for details). Merge the explicitly given ssh_options over the top of the info
36
+ # from the config file.
37
+ ssh_options = Net::SSH.configuration_for(server.host, ssh_options.fetch(:config, true)).merge(ssh_options)
37
38
 
38
- # Once we've loaded the config, we don't need Net::SSH to do it again.
39
- ssh_options[:config] = false
39
+ # Once we've loaded the config, we don't need Net::SSH to do it again.
40
+ ssh_options[:config] = false
40
41
 
41
- ssh_options[:verbose] = :debug if options[:verbose] && options[:verbose] > 0
42
+ ssh_options[:verbose] = :debug if options[:verbose] && options[:verbose] > 0
42
43
 
43
- user = server.user || options[:user] || ssh_options[:username] ||
44
- ssh_options[:user] || ServerDefinition.default_user
45
- port = server.port || options[:port] || ssh_options[:port]
44
+ user = server.user || options[:user] || ssh_options[:username] ||
45
+ ssh_options[:user] || ServerDefinition.default_user
46
+ port = server.port || options[:port] || ssh_options[:port]
46
47
 
47
- # the .ssh/config file might have changed the host-name on us
48
- host = ssh_options.fetch(:host_name, server.host)
48
+ # the .ssh/config file might have changed the host-name on us
49
+ host = ssh_options.fetch(:host_name, server.host)
49
50
 
50
- ssh_options[:port] = port if port
51
+ ssh_options[:port] = port if port
51
52
 
52
- # delete these, since we've determined which username to use by this point
53
- ssh_options.delete(:username)
54
- ssh_options.delete(:user)
53
+ # delete these, since we've determined which username to use by this point
54
+ ssh_options.delete(:username)
55
+ ssh_options.delete(:user)
55
56
 
56
- begin
57
- connection_options = ssh_options.merge(
58
- :password => password_value,
59
- :auth_methods => ssh_options[:auth_methods] || methods.shift
60
- )
57
+ begin
58
+ connection_options = ssh_options.merge(
59
+ :password => password_value,
60
+ :auth_methods => ssh_options[:auth_methods] || methods.shift
61
+ )
61
62
 
62
- yield host, user, connection_options
63
- rescue Net::SSH::AuthenticationFailed
64
- raise if methods.empty? || ssh_options[:auth_methods]
65
- password_value = server.password || options[:password]
66
- retry
63
+ yield host, user, connection_options
64
+ rescue Net::SSH::AuthenticationFailed
65
+ raise if methods.empty? || ssh_options[:auth_methods]
66
+ password_value = server.password || options[:password]
67
+ retry
68
+ end
67
69
  end
68
70
  end
69
71
  end
@@ -1,7 +1,7 @@
1
1
  module Capistrano
2
2
  module Different
3
3
  module Password
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-different-password
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-27 00:00:00.000000000 Z
12
+ date: 2012-11-22 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: This gem make you can use different password with capistrano.
15
15
  email:
@@ -51,4 +51,3 @@ signing_key:
51
51
  specification_version: 3
52
52
  summary: This gem make you can use different password with capistrano.
53
53
  test_files: []
54
- has_rdoc: