knife-zero 1.2.1 → 1.3.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: e729fe2878ec1d2a13f131c08c241a570557bcfa
4
- data.tar.gz: fc5e3e2e48959607b9b92fafc25d4fe5013af357
3
+ metadata.gz: 8a52879c7b2312b6a05e46f044746eed637e2070
4
+ data.tar.gz: 3125584c73940e7a77afc98f8ec48122e2cb1c06
5
5
  SHA512:
6
- metadata.gz: 58de913724633bc5ccfa587bc683f724071945b79f6cad52b6f5d6346c16ad0cd2e77c4638ea0817ddf3d6faa04f5f6b12889ba4e69d89608038d9416b99a248
7
- data.tar.gz: 88c189a807cfcefb3fddd68363a2f00290c9040070cce47f2194e2ff5355fc196dba363feae603d89e27f457385887fd6f241702f0ef4f89f44e536686bf30c0
6
+ metadata.gz: 767c923ddd0b2f41f69be5bd28cbf81d958de19cea129db796613f0d251da777b940a48458fd6d50e2d7f8e88c71dfafc73a761bd29208446532a6aaa5aa8d4f
7
+ data.tar.gz: dcf59ee8ac62dfd553adcdd07a04b3c5a06393d3c43a48298157ca2bf75865feaacd3f2146bb077dc071feb062008a49dfba78c26716730add01dc8f32b6cddc
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## Unrelesed
4
4
 
5
+ ## v1.3.0
6
+
7
+ - return dummy key to validation.
8
+ - remove bootstrap template chef-full-localmode. use chef-full by default.
9
+ - create around alias for validation_key and start_chef to bootstrap_context.
10
+ - set true to Chef::Config[:knife_zero] for bootstrap_context.
11
+
5
12
  ## v1.2.1
6
13
 
7
14
  - set rescue for debug during ssh session.
@@ -7,6 +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
11
  Chef::Knife::Ssh.load_deps
11
12
  end
12
13
 
@@ -43,7 +43,7 @@ class Chef
43
43
  :short => "-d DISTRO",
44
44
  :long => "--distro DISTRO",
45
45
  :description => "Bootstrap a distro using a template",
46
- :default => "chef-full-localmode"
46
+ :default => "chef-full"
47
47
 
48
48
  option :use_sudo,
49
49
  :long => "--sudo",
@@ -5,14 +5,28 @@ class Chef
5
5
  module Core
6
6
  class BootstrapContext
7
7
  class_eval do
8
- def start_chef_local
9
- client_path = @chef_config[:chef_client_path] || 'chef-client'
10
- s = "#{client_path} -j /etc/chef/first-boot.json"
11
- s << ' -l debug' if @config[:verbosity] and @config[:verbosity] >= 2
12
- s << " -E #{bootstrap_environment}" if ::Chef::VERSION.to_f != 0.9 # only use the -E option on Chef 0.10+
13
- s << " -S http://127.0.0.1:#{URI.parse(Chef::Config.chef_server_url).port}"
14
- s << " -W" if @config[:why_run]
15
- s
8
+ alias :orig_validation_key validation_key
9
+ def validation_key
10
+ if @chef_config[:knife_zero]
11
+ OpenSSL::PKey::RSA.new(2048).to_s
12
+ else
13
+ orig_validation_key
14
+ end
15
+ end
16
+
17
+ alias :orig_start_chef start_chef
18
+ def start_chef
19
+ if @chef_config[:knife_zero]
20
+ client_path = @chef_config[:chef_client_path] || 'chef-client'
21
+ s = "#{client_path} -j /etc/chef/first-boot.json"
22
+ s << ' -l debug' if @config[:verbosity] and @config[:verbosity] >= 2
23
+ s << " -E #{bootstrap_environment}" if ::Chef::VERSION.to_f != 0.9 # only use the -E option on Chef 0.10+
24
+ s << " -S http://127.0.0.1:#{URI.parse(Chef::Config.chef_server_url).port}"
25
+ s << " -W" if @config[:why_run]
26
+ s
27
+ else
28
+ orig_start_chef
29
+ end
16
30
  end
17
31
  end
18
32
  end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Zero
3
- VERSION = "1.2.1"
3
+ VERSION = "1.3.0"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
@@ -9,8 +9,12 @@ class TC_ZeroBootstrap < Test::Unit::TestCase
9
9
  Chef::Knife::ZeroBootstrap.load_deps
10
10
  end
11
11
 
12
+ test "returns true from Chef::Config[:knife_zero]" do
13
+ assert_true(Chef::Config[:knife_zero])
14
+ end
15
+
12
16
  test "returns changed value from core" do
13
- assert_equal("chef-full-localmode", @app.config[:distro])
17
+ assert_equal("chef-full", @app.config[:distro])
14
18
  end
15
19
 
16
20
  test "returns BootstrapSsh via knife_ssh" do
@@ -6,6 +6,10 @@ class TC_ZeroChefClient < Test::Unit::TestCase
6
6
  @app.merge_configs
7
7
  end
8
8
 
9
+ test "returns true from Chef::Config[:knife_zero]" do
10
+ assert(Chef::Config[:knife_zero])
11
+ end
12
+
9
13
  test "returns changed value from core" do
10
14
  assert_nil(@app.config[:concurrency])
11
15
  assert_nil(@app.config[:override_runlist])
