knife-zero 1.2.1 → 1.3.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 +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/chef/knife/zero_base.rb +1 -0
- data/lib/chef/knife/zero_bootstrap.rb +1 -1
- data/lib/knife-zero/core/bootstrap_context.rb +22 -8
- data/lib/knife-zero/version.rb +1 -1
- data/test/chef/knife/test_zero_bootstrap.rb +5 -1
- data/test/chef/knife/test_zero_chef_client.rb +4 -0
- data/test/knife-zero/core/test_bootstrap_context.rb +20 -0
- data/test/knife-zero/test_versioin.rb +1 -1
- metadata +4 -3
- data/lib/chef/knife/bootstrap/chef-full-localmode.erb +0 -74
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8a52879c7b2312b6a05e46f044746eed637e2070
|
|
4
|
+
data.tar.gz: 3125584c73940e7a77afc98f8ec48122e2cb1c06
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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.
|
data/lib/chef/knife/zero_base.rb
CHANGED
|
@@ -5,14 +5,28 @@ class Chef
|
|
|
5
5
|
module Core
|
|
6
6
|
class BootstrapContext
|
|
7
7
|
class_eval do
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
data/lib/knife-zero/version.rb
CHANGED
|
@@ -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
|
|
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
|
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.
|
|
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-
|
|
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 %>'
|