knife-zero 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4383c976a2e1f917aaec4d23f7684e13bc72fb2
4
- data.tar.gz: 43698c8ac6150af68f0744215d8a66fbcd54d8da
3
+ metadata.gz: faceb4268fabca7f9ce0d461762633eee1e462c7
4
+ data.tar.gz: 9fa1e9d3057549778c1aecbcd9610bb8b4e78194
5
5
  SHA512:
6
- metadata.gz: eacd35b62835fd3879179b19060f1d8682962c08fddd84e3a0f80b9d01164298c58f62ee1bb1818c0351f775c4c3ab586d32d239125b68b1e850f4e4496ef29d
7
- data.tar.gz: bf56cd573120019588155d0302139cc990fca572707702809087d41db75daa460d9ed86208a9dccd473359c23131a360cc459c6447c61a30e0bd600ee50b998a
6
+ metadata.gz: 33bab13eec4bb5b1d9630ecdf740bb61acd08b5d7d435b9a743c048faba61b8ddf8f8a3a13e2cd4190c99fe86b45ea629840421fb26c3beb71e368dba900ff5b
7
+ data.tar.gz: 18a186631c76e4a9e996f87becc6dde87c834fdc9a6fd306fffe9a20ecb92f4fe9ad32ac732a86bca8656fd3012f8f5b79652ae30a3b1f781d37835f720810a6
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## v1.7.0
6
+
7
+ - Bug: ignored knife[:use_sudo] by converge, #22 #42
8
+ - Feature: Append white_list to client.rb at bootstrap. #43
9
+ - Feature: Add --without-chef-run to zero bootstrap #44
10
+
5
11
  ## v1.6.0
6
12
 
7
13
  - Feature: #32 create alias converge to chef_client, and recommended it by README.
@@ -7,7 +7,7 @@ class Chef
7
7
  includer.class_eval do
8
8
  deps do
9
9
  Chef::Config[:local_mode] = true
10
- Chef::Config[:knife_zero] = true
10
+ Chef::Config[:knife_zero] = Hash.new
11
11
  Chef::Knife::Ssh.load_deps
12
12
  end
13
13
 
@@ -19,6 +19,11 @@ class Chef
19
19
  self.options.delete :node_ssl_verify_mode
20
20
  self.options.delete :node_verify_api_cert
21
21
 
22
+ option :without_chef_run,
23
+ :long => "--without-chef-run",
24
+ :description => "Bootstrap without Chef-Client Run.(for only update client.rb)",
25
+ :boolean => false
26
+
22
27
  def knife_ssh
23
28
  begin
24
29
  ssh = Chef::Knife::BootstrapSsh.new
@@ -15,9 +15,17 @@ class Chef
15
15
  banner "knife zero chef_client QUERY (options) | It's same as converge"
16
16
 
17
17
  self.options = Ssh.options.merge(self.options)
18
- self.options[:use_sudo] = Bootstrap.options[:use_sudo]
19
18
  self.options[:use_sudo_password] = Bootstrap.options[:use_sudo_password]
20
19
 
20
+
21
+ option :use_sudo,
22
+ :long => "--[no-]sudo",
23
+ :description => "Execute the chef-client via sudo (true by default)",
24
+ :boolean => true,
25
+ :default => true,
26
+ :proc => lambda { |v| Chef::Config[:knife][:use_sudo] = v }
27
+
28
+
21
29
  option :override_runlist,
22
30
  :short => "-o RunlistItem,RunlistItem...",
23
31
  :long => "--override-runlist RunlistItem,RunlistItem...",
@@ -28,17 +36,19 @@ class Chef
28
36
 
29
37
  def initialize(argv=[])
30
38
  super
39
+ self.configure_chef
31
40
  @name_args = [@name_args[0], start_chef_client]
32
41
  end
33
42
 
34
43
  def start_chef_client
35
- client_path = @config[:use_sudo] ? 'sudo ' : ''
44
+ client_path = @config[:use_sudo] || Chef::Config[:knife][:use_sudo] ? 'sudo ' : ''
36
45
  client_path = @config[:chef_client_path] ? "#{client_path}#{@config[:chef_client_path]}" : "#{client_path}chef-client"
37
46
  s = "#{client_path}"
38
47
  s << ' -l debug' if @config[:verbosity] and @config[:verbosity] >= 2
39
48
  s << " -S http://127.0.0.1:#{::Knife::Zero::Helper.zero_remote_port}"
40
49
  s << " -o #{@config[:override_runlist]}" if @config[:override_runlist]
41
50
  s << " -W" if @config[:why_run]
51
+ Chef::Log.info "Remote command: " + s
42
52
  s
43
53
  end
44
54
  end
@@ -15,9 +15,24 @@ class Chef
15
15
  end
16
16
  end
17
17
 
18
+ alias :orig_config_content config_content
19
+ def config_content
20
+ client_rb = orig_config_content
21
+ %w{ automatic_attribute_whitelist default_attribute_whitelist normal_attribute_whitelist override_attribute_whitelist }.each do |white_list|
22
+ if Chef::Config[:knife][white_list.to_sym] && Chef::Config[:knife][white_list.to_sym].is_a?(Array)
23
+ client_rb << [
24
+ white_list,
25
+ Chef::Config[:knife][white_list.to_sym].to_s
26
+ ].join(" ")
27
+ end
28
+ end
29
+ client_rb
30
+ end
31
+
18
32
  alias :orig_start_chef start_chef
19
33
  def start_chef
20
34
  if @chef_config[:knife_zero]
35
+ unless @config[:without_chef_run]
21
36
  client_path = @chef_config[:chef_client_path] || 'chef-client'
22
37
  s = "#{client_path} -j /etc/chef/first-boot.json"
23
38
  s << ' -l debug' if @config[:verbosity] and @config[:verbosity] >= 2
@@ -25,6 +40,9 @@ class Chef
25
40
  s << " -S http://127.0.0.1:#{::Knife::Zero::Helper.zero_remote_port}"
26
41
  s << " -W" if @config[:why_run]
27
42
  s
43
+ else
44
+ "echo Execution of Chef-Client has been canceled due to --without-chef-run."
45
+ end
28
46
  else
29
47
  orig_start_chef
30
48
  end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Zero
3
- VERSION = "1.6.0"
3
+ VERSION = "1.7.0"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
@@ -10,7 +10,7 @@ class TC_ZeroBootstrap < Test::Unit::TestCase
10
10
  end
11
11
 
12
12
  test "returns true from Chef::Config[:knife_zero]" do
13
- assert_true(Chef::Config[:knife_zero])
13
+ assert_equal({}, Chef::Config[:knife_zero])
14
14
  end
15
15
 
16
16
  test "returns expected bootstrap template(for notice changes of core to me)" do
@@ -2,6 +2,6 @@ require "knife-zero/version"
2
2
 
3
3
  class TC_Version < Test::Unit::TestCase
4
4
  test "returns version correctly" do
5
- assert_equal("1.6.0", Knife::Zero::VERSION)
5
+ assert_equal("1.7.0", Knife::Zero::VERSION)
6
6
  end
7
7
  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.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sawanoboly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-13 00:00:00.000000000 Z
11
+ date: 2015-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler