knife-zero 1.5.1 → 1.6.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 +6 -0
- data/README.md +12 -10
- data/lib/chef/knife/zero_base.rb +0 -51
- data/lib/chef/knife/zero_bootstrap.rb +4 -117
- data/lib/chef/knife/zero_chef_client.rb +4 -13
- data/lib/chef/knife/zero_converge.rb +15 -0
- data/lib/knife-zero/version.rb +1 -1
- data/test/chef/knife/test_zero_bootstrap.rb +2 -2
- data/test/knife-zero/test_bootstrap_ssh.rb +0 -10
- data/test/knife-zero/test_versioin.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4383c976a2e1f917aaec4d23f7684e13bc72fb2
|
4
|
+
data.tar.gz: 43698c8ac6150af68f0744215d8a66fbcd54d8da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eacd35b62835fd3879179b19060f1d8682962c08fddd84e3a0f80b9d01164298c58f62ee1bb1818c0351f775c4c3ab586d32d239125b68b1e850f4e4496ef29d
|
7
|
+
data.tar.gz: bf56cd573120019588155d0302139cc990fca572707702809087d41db75daa460d9ed86208a9dccd473359c23131a360cc459c6447c61a30e0bd600ee50b998a
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## v1.6.0
|
6
|
+
|
7
|
+
- Feature: #32 create alias converge to chef_client, and recommended it by README.
|
8
|
+
- Refactor: almostoptions are derived from core.
|
9
|
+
- PR #38 HT: @patcon
|
10
|
+
|
5
11
|
## v1.5.1
|
6
12
|
|
7
13
|
- Bug: `--ssh-user` arg doesn't override `knife[:ssh_user]`.
|
data/README.md
CHANGED
@@ -47,7 +47,8 @@ $ chef gem install knife-zero
|
|
47
47
|
```
|
48
48
|
** ZERO COMMANDS **
|
49
49
|
knife zero bootstrap FQDN (options)
|
50
|
-
knife zero chef_client QUERY (options)
|
50
|
+
knife zero chef_client QUERY (options) | It's same as converge
|
51
|
+
knife zero converge QUERY (options)
|
51
52
|
knife zero diagnose # show configuration from file
|
52
53
|
```
|
53
54
|
|
@@ -121,11 +122,12 @@ $ parallel -j 5 ./bin/knife zero bootstrap ::: nodeA nodeB nodeC...
|
|
121
122
|
```
|
122
123
|
|
123
124
|
|
124
|
-
### knife zero chef_client (for update)
|
125
|
+
### knife zero converge/chef_client (for update)
|
125
126
|
|
126
|
-
`knife zero
|
127
|
+
`knife zero converge QUERY (options)`
|
128
|
+
`knife zero chef_client QUERY (options) | It's same as converge`
|
127
129
|
|
128
|
-
Search nodes from local chef-repo directory, and run
|
130
|
+
Search nodes from local chef-repo directory, and run chef-client at remote node.
|
129
131
|
|
130
132
|
Supported options are mostly the same as `knife ssh`.
|
131
133
|
And it supports below.
|
@@ -147,7 +149,7 @@ host.example.com:
|
|
147
149
|
run_list: recipe[hogehoge::default]
|
148
150
|
|
149
151
|
|
150
|
-
$ knife zero
|
152
|
+
$ knife zero converge 'name:*' --attribute ipaddress
|
151
153
|
|
152
154
|
## host.example.com was converged by run_list.
|
153
155
|
host.example.com Starting Chef Client, version 11.14.6
|
@@ -249,14 +251,14 @@ Connecting to 192.168.33.10
|
|
249
251
|
...
|
250
252
|
```
|
251
253
|
|
252
|
-
Run zero
|
254
|
+
Run zero converge with `-a name` option.
|
253
255
|
|
254
256
|
> Caution: `-a(--attribute) name` option doesn't work since chef 12.1.0.
|
255
257
|
> Please use specific attribute until fix it.
|
256
258
|
> I've already create PR for fix. Please wait for merge to use name attribute. https://github.com/chef/chef/pull/3195
|
257
259
|
|
258
260
|
```
|
259
|
-
$ knife zero
|
261
|
+
$ knife zero converge "name:*" -x vagrant -i ./.vagrant/machines/default/virtualbox/private_key --sudo -a name
|
260
262
|
WARN: No cookbooks directory found at or above current directory. Assuming /Users/sawanoboriyu/worktemp/knife-zero-vagrant.
|
261
263
|
192.168.33.10 Starting Chef Client, version 12.0.3
|
262
264
|
192.168.33.10 resolving cookbooks for run list: []
|
@@ -320,10 +322,10 @@ $ knife node edit vagrant.vm
|
|
320
322
|
}
|
321
323
|
```
|
322
324
|
|
323
|
-
Run zero
|
325
|
+
Run zero converge with `-a chef_ip` option.
|
324
326
|
|
325
327
|
```
|
326
|
-
$ ./bin/knife zero
|
328
|
+
$ ./bin/knife zero converge "name:vagrant.vm" -x vagrant -i ./.vagrant/machines/default/virtualbox/private_key --sudo -a chef_ip
|
327
329
|
|
328
330
|
192.168.33.10 Starting Chef Client, version 12.0.3
|
329
331
|
192.168.33.10 resolving cookbooks for run list: []
|
@@ -342,7 +344,7 @@ $ ./bin/knife zero chef_client "name:vagrant.vm" -x vagrant -i ./.vagrant/machin
|
|
342
344
|
For example, you can use ipv4 of eth1(or others) like below.
|
343
345
|
|
344
346
|
```
|
345
|
-
$ knife zero
|
347
|
+
$ knife zero converge "name:*" -x vagrant -i ./.vagrant/machines/default/virtualbox/private_key --sudo -a network.interfaces.eth1.addresses.keys.rotate.first
|
346
348
|
|
347
349
|
192.168.33.10 Starting Chef Client, version 12.0.3
|
348
350
|
192.168.33.10 resolving cookbooks for run list: []
|
data/lib/chef/knife/zero_base.rb
CHANGED
@@ -11,57 +11,6 @@ class Chef
|
|
11
11
|
Chef::Knife::Ssh.load_deps
|
12
12
|
end
|
13
13
|
|
14
|
-
## Just ported from chef
|
15
|
-
option :ssh_user,
|
16
|
-
:short => "-x USERNAME",
|
17
|
-
:long => "--ssh-user USERNAME",
|
18
|
-
:description => "The ssh username",
|
19
|
-
:default => "root"
|
20
|
-
|
21
|
-
option :ssh_password,
|
22
|
-
:short => "-P PASSWORD",
|
23
|
-
:long => "--ssh-password PASSWORD",
|
24
|
-
:description => "The ssh password"
|
25
|
-
|
26
|
-
option :identity_file,
|
27
|
-
:short => "-i IDENTITY_FILE",
|
28
|
-
:long => "--identity-file IDENTITY_FILE",
|
29
|
-
:description => "The SSH identity file used for authentication"
|
30
|
-
|
31
|
-
option :ssh_port,
|
32
|
-
:short => "-p PORT",
|
33
|
-
:long => "--ssh-port PORT",
|
34
|
-
:description => "The ssh port",
|
35
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key }
|
36
|
-
|
37
|
-
option :ssh_gateway,
|
38
|
-
:short => "-G GATEWAY",
|
39
|
-
:long => "--ssh-gateway GATEWAY",
|
40
|
-
:description => "The ssh gateway",
|
41
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:ssh_gateway] = key }
|
42
|
-
|
43
|
-
option :forward_agent,
|
44
|
-
:short => "-A",
|
45
|
-
:long => "--forward-agent",
|
46
|
-
:description => "Enable SSH agent forwarding",
|
47
|
-
:boolean => true
|
48
|
-
|
49
|
-
option :host_key_verify,
|
50
|
-
:long => "--[no-]host-key-verify",
|
51
|
-
:description => "Verify host key, enabled by default.",
|
52
|
-
:boolean => true,
|
53
|
-
:default => true
|
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
14
|
## Added by Knife-Zero
|
66
15
|
option :why_run,
|
67
16
|
:short => '-W',
|
@@ -14,123 +14,10 @@ class Chef
|
|
14
14
|
|
15
15
|
banner "knife zero bootstrap FQDN (options)"
|
16
16
|
|
17
|
-
##
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
:description => "The Chef node name for your new node"
|
22
|
-
|
23
|
-
option :prerelease,
|
24
|
-
:long => "--prerelease",
|
25
|
-
:description => "Install the pre-release chef gems"
|
26
|
-
|
27
|
-
option :bootstrap_version,
|
28
|
-
:long => "--bootstrap-version VERSION",
|
29
|
-
:description => "The version of Chef to install",
|
30
|
-
:proc => lambda { |v| Chef::Config[:knife][:bootstrap_version] = v }
|
31
|
-
|
32
|
-
option :bootstrap_proxy,
|
33
|
-
:long => "--bootstrap-proxy PROXY_URL",
|
34
|
-
:description => "The proxy server for the node being bootstrapped",
|
35
|
-
:proc => Proc.new { |p| Chef::Config[:knife][:bootstrap_proxy] = p }
|
36
|
-
|
37
|
-
option :bootstrap_no_proxy,
|
38
|
-
:long => "--bootstrap-no-proxy [NO_PROXY_URL|NO_PROXY_IP]",
|
39
|
-
:description => "Do not proxy locations for the node being bootstrapped; this option is used internally by Opscode",
|
40
|
-
:proc => Proc.new { |np| Chef::Config[:knife][:bootstrap_no_proxy] = np }
|
41
|
-
|
42
|
-
# DEPR: Remove this option in Chef 13
|
43
|
-
option :distro,
|
44
|
-
:short => "-d DISTRO",
|
45
|
-
:long => "--distro DISTRO",
|
46
|
-
:description => "Bootstrap a distro using a template",
|
47
|
-
:default => "chef-full"
|
48
|
-
|
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."
|
53
|
-
|
54
|
-
# DEPR: Remove this option in Chef 13
|
55
|
-
option :template_file,
|
56
|
-
:long => "--template-file TEMPLATE",
|
57
|
-
:description => "Full path to location of template to use",
|
58
|
-
:default => false
|
59
|
-
|
60
|
-
option :run_list,
|
61
|
-
:short => "-r RUN_LIST",
|
62
|
-
:long => "--run-list RUN_LIST",
|
63
|
-
:description => "Comma separated list of roles/recipes to apply",
|
64
|
-
:proc => lambda { |o| o.split(/[\s,]+/) },
|
65
|
-
:default => []
|
66
|
-
|
67
|
-
option :first_boot_attributes,
|
68
|
-
:short => "-j JSON_ATTRIBS",
|
69
|
-
:long => "--json-attributes",
|
70
|
-
:description => "A JSON string to be added to the first run of chef-client",
|
71
|
-
:proc => lambda { |o| Chef::JSONCompat.parse(o) },
|
72
|
-
:default => {}
|
73
|
-
|
74
|
-
option :hint,
|
75
|
-
:long => "--hint HINT_NAME[=HINT_FILE]",
|
76
|
-
:description => "Specify Ohai Hint to be set on the bootstrap target. Use multiple --hint options to specify multiple hints.",
|
77
|
-
:proc => Proc.new { |h|
|
78
|
-
Chef::Config[:knife][:hints] ||= Hash.new
|
79
|
-
name, path = h.split("=")
|
80
|
-
Chef::Config[:knife][:hints][name] = path ? Chef::JSONCompat.parse(::File.read(path)) : Hash.new }
|
81
|
-
|
82
|
-
option :secret,
|
83
|
-
:short => "-s SECRET",
|
84
|
-
:long => "--secret ",
|
85
|
-
:description => "The secret key to use to encrypt data bag item values",
|
86
|
-
:proc => Proc.new { |s| Chef::Config[:knife][:secret] = s }
|
87
|
-
|
88
|
-
option :secret_file,
|
89
|
-
:long => "--secret-file SECRET_FILE",
|
90
|
-
:description => "A file containing the secret key to use to encrypt data bag item values",
|
91
|
-
:proc => Proc.new { |sf| Chef::Config[:knife][:secret_file] = sf }
|
92
|
-
|
93
|
-
option :bootstrap_url,
|
94
|
-
:long => "--bootstrap-url URL",
|
95
|
-
:description => "URL to a custom installation script",
|
96
|
-
:proc => Proc.new { |u| Chef::Config[:knife][:bootstrap_url] = u }
|
97
|
-
|
98
|
-
option :bootstrap_install_command,
|
99
|
-
:long => "--bootstrap-install-command COMMANDS",
|
100
|
-
:description => "Custom command to install chef-client",
|
101
|
-
:proc => Proc.new { |ic| Chef::Config[:knife][:bootstrap_install_command] = ic }
|
102
|
-
|
103
|
-
option :bootstrap_wget_options,
|
104
|
-
:long => "--bootstrap-wget-options OPTIONS",
|
105
|
-
:description => "Add options to wget when installing chef-client",
|
106
|
-
:proc => Proc.new { |wo| Chef::Config[:knife][:bootstrap_wget_options] = wo }
|
107
|
-
|
108
|
-
option :bootstrap_curl_options,
|
109
|
-
:long => "--bootstrap-curl-options OPTIONS",
|
110
|
-
:description => "Add options to curl when install chef-client",
|
111
|
-
:proc => Proc.new { |co| Chef::Config[:knife][:bootstrap_curl_options] = co }
|
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
|
-
|
17
|
+
## Import from knife bootstrap except exclusions
|
18
|
+
self.options = Bootstrap.options.merge(self.options)
|
19
|
+
self.options.delete :node_ssl_verify_mode
|
20
|
+
self.options.delete :node_verify_api_cert
|
134
21
|
|
135
22
|
def knife_ssh
|
136
23
|
begin
|
@@ -12,20 +12,11 @@ class Chef
|
|
12
12
|
require "knife-zero/helper"
|
13
13
|
end
|
14
14
|
|
15
|
-
banner "knife zero chef_client QUERY (options)"
|
15
|
+
banner "knife zero chef_client QUERY (options) | It's same as converge"
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
:description => "The number of concurrent connections",
|
21
|
-
:default => nil,
|
22
|
-
:proc => lambda { |o| o.to_i }
|
23
|
-
|
24
|
-
option :attribute,
|
25
|
-
:short => "-a ATTR",
|
26
|
-
:long => "--attribute ATTR",
|
27
|
-
:description => "The attribute to use for opening the connection - default depends on the context",
|
28
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:ssh_attribute] = key.strip }
|
17
|
+
self.options = Ssh.options.merge(self.options)
|
18
|
+
self.options[:use_sudo] = Bootstrap.options[:use_sudo]
|
19
|
+
self.options[:use_sudo_password] = Bootstrap.options[:use_sudo_password]
|
29
20
|
|
30
21
|
option :override_runlist,
|
31
22
|
:short => "-o RunlistItem,RunlistItem...",
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'chef/knife'
|
2
|
+
require 'chef/knife/zero_chef_client'
|
3
|
+
|
4
|
+
class Chef
|
5
|
+
class Knife
|
6
|
+
class ZeroConverge < Chef::Knife::ZeroChefClient
|
7
|
+
deps do
|
8
|
+
Chef::Knife::ZeroChefClient.load_deps
|
9
|
+
end
|
10
|
+
|
11
|
+
banner "knife zero converge QUERY (options)"
|
12
|
+
self.options = ZeroChefClient.options
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/knife-zero/version.rb
CHANGED
@@ -13,8 +13,8 @@ class TC_ZeroBootstrap < Test::Unit::TestCase
|
|
13
13
|
assert_true(Chef::Config[:knife_zero])
|
14
14
|
end
|
15
15
|
|
16
|
-
test "returns
|
17
|
-
assert_equal("chef-full", @app.
|
16
|
+
test "returns expected bootstrap template(for notice changes of core to me)" do
|
17
|
+
assert_equal("chef-full", @app.default_bootstrap_template)
|
18
18
|
end
|
19
19
|
|
20
20
|
test "returns BootstrapSsh via knife_ssh" do
|
@@ -5,14 +5,4 @@ class TC_BootstrapSsh < Test::Unit::TestCase
|
|
5
5
|
@app = Chef::Knife::BootstrapSsh.new
|
6
6
|
@app.merge_configs
|
7
7
|
end
|
8
|
-
|
9
|
-
test "RR" do
|
10
|
-
assert_rr do
|
11
|
-
subject = Hash.new
|
12
|
-
mock(subject).to_json("hoge") {
|
13
|
-
"mogemoge"
|
14
|
-
}
|
15
|
-
assert_equal("mogemoge", subject.to_json("hoge"))
|
16
|
-
end
|
17
|
-
end
|
18
8
|
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: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sawanoboly
|
@@ -174,6 +174,7 @@ files:
|
|
174
174
|
- lib/chef/knife/zero_base.rb
|
175
175
|
- lib/chef/knife/zero_bootstrap.rb
|
176
176
|
- lib/chef/knife/zero_chef_client.rb
|
177
|
+
- lib/chef/knife/zero_converge.rb
|
177
178
|
- lib/chef/knife/zero_diagnose.rb
|
178
179
|
- lib/knife-zero/bootstrap_ssh.rb
|
179
180
|
- lib/knife-zero/core/bootstrap_context.rb
|