knife-zero 0.2.0 → 0.3.0.pre
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +12 -0
- data/lib/chef/knife/chef_client.rb +31 -4
- data/lib/knife-zero/helper.rb +18 -0
- data/lib/knife-zero/version.rb +1 -1
- metadata +4 -4
- data/lib/knife-zero/common.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78eea0a45dc96971a8ca19c4ad4adca6c958d749
|
4
|
+
data.tar.gz: 2ca8b1ddc35e0030c18f28944759027030622e5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6de703db7970fb788c970886555256d2c8b9ade52f1754b7d43e31c7dc0dcdd8364f8f05324c158e737cdd6615314b2014d8cab1834f8fe9185bfdd1ac1b0de
|
7
|
+
data.tar.gz: be6bcb9912982792b319a31169be2713c64006173f25ffaf84f8413f309f436ec5137d08ceb1f6a4b76851981038e71e8655f4a4ae4afe2b92b0572bdcac6c44
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -45,6 +45,11 @@ Install Chef to remote node and run chef-client under chef-zero via tcp-forward.
|
|
45
45
|
|
46
46
|
Supported options are mostly the same as `knife bootstrap`.
|
47
47
|
|
48
|
+
#### Specific options(s)
|
49
|
+
|
50
|
+
```
|
51
|
+
-W, --why-run Enable whyrun mode on chef-client run at remote node.
|
52
|
+
```
|
48
53
|
|
49
54
|
#### Example
|
50
55
|
|
@@ -116,6 +121,13 @@ Search nodes from local chef-repo directory, and run command at remote node.
|
|
116
121
|
|
117
122
|
Supported options are mostly the same as `knife ssh`.
|
118
123
|
|
124
|
+
#### Specific options(s)
|
125
|
+
|
126
|
+
```
|
127
|
+
-W, --why-run Enable whyrun mode on chef-client run at remote node.
|
128
|
+
-C, --concurrency NUMBER (0.3.0 or later) Number of concurrency. (default: 1) ; not avaiable on some platforms like Windows and NetBSD 4.
|
129
|
+
```
|
130
|
+
|
119
131
|
#### Example
|
120
132
|
|
121
133
|
```
|
@@ -1,10 +1,13 @@
|
|
1
1
|
require 'chef/knife'
|
2
2
|
require 'chef/knife/zero_base'
|
3
|
+
require 'knife-zero/helper'
|
3
4
|
|
4
5
|
class Chef
|
5
6
|
class Knife
|
6
7
|
class ZeroChefClient < Chef::Knife::Ssh
|
7
8
|
include Chef::Knife::ZeroBase
|
9
|
+
include ::Knife::Zero::Helper
|
10
|
+
|
8
11
|
deps do
|
9
12
|
require 'chef/node'
|
10
13
|
require 'chef/environment'
|
@@ -27,6 +30,13 @@ class Chef
|
|
27
30
|
:description => "execute the chef-client via sudo",
|
28
31
|
:boolean => true
|
29
32
|
|
33
|
+
option :concurrency,
|
34
|
+
:short => "-C NUMBER",
|
35
|
+
:long => "--concurrency NUMBER",
|
36
|
+
:description => "Number of concurrency. (default: 1) ; not avaiable on some platforms like Windows and NetBSD 4.",
|
37
|
+
:proc => lambda { |s| s.to_i },
|
38
|
+
:default => 1
|
39
|
+
|
30
40
|
def run
|
31
41
|
configure_attribute
|
32
42
|
configure_user
|
@@ -34,12 +44,29 @@ class Chef
|
|
34
44
|
configure_identity_file
|
35
45
|
list = search_nodes
|
36
46
|
|
47
|
+
pids = []
|
37
48
|
list.each do |n|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
49
|
+
# Note: fork(2) is not avaiable on some platforms like Windows and NetBSD 4.
|
50
|
+
if (Process.respond_to?(:fork) && !Chef::Platform.windows?)
|
51
|
+
pids << Process.fork {
|
52
|
+
Chef::Log.debug("Start session for #{n}")
|
53
|
+
session = knife_ssh
|
54
|
+
session.configure_session(n)
|
55
|
+
session.ssh_command(start_chef_client)
|
56
|
+
}
|
57
|
+
until count_alive_pids(pids) < @config[:concurrency]
|
58
|
+
sleep 1
|
59
|
+
end
|
60
|
+
else
|
61
|
+
Chef::Log.debug("Start session for #{n}")
|
62
|
+
session = knife_ssh
|
63
|
+
session.configure_session(n)
|
64
|
+
session.ssh_command(start_chef_client)
|
65
|
+
end
|
42
66
|
end
|
67
|
+
|
68
|
+
result = Process.waitall
|
69
|
+
## NOTE: should report if includes fail...?
|
43
70
|
end
|
44
71
|
|
45
72
|
def start_chef_client
|
data/lib/knife-zero/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-zero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sawanoboly
|
@@ -72,8 +72,8 @@ files:
|
|
72
72
|
- lib/chef/knife/zero_base.rb
|
73
73
|
- lib/chef/knife/zero_bootstrap.rb
|
74
74
|
- lib/knife-zero/bootstrap_ssh.rb
|
75
|
-
- lib/knife-zero/common.rb
|
76
75
|
- lib/knife-zero/core/bootstrap_context.rb
|
76
|
+
- lib/knife-zero/helper.rb
|
77
77
|
- lib/knife-zero/version.rb
|
78
78
|
homepage: ''
|
79
79
|
licenses:
|
@@ -90,9 +90,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
90
|
version: '0'
|
91
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- - "
|
93
|
+
- - ">"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
95
|
+
version: 1.3.1
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project:
|
98
98
|
rubygems_version: 2.2.2
|