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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a32a5fe620a54193b033256128e075e5f9cf6489
4
- data.tar.gz: c899819b89589847f709f029d8a7999671ad6a26
3
+ metadata.gz: 78eea0a45dc96971a8ca19c4ad4adca6c958d749
4
+ data.tar.gz: 2ca8b1ddc35e0030c18f28944759027030622e5b
5
5
  SHA512:
6
- metadata.gz: b717a39a9403d4fd5635c5d325aaaab190f1f2b5abae8c1bb591d17ceef75d5f77212d6768fd620cecedba1d371c97cb1ceab8803dd10bc9de79b65ca6da4732
7
- data.tar.gz: c5c277db98f52fab444aab6adf26d90f26cc5648b3328da113c5d2dda1bff1bf8e76b599ba16955857856915ccb17acd7c4bbfdd53d11cf5244f9033618b6d79
6
+ metadata.gz: a6de703db7970fb788c970886555256d2c8b9ade52f1754b7d43e31c7dc0dcdd8364f8f05324c158e737cdd6615314b2014d8cab1834f8fe9185bfdd1ac1b0de
7
+ data.tar.gz: be6bcb9912982792b319a31169be2713c64006173f25ffaf84f8413f309f436ec5137d08ceb1f6a4b76851981038e71e8655f4a4ae4afe2b92b0572bdcac6c44
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog of knife-zero
2
2
 
3
+ ## v0.3.0.pre
4
+
5
+ - Feature: chef_client run parallel.
6
+
3
7
  ## v0.2.0
4
8
 
5
9
  - Feature: Support Why-run.
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
- Chef::Log.debug("Start session for #{n}")
39
- session = knife_ssh
40
- session.configure_session(n)
41
- session.ssh_command(start_chef_client)
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
@@ -0,0 +1,18 @@
1
+ module Knife
2
+ module Zero
3
+ module Helper
4
+ def count_alive_pids(pids)
5
+ alive = 0
6
+ pids.each do |pid|
7
+ begin
8
+ Process.getpgid pid
9
+ alive +=1
10
+ rescue
11
+ next
12
+ end
13
+ end
14
+ alive
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Zero
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0.pre"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
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.2.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: '0'
95
+ version: 1.3.1
96
96
  requirements: []
97
97
  rubyforge_project:
98
98
  rubygems_version: 2.2.2
@@ -1,7 +0,0 @@
1
- module Knife
2
- module Zero
3
- module Helper
4
- ## Some Helper..
5
- end
6
- end
7
- end