@@ -0,0 +1,20 @@
1
+ require 'chef/knife/zero_chef_client'
2
+ require 'knife-zero/core/bootstrap_context'
3
+
4
+ class TC_BootstrapContext < Test::Unit::TestCase
5
+ def setup
6
+ Chef::Config[:validation_key] = nil
7
+ app = Chef::Knife::ZeroBootstrap.new
8
+ app.merge_configs
9
+ @bsc = Chef::Knife::Core::BootstrapContext.new(app.config, [], Chef::Config.configuration)
10
+ stub(OpenSSL::PKey::RSA).new{"knfe-zerozero"}
11
+ end
12
+
13
+ test "Should use aliased validation_key" do
14
+ assert_equal("knfe-zerozero", @bsc.validation_key)
15
+ end
16
+
17
+ test "Should use aliased start_chef" do
18
+ assert_match('-S http://127.0.0.1', @bsc.start_chef)
19
+ end
20
+ end
@@ -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.2.0", Knife::Zero::VERSION)
5
+ assert_equal("1.3.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.2.1
4
+ version: 1.3.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-04-01 00:00:00.000000000 Z
11
+ date: 2015-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -167,7 +167,6 @@ files:
167
167
  - Rakefile
168
168
  - circle.yml
169
169
  - knife-zero.gemspec
170
- - lib/chef/knife/bootstrap/chef-full-localmode.erb
171
170
  - lib/chef/knife/zero_base.rb
172
171
  - lib/chef/knife/zero_bootstrap.rb
173
172
  - lib/chef/knife/zero_chef_client.rb
@@ -179,6 +178,7 @@ files:
179
178
  - lib/knife-zero/version.rb
180
179
  - test/chef/knife/test_zero_bootstrap.rb
181
180
  - test/chef/knife/test_zero_chef_client.rb
181
+ - test/knife-zero/core/test_bootstrap_context.rb
182
182
  - test/knife-zero/test_bootstrap_ssh.rb
183
183
  - test/knife-zero/test_versioin.rb
184
184
  - test/run_test.rb
@@ -210,6 +210,7 @@ summary: Run chef-client at remote node with chef-zero(local-mode) via HTTP over
210
210
  test_files:
211
211
  - test/chef/knife/test_zero_bootstrap.rb
212
212
  - test/chef/knife/test_zero_chef_client.rb
213
+ - test/knife-zero/core/test_bootstrap_context.rb
213
214
  - test/knife-zero/test_bootstrap_ssh.rb
214
215
  - test/knife-zero/test_versioin.rb
215
216
  - test/run_test.rb
@@ -1,74 +0,0 @@
1
- bash -c '
2
- <%= "export https_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
3
-
4
- distro=`uname -s`
5
-
6
- if test "x$distro" = "xSunOS"; then
7
- if test -d "/usr/sfw/bin"; then
8
- PATH=/usr/sfw/bin:$PATH
9
- export PATH
10
- fi
11
- fi
12
-
13
- exists() {
14
- if command -v $1 &>/dev/null
15
- then
16
- return 0
17
- else
18
- return 1
19
- fi
20
- }
21
-
22
- <% if knife_config[:bootstrap_install_command] %>
23
- <%= knife_config[:bootstrap_install_command] %>
24
- <% else %>
25
- install_sh="<%= knife_config[:bootstrap_url] ? knife_config[:bootstrap_url] : "https://www.chef.io/chef/install.sh" %>"
26
- if ! exists /usr/bin/chef-client; then
27
- echo "Installing Chef Client..."
28
- if exists wget; then
29
- bash <(wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %> <%= knife_config[:bootstrap_wget_options] %> ${install_sh} -O -) <%= latest_current_chef_version_string %>
30
- elif exists curl; then
31
- bash <(curl -L <%= "--proxy \"#{knife_config[:bootstrap_proxy]}\" " if knife_config[:bootstrap_proxy] %> <%= knife_config[:bootstrap_curl_options] %> ${install_sh}) <%= latest_current_chef_version_string %>
32
- else
33
- echo "Neither wget nor curl found. Please install one and try again." >&2
34
- exit 1
35
- fi
36
- fi
37
- <% end %>
38
-
39
- mkdir -p /etc/chef
40
-
41
- cat > /etc/chef/validation.pem <<'EOP'
42
- <%= OpenSSL::PKey::RSA.new 2048 %>
43
- EOP
44
- chmod 0600 /etc/chef/validation.pem
45
-
46
- <% if encrypted_data_bag_secret -%>
47
- cat > /etc/chef/encrypted_data_bag_secret <<'EOP'
48
- <%= encrypted_data_bag_secret %>
49
- EOP
50
- chmod 0600 /etc/chef/encrypted_data_bag_secret
51
- <% end -%>
52
-
53
- <%# Generate Ohai Hints -%>
54
- <% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
55
- mkdir -p /etc/chef/ohai/hints
56
-
57
- <% @chef_config[:knife][:hints].each do |name, hash| -%>
58
- cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
59
- <%= Chef::JSONCompat.to_json(hash) %>
60
- EOP
61
- <% end -%>
62
- <% end -%>
63
-
64
- cat > /etc/chef/client.rb <<'EOP'
65
- <%= config_content %>
66
- EOP
67
-
68
- cat > /etc/chef/first-boot.json <<'EOP'
69
- <%= Chef::JSONCompat.to_json(first_boot) %>
70
- EOP
71
-
72
- echo "Starting first Chef Client run..."
73
-
74
- <%= start_chef_local %>'