knife-zero 1.18.2 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3482b27b06c57e695fffe467a3dc5fe813c5c108
4
- data.tar.gz: a31005457dbeacb0552fcde7927efa49457f865f
3
+ metadata.gz: 52199e9e746924c3c79500a9e400efc65106ecc3
4
+ data.tar.gz: 36e1acc1c01787057359d74e905d4cda5ca09dc3
5
5
  SHA512:
6
- metadata.gz: 49261c9d9dc2132d2e2404801399ba06ea66d3c577cb2e494ebe16a159c186eb32578dc8dd8dac0cfe39e3adc68010df96f9bc1cafc277226aa505626d40ff6f
7
- data.tar.gz: d4ce400adca4cc8b25bad7d8ae7b694210e4d4fd55c9b2e32e6b77e587c3cec59876f1d17f97bc8b705c2c610385902eb9198f96a88e98960249e3b43c4d3f83
6
+ metadata.gz: 97e2d77e4489f0918a66b6d964cda2278d1de4c9e17e521c12f5087bba224764af129727e4c9e0533e62ba519825eec9503da031c298d206d1d4823ad2b1687c
7
+ data.tar.gz: 2a09dff1d7181f5b3e5b570c2fb0add8a6431f6c37fd4b005d46440e14223f37e5c62cfde00bad5c2562842c487b1c2d05bd68f93405c3c3022a0bda51bf47f3
data/CHANGELOG.md CHANGED
@@ -2,11 +2,16 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- Empty.
5
+
6
+ ## v1.19.0
7
+
8
+ - enable keepalive on Net::SSH::Multi [#116](https://github.com/higanworks/knife-zero/pull/116)
9
+ - add option node_config_file to zero converge [#114](https://github.com/higanworks/knife-zero/pull/114)
10
+ - `-N, --node-config PATH_TO_CONFIG`
6
11
 
7
12
  ## v1.18.2
8
13
 
9
- - add -E option support for converge #112 HT: @yusukegoto
14
+ - add -E option support for converge [#112](https://github.com/higanworks/knife-zero/pull/112) HT: [@yusukegoto](https://github.com/yusukegoto)
10
15
 
11
16
  ## v1.18.1
12
17
 
@@ -19,11 +24,11 @@ Empty.
19
24
 
20
25
  ## v1.17.3
21
26
 
22
- - apply no-color to remote side #109 HT: @yusukegoto
27
+ - apply no-color to remote side [#109](https://github.com/higanworks/knife-zero/pull/109) HT: [@yusukegoto](https://github.com/yusukegoto)
23
28
 
24
29
  ## v1.17.2
25
30
 
26
- - pass true as 2nd args for Net::SSH.configuration_for by default. #106
31
+ - pass true as 2nd args for Net::SSH.configuration_for by default. [#106](https://github.com/higanworks/knife-zero/pull/106)
27
32
 
28
33
  ## v1.17.1
29
34
 
@@ -31,17 +36,17 @@ Empty.
31
36
 
32
37
  ## v1.17.0(Yanked)
33
38
 
34
- - Change: Ask overwrite node object at bootstrap #101
39
+ - Change: Ask overwrite node object at bootstrap [#101](https://github.com/higanworks/knife-zero/pull/101)
35
40
  - New option `--[no-]overwrite`
36
41
 
37
42
  ## v1.16.0
38
43
 
39
- - [Feature] converge with `--json-attributes` #98
44
+ - [Feature] converge with `--json-attributes` [#98](https://github.com/higanworks/knife-zero/pull/98)
40
45
 
41
46
  ## v1.15.3
42
47
 
43
48
  - [Bugfix] move overridden options of bootstrap into deps.
44
- - The new change about policy_group breaks knife bootstrap when policies aren't used #92
49
+ - The new change about policy_group breaks knife bootstrap when policies aren't used [#92](https://github.com/higanworks/knife-zero/pull/92)
45
50
 
46
51
  ## v1.15.2
47
52
 
@@ -30,6 +30,11 @@ class Chef
30
30
  self.options[:skip_cookbook_sync] = Chef::Application::Client.options[:skip_cookbook_sync]
31
31
  end
32
32
 
33
+ option :node_config_file,
34
+ :short => "-N PATH_TO_CONFIG",
35
+ :long => "--node-config PATH_TO_CONFIG",
36
+ :description => "The configuration file to use on remote node"
37
+
33
38
  option :splay,
34
39
  :long => "--splay SECONDS",
35
40
  :description => "The splay time for running at intervals, in seconds",
@@ -90,6 +95,7 @@ class Chef
90
95
  s << ' -j /etc/chef/chef_client_json.json' if @config[:json_attribs]
91
96
  s << " --splay #{@config[:splay]}" if @config[:splay]
92
97
  s << " -n #{@config[:named_run_list]}" if @config[:named_run_list]
98
+ s << " --config #{@config[:node_config_file]}" if @config[:node_config_file]
93
99
  s << " --skip-cookbook-sync" if @config[:skip_cookbook_sync]
94
100
  s << " --no-color" unless @config[:color]
95
101
  s << " -E #{@config[:environment]}" if @config[:environment]
@@ -55,3 +55,70 @@ if Gem::Version.new(Net::SSH::Multi::Version::STRING) < Gem::Version.new("1.3.0.
55
55
  end
56
56
  end
57
57
  end
58
+
59
+ ## monkey patch for ssh keepalive
60
+ # Ref: http://qiita.com/kackytw/items/49e2d10512b197089502
61
+ require 'net/ssh/multi/server'
62
+ module Net::SSH::Multi
63
+ class Server
64
+ class_eval do
65
+ require 'net/ssh/connection/keepalive'
66
+ def new_session #:nodoc:
67
+ session = if gateway
68
+ gateway.ssh(host, user, options)
69
+ else
70
+ Net::SSH.start(host, user, options)
71
+ end
72
+
73
+ ## >> Patch
74
+ @keepalive = Net::SSH::Connection::Keepalive.new(session)
75
+ ## << Patch
76
+
77
+ session[:server] = self
78
+ session
79
+ rescue ::Timeout::Error => error
80
+ raise Net::SSH::ConnectionTimeout.new("#{error.message} for #{host}")
81
+ rescue Net::SSH::AuthenticationFailed => error
82
+ raise Net::SSH::AuthenticationFailed.new("#{error.message}@#{host}")
83
+ end
84
+
85
+ ## >> Patch
86
+ def keepalive_if_needed(readers, writers)
87
+ listeners = session.listeners.keys
88
+ readers = readers || []
89
+ writers = writers || []
90
+ @keepalive.send_as_needed(!(listeners & readers).empty? || !(listeners & writers).empty?)
91
+ end
92
+ ## << Patch
93
+ end
94
+ end
95
+ end
96
+
97
+ require 'net/ssh/multi/session'
98
+ module Net::SSH::Multi
99
+ class Session
100
+ class_eval do
101
+ def process(wait=nil, &block)
102
+ realize_pending_connections!
103
+ wait = @connect_threads.any? ? 0 : wait
104
+
105
+ return false unless preprocess(&block)
106
+
107
+ readers = server_list.map { |s| s.readers }.flatten
108
+ writers = server_list.map { |s| s.writers }.flatten
109
+
110
+ readers, writers, = IO.select(readers, writers, nil, wait)
111
+
112
+ ## >> Patch
113
+ server_list.each { |server| server.keepalive_if_needed(readers, writers) }
114
+ ## << Patch
115
+
116
+ if readers
117
+ return postprocess(readers, writers)
118
+ else
119
+ return true
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Zero
3
- VERSION = "1.18.2"
3
+ VERSION = "1.19.0"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-zero
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.2
4
+ version: 1.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sawanoboly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-06 00:00:00.000000000 Z
11
+ date: 2017-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler