knife-zero 1.4.0 → 1.5.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 +8 -4
- data/Dockerfile +25 -0
- data/README.md +18 -13
- data/circle.yml +8 -0
- data/integration_test/chef-repo/knife.rb +2 -0
- data/integration_test/chef-repo/run.sh +10 -0
- data/integration_test/pre/Dockerfile +11 -0
- data/lib/chef/knife/zero_base.rb +12 -0
- data/lib/chef/knife/zero_bootstrap.rb +29 -10
- data/lib/chef/knife/zero_chef_client.rb +0 -5
- data/lib/chef/knife/zero_diagnose.rb +1 -1
- data/lib/knife-zero/version.rb +1 -1
- data/test/chef/knife/test_zero_bootstrap.rb +1 -1
- data/test/knife-zero/core/test_bootstrap_context.rb +2 -2
- data/test/knife-zero/core/test_zerohelper.rb +43 -0
- data/test/knife-zero/test_versioin.rb +1 -1
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7615a63a5eff793078740317f3ca12fdb607821e
|
4
|
+
data.tar.gz: 0d73adc8804b0bd7795cdf3c7bfa4f37b73ed7ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abec6340cc40f8df2457bb2d11323c4f83d12a4a2cedd6f8178fe98e6803a70e9a3ec3732d3a38e196da9d8b1a1678ac404c1ccdf1430484e5127199b50eb5ef
|
7
|
+
data.tar.gz: ec85f918f363ac842b3e65c1391ba9093e2ba6322763fa55249be4fa7bc01af698167116c81a8540cb7b5aa3595bb84c032c36f9b7c81c4ceb224460b29d5514
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
# Changelog of knife-zero
|
2
2
|
|
3
|
-
##
|
3
|
+
## Unreleased
|
4
|
+
|
5
|
+
## v1.5.0
|
6
|
+
|
7
|
+
- Feature: Support bootstrap as vault client(chef-vault).
|
4
8
|
|
5
9
|
## v1.4.0
|
6
10
|
|
7
11
|
- Change: remote listen by local chef-zero port + 10000
|
8
|
-
- Feature:
|
12
|
+
- Feature: override Remote Chef-Zero port.
|
9
13
|
|
10
14
|
## v1.3.0
|
11
15
|
|
@@ -29,7 +33,7 @@
|
|
29
33
|
|
30
34
|
## v1.1.5
|
31
35
|
|
32
|
-
-
|
36
|
+
- Fix: remove debug code.
|
33
37
|
|
34
38
|
## v1.1.4
|
35
39
|
|
@@ -78,7 +82,7 @@
|
|
78
82
|
|
79
83
|
## v0.1.0 (yanked)
|
80
84
|
|
81
|
-
- Feature: run Chef-Client by
|
85
|
+
- Feature: run Chef-Client by Search query.
|
82
86
|
|
83
87
|
|
84
88
|
## v0.0.2
|
data/Dockerfile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
FROM higanworks/knife-zero-edgebase
|
2
|
+
MAINTAINER sawanoboriyu@higanworks.com
|
3
|
+
|
4
|
+
ADD .git/index /index
|
5
|
+
|
6
|
+
WORKDIR /home
|
7
|
+
RUN wget https://codeload.github.com/chef/chef/legacy.tar.gz/master
|
8
|
+
RUN tar xvzf master && mv chef-chef-* chef
|
9
|
+
|
10
|
+
WORKDIR /home/chef
|
11
|
+
|
12
|
+
RUN gem build chef.gemspec
|
13
|
+
RUN gem install -V -b chef*.gem --no-ri --no-rdoc
|
14
|
+
|
15
|
+
ADD . /home/knife-zero/
|
16
|
+
ADD integration_test/chef-repo /chef-repo/
|
17
|
+
|
18
|
+
WORKDIR /home/knife-zero
|
19
|
+
|
20
|
+
RUN gem build knife-zero.gemspec
|
21
|
+
RUN gem install -V -l knife-zero-*.gem
|
22
|
+
|
23
|
+
WORKDIR /chef-repo
|
24
|
+
|
25
|
+
CMD ["sh", "run.sh"]
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Knife-Plugin Zero
|
2
2
|
|
3
|
-
[](https://circleci.com/gh/higanworks/knife-zero)
|
3
|
+
- current_master: [](https://circleci.com/gh/higanworks/knife-zero/tree/master)
|
4
|
+
- integration_with_edge_chef: [](https://circleci.com/gh/higanworks/knife-zero/tree/integration_testedge)
|
4
5
|
|
5
6
|
[](https://gitter.im/higanworks/knife-zero?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
6
7
|
|
@@ -8,11 +9,11 @@
|
|
8
9
|
[](http://waffle.io/higanworks/knife-zero)
|
9
10
|
[](http://waffle.io/higanworks/knife-zero)
|
10
11
|
|
11
|
-
Run chef-client at remote node with chef-zero(local-mode) via HTTP over SSH port
|
12
|
+
Run chef-client at remote node with chef-zero(local-mode) via HTTP over SSH port forwarding.
|
12
13
|
|
13
14
|
- It doesn't have to transport cookbooks via scp,rsync or something.
|
14
15
|
- It can collect node object into local chef-repo.
|
15
|
-
- It supports all
|
16
|
+
- It supports all functions of chef(C/S).
|
16
17
|
- You have only to manage one chef-repo.
|
17
18
|
|
18
19
|
## Requirements
|
@@ -73,7 +74,7 @@ host.example.com Starting Chef Client, version 11.14.6
|
|
73
74
|
host.example.com Creating a new client identity for host.example.com using the validator key.
|
74
75
|
|
75
76
|
|
76
|
-
##
|
77
|
+
## Resolve and sync cookbook via http over ssh tcp-forward by run-list.
|
77
78
|
host.example.com resolving cookbooks for run list: ["hogehoge::default"]
|
78
79
|
host.example.com Synchronizing Cookbooks:
|
79
80
|
host.example.com - hogehoge
|
@@ -105,7 +106,7 @@ Platform: ubuntu 12.04
|
|
105
106
|
Tags:
|
106
107
|
```
|
107
108
|
|
108
|
-
|
109
|
+
Search and execute command via ssh by knife ssh.
|
109
110
|
|
110
111
|
```
|
111
112
|
$ knife ssh 'hostname:*' --local-mode uptime --attribute ipaddress
|
@@ -181,7 +182,7 @@ host2.example.com Chef Client finished, 0/0 resources updated in 3.729471856 sec
|
|
181
182
|
1. bundle init and add below.
|
182
183
|
- `gem 'chef' `
|
183
184
|
- `gem 'knife-zero'`
|
184
|
-
- and cookbook management tool such as `
|
185
|
+
- and cookbook management tool such as `Berkshelf` or `Librarian-Chef`.
|
185
186
|
1. bundle
|
186
187
|
e.g.) `bundle install --path vendor/bundle --binstubs`
|
187
188
|
1. install cookbooks to `./cookbooks`. (if you need run recipe.)
|
@@ -197,7 +198,11 @@ See [Getting Started knife-zero with test-kitchen](https://github.com/higanworks
|
|
197
198
|
|
198
199
|
### Or, Try knife-zero simply with Vagrant.
|
199
200
|
|
200
|
-
|
201
|
+
> **For Your Information** :
|
202
|
+
> If only you want to try `chef-zero` or `chef-client localmode` (For instance: migrate from chef-solo), You should use [chef-zero provisioner(Vagrant)](http://docs.vagrantup.com/v2/provisioning/chef_zero.html) with vagrant.
|
203
|
+
> The knife-zero will provides similar usage with the chef-zero provisioner on vagrant, but for remote node.
|
204
|
+
|
205
|
+
Set local_mode as default to `knife.rb`.
|
201
206
|
|
202
207
|
```
|
203
208
|
$ echo 'local_mode true' >> knife.rb
|
@@ -343,9 +348,9 @@ $ knife zero chef_client "name:*" -x vagrant -i ./.vagrant/machines/default/virt
|
|
343
348
|
192.168.33.10 resolving cookbooks for run list: []
|
344
349
|
```
|
345
350
|
|
346
|
-
## Debug for
|
351
|
+
## Debug for Configuration
|
347
352
|
|
348
|
-
`knife zero diagnose` shows
|
353
|
+
`knife zero diagnose` shows configuration from file(Such as knife.rb).
|
349
354
|
|
350
355
|
```
|
351
356
|
$ knife zero diagnose
|
@@ -355,10 +360,10 @@ Chef::Config
|
|
355
360
|
---
|
356
361
|
:local_mode: true
|
357
362
|
:verbosity:
|
358
|
-
:config_file: "/Users/sawanoboriyu/github/higanworks/knife-
|
363
|
+
:config_file: "/Users/sawanoboriyu/github/higanworks/knife-zero_playground/knife.rb"
|
359
364
|
:color: true
|
360
365
|
:log_level: :error
|
361
|
-
:chef_repo_path: "/Users/sawanoboriyu/github/higanworks/knife-
|
366
|
+
:chef_repo_path: "/Users/sawanoboriyu/github/higanworks/knife-zero_playground"
|
362
367
|
:log_location: !ruby/object:IO {}
|
363
368
|
:chef_server_url: http://localhost:8889
|
364
369
|
:repo_mode: everything
|
@@ -373,9 +378,9 @@ Knife::Config
|
|
373
378
|
:format: summary
|
374
379
|
:ssh_user: root
|
375
380
|
:host_key_verify: true
|
376
|
-
:config_file: "/Users/sawanoboriyu/github/higanworks/knife-
|
381
|
+
:config_file: "/Users/sawanoboriyu/github/higanworks/knife-zero_playground/knife.rb"
|
377
382
|
|
378
|
-
Zero
|
383
|
+
Zero Bootstrap Config
|
379
384
|
====================
|
380
385
|
---
|
381
386
|
:ssh_user: root
|
data/circle.yml
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
machine:
|
3
3
|
ruby:
|
4
4
|
version: 2.1.5
|
5
|
+
services:
|
6
|
+
- docker
|
5
7
|
test:
|
6
8
|
override:
|
7
9
|
- bundle exec ruby test/run_test.rb -v
|
10
|
+
deployment:
|
11
|
+
integration:
|
12
|
+
branch: integration_testedge
|
13
|
+
commands:
|
14
|
+
- docker build -t local/knife-zero .
|
15
|
+
- docker run -it local/knife-zero sh run.sh
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
/usr/sbin/sshd -E /tmp/log -o 'LogLevel DEBUG'
|
6
|
+
knife zero diagnose
|
7
|
+
knife zero bootstrap 127.0.0.1 -N zerohost -x docker -P docker --sudo -V
|
8
|
+
knife node show zerohost
|
9
|
+
knife zero chef_client "name:zerohost" -a ipaddress -x docker -P docker --sudo -V
|
10
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
FROM ubuntu:15.04
|
2
|
+
MAINTAINER sawanoboriyu@higanworks.com
|
3
|
+
|
4
|
+
RUN apt-get -y update
|
5
|
+
RUN apt-get -y install sudo git build-essential ruby2.1 ruby2.1-dev openssh-server wget vim net-tools
|
6
|
+
|
7
|
+
|
8
|
+
RUN mkdir /var/run/sshd
|
9
|
+
RUN useradd -p $(perl -e'print crypt("docker", "docker")') -m docker
|
10
|
+
RUN echo '%docker ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/docker
|
11
|
+
CMD ["/bin/true"]
|
data/lib/chef/knife/zero_base.rb
CHANGED
@@ -11,6 +11,7 @@ class Chef
|
|
11
11
|
Chef::Knife::Ssh.load_deps
|
12
12
|
end
|
13
13
|
|
14
|
+
## Just ported from chef
|
14
15
|
option :ssh_user,
|
15
16
|
:short => "-x USERNAME",
|
16
17
|
:long => "--ssh-user USERNAME",
|
@@ -51,6 +52,17 @@ class Chef
|
|
51
52
|
:boolean => true,
|
52
53
|
:default => true
|
53
54
|
|
55
|
+
option :use_sudo,
|
56
|
+
:long => "--sudo",
|
57
|
+
:description => "execute the chef-client via sudo",
|
58
|
+
:boolean => true
|
59
|
+
|
60
|
+
option :use_sudo_password,
|
61
|
+
:long => "--use-sudo-password",
|
62
|
+
:description => "Execute the bootstrap via sudo with password",
|
63
|
+
:boolean => false
|
64
|
+
|
65
|
+
## Added by Knife-Zero
|
54
66
|
option :why_run,
|
55
67
|
:short => '-W',
|
56
68
|
:long => '--why-run',
|
@@ -14,6 +14,7 @@ class Chef
|
|
14
14
|
|
15
15
|
banner "knife zero bootstrap FQDN (options)"
|
16
16
|
|
17
|
+
## Just ported from chef bootstrap
|
17
18
|
option :chef_node_name,
|
18
19
|
:short => "-N NAME",
|
19
20
|
:long => "--node-name NAME",
|
@@ -38,23 +39,19 @@ class Chef
|
|
38
39
|
:description => "Do not proxy locations for the node being bootstrapped; this option is used internally by Opscode",
|
39
40
|
:proc => Proc.new { |np| Chef::Config[:knife][:bootstrap_no_proxy] = np }
|
40
41
|
|
41
|
-
|
42
|
+
# DEPR: Remove this option in Chef 13
|
42
43
|
option :distro,
|
43
44
|
:short => "-d DISTRO",
|
44
45
|
:long => "--distro DISTRO",
|
45
46
|
:description => "Bootstrap a distro using a template",
|
46
47
|
:default => "chef-full"
|
47
48
|
|
48
|
-
option :
|
49
|
-
:
|
50
|
-
:
|
51
|
-
:
|
52
|
-
|
53
|
-
option :use_sudo_password,
|
54
|
-
:long => "--use-sudo-password",
|
55
|
-
:description => "Execute the bootstrap via sudo with password",
|
56
|
-
:boolean => false
|
49
|
+
option :bootstrap_template,
|
50
|
+
:short => "-t TEMPLATE",
|
51
|
+
:long => "--bootstrap-template TEMPLATE",
|
52
|
+
:description => "Bootstrap Chef using a built-in or custom template. Set to the full path of an erb template or use one of the built-in templates."
|
57
53
|
|
54
|
+
# DEPR: Remove this option in Chef 13
|
58
55
|
option :template_file,
|
59
56
|
:long => "--template-file TEMPLATE",
|
60
57
|
:description => "Full path to location of template to use",
|
@@ -113,6 +110,28 @@ class Chef
|
|
113
110
|
:description => "Add options to curl when install chef-client",
|
114
111
|
:proc => Proc.new { |co| Chef::Config[:knife][:bootstrap_curl_options] = co }
|
115
112
|
|
113
|
+
|
114
|
+
## experimental: vault support
|
115
|
+
option :bootstrap_vault_file,
|
116
|
+
:long => '--bootstrap-vault-file VAULT_FILE',
|
117
|
+
:description => 'A JSON file with a list of vault(s) and item(s) to be updated'
|
118
|
+
|
119
|
+
option :bootstrap_vault_json,
|
120
|
+
:long => '--bootstrap-vault-json VAULT_JSON',
|
121
|
+
:description => 'A JSON string with the vault(s) and item(s) to be updated'
|
122
|
+
|
123
|
+
option :bootstrap_vault_item,
|
124
|
+
:long => '--bootstrap-vault-item VAULT_ITEM',
|
125
|
+
:description => 'A single vault and item to update as "vault:item"',
|
126
|
+
:proc => Proc.new { |i|
|
127
|
+
(vault, item) = i.split(/:/)
|
128
|
+
Chef::Config[:knife][:bootstrap_vault_item] ||= {}
|
129
|
+
Chef::Config[:knife][:bootstrap_vault_item][vault] ||= []
|
130
|
+
Chef::Config[:knife][:bootstrap_vault_item][vault].push(item)
|
131
|
+
Chef::Config[:knife][:bootstrap_vault_item]
|
132
|
+
}
|
133
|
+
|
134
|
+
|
116
135
|
def knife_ssh
|
117
136
|
begin
|
118
137
|
ssh = Chef::Knife::BootstrapSsh.new
|
@@ -27,11 +27,6 @@ class Chef
|
|
27
27
|
:description => "The attribute to use for opening the connection - default depends on the context",
|
28
28
|
:proc => Proc.new { |key| Chef::Config[:knife][:ssh_attribute] = key.strip }
|
29
29
|
|
30
|
-
option :use_sudo,
|
31
|
-
:long => "--sudo",
|
32
|
-
:description => "execute the chef-client via sudo",
|
33
|
-
:boolean => true
|
34
|
-
|
35
30
|
option :override_runlist,
|
36
31
|
:short => "-o RunlistItem,RunlistItem...",
|
37
32
|
:long => "--override-runlist RunlistItem,RunlistItem...",
|
data/lib/knife-zero/version.rb
CHANGED
@@ -22,7 +22,7 @@ class TC_ZeroBootstrap < Test::Unit::TestCase
|
|
22
22
|
assert_kind_of(Chef::Knife::BootstrapSsh, ssh)
|
23
23
|
end
|
24
24
|
|
25
|
-
sub_test_case "overwrite
|
25
|
+
sub_test_case "overwrite ssh_configuration from ssh/config" do
|
26
26
|
test "overwrite port number" do
|
27
27
|
stub(Net::SSH).configuration_for { {port: 10022} }
|
28
28
|
ssh = @app.knife_ssh
|
@@ -7,11 +7,11 @@ class TC_BootstrapContext < Test::Unit::TestCase
|
|
7
7
|
app = Chef::Knife::ZeroBootstrap.new
|
8
8
|
app.merge_configs
|
9
9
|
@bsc = Chef::Knife::Core::BootstrapContext.new(app.config, [], Chef::Config.configuration)
|
10
|
-
stub(OpenSSL::PKey::RSA).new{"
|
10
|
+
stub(OpenSSL::PKey::RSA).new{"knife-zerozero"}
|
11
11
|
end
|
12
12
|
|
13
13
|
test "Should use aliased validation_key" do
|
14
|
-
assert_equal("
|
14
|
+
assert_equal("knife-zerozero", @bsc.validation_key)
|
15
15
|
end
|
16
16
|
|
17
17
|
test "Should use aliased start_chef" do
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'chef/knife/zero_base'
|
2
|
+
require 'knife-zero/helper'
|
3
|
+
|
4
|
+
class TC_ZeroHelper < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@config = Chef::Config
|
7
|
+
end
|
8
|
+
|
9
|
+
test "Should returns 18889 as zero_remote_port by default" do
|
10
|
+
assert_equal(18889, ::Knife::Zero::Helper.zero_remote_port)
|
11
|
+
end
|
12
|
+
|
13
|
+
sub_test_case "override" do
|
14
|
+
test "Should returns 10000 + chef_zero_port as zero_remote_port" do
|
15
|
+
@config[:chef_zero_port] = 2500
|
16
|
+
assert_equal(12500, ::Knife::Zero::Helper.zero_remote_port)
|
17
|
+
end
|
18
|
+
|
19
|
+
test "Should returns 10000 + knife:chef_zero_port as zero_remote_port" do
|
20
|
+
@config[:knife][:chef_zero_port] = 2500
|
21
|
+
assert_equal(12500, ::Knife::Zero::Helper.zero_remote_port)
|
22
|
+
end
|
23
|
+
|
24
|
+
def teardown
|
25
|
+
@config[:chef_zero_port] = nil
|
26
|
+
@config[:knife][:chef_zero_port] = nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
sub_test_case "force set by remote_chef_zero_port" do
|
31
|
+
|
32
|
+
test "Should returns passed remote_chef_zero_port as zero_remote_port" do
|
33
|
+
@config[:remote_chef_zero_port] = 8888
|
34
|
+
@config[:chef_zero_port] = 2500
|
35
|
+
assert_equal(8888, ::Knife::Zero::Helper.zero_remote_port)
|
36
|
+
end
|
37
|
+
|
38
|
+
def teardown
|
39
|
+
@config[:remote_chef_zero_port] = nil
|
40
|
+
@config[:chef_zero_port] = nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
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.5.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-
|
11
|
+
date: 2015-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -160,12 +160,16 @@ extra_rdoc_files: []
|
|
160
160
|
files:
|
161
161
|
- ".gitignore"
|
162
162
|
- CHANGELOG.md
|
163
|
+
- Dockerfile
|
163
164
|
- Gemfile
|
164
165
|
- Guardfile
|
165
166
|
- LICENSE.txt
|
166
167
|
- README.md
|
167
168
|
- Rakefile
|
168
169
|
- circle.yml
|
170
|
+
- integration_test/chef-repo/knife.rb
|
171
|
+
- integration_test/chef-repo/run.sh
|
172
|
+
- integration_test/pre/Dockerfile
|
169
173
|
- knife-zero.gemspec
|
170
174
|
- lib/chef/knife/zero_base.rb
|
171
175
|
- lib/chef/knife/zero_bootstrap.rb
|
@@ -179,6 +183,7 @@ files:
|
|
179
183
|
- test/chef/knife/test_zero_bootstrap.rb
|
180
184
|
- test/chef/knife/test_zero_chef_client.rb
|
181
185
|
- test/knife-zero/core/test_bootstrap_context.rb
|
186
|
+
- test/knife-zero/core/test_zerohelper.rb
|
182
187
|
- test/knife-zero/test_bootstrap_ssh.rb
|
183
188
|
- test/knife-zero/test_versioin.rb
|
184
189
|
- test/run_test.rb
|
@@ -202,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
207
|
version: '0'
|
203
208
|
requirements: []
|
204
209
|
rubyforge_project:
|
205
|
-
rubygems_version: 2.
|
210
|
+
rubygems_version: 2.4.6
|
206
211
|
signing_key:
|
207
212
|
specification_version: 4
|
208
213
|
summary: Run chef-client at remote node with chef-zero(local-mode) via HTTP over SSH
|
@@ -211,6 +216,7 @@ test_files:
|
|
211
216
|
- test/chef/knife/test_zero_bootstrap.rb
|
212
217
|
- test/chef/knife/test_zero_chef_client.rb
|
213
218
|
- test/knife-zero/core/test_bootstrap_context.rb
|
219
|
+
- test/knife-zero/core/test_zerohelper.rb
|
214
220
|
- test/knife-zero/test_bootstrap_ssh.rb
|
215
221
|
- test/knife-zero/test_versioin.rb
|
216
222
|
- test/run_test.rb
|