knife 18.5.0 → 18.6.13
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/Gemfile +2 -6
- data/knife.gemspec +6 -3
- data/lib/chef/application/knife.rb +3 -0
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +8 -1
- data/lib/chef/knife/bootstrap.rb +33 -2
- data/lib/chef/knife/core/bootstrap_context.rb +11 -1
- data/lib/chef/knife/core/windows_bootstrap_context.rb +41 -3
- data/lib/chef/knife/license.rb +52 -0
- data/lib/chef/knife/version.rb +1 -1
- data/lib/chef/utils/licensing_config.rb +9 -0
- data/lib/chef/utils/licensing_handler.rb +53 -0
- data/spec/unit/knife/bootstrap_spec.rb +6 -6
- data/spec/unit/knife/license_spec.rb +90 -0
- metadata +47 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e494361153bfaa991e49f354d0c38aa08b7c34fe4168cd26684b04172f4fb8cf
|
|
4
|
+
data.tar.gz: 6dedb2d0c6c50b3d0527eb240006b0daeafedcda9e1de2f036961555ae75ea22
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7ebbe1f402396739175969bf45e3c7008cb331f3baaa6baadf8086586a4890f73faf9a6a09a8edb4461f9e9ed381376fbef560789deaeadb7f67e2dcb187ef57
|
|
7
|
+
data.tar.gz: ba70d328f4f95a93dc291946cab804e09c5507e04099c745a3f6e998a70ee5cd6b94cc141d57fa5d9821008af041a6023e7104bf0131fca15bf16dee96112790
|
data/Gemfile
CHANGED
|
@@ -6,9 +6,8 @@ group(:development, :test) do
|
|
|
6
6
|
gem "cheffish", ">= 14" # testing only , but why didn't this need to explicit in chef?
|
|
7
7
|
gem "webmock"
|
|
8
8
|
gem "crack", "< 0.4.6" # due to https://github.com/jnunemaker/crack/pull/75
|
|
9
|
-
gem "rake"
|
|
9
|
+
gem "rake", ">= 12.3.3"
|
|
10
10
|
gem "rspec"
|
|
11
|
-
gem "chef-bin", path: "../chef-bin"
|
|
12
11
|
end
|
|
13
12
|
|
|
14
13
|
group(:omnibus_package, :pry) do
|
|
@@ -21,7 +20,4 @@ group(:chefstyle) do
|
|
|
21
20
|
gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "main"
|
|
22
21
|
end
|
|
23
22
|
|
|
24
|
-
gem "ohai", git: "https://github.com/chef/ohai.git", branch: "
|
|
25
|
-
gem "chef", path: ".."
|
|
26
|
-
gem "chef-utils", path: File.expand_path("../chef-utils", __dir__) if File.exist?(File.expand_path("../chef-utils", __dir__))
|
|
27
|
-
gem "chef-config", path: File.expand_path("../chef-config", __dir__) if File.exist?(File.expand_path("../chef-config", __dir__))
|
|
23
|
+
gem "ohai", git: "https://github.com/chef/ohai.git", branch: "18-stable"
|
data/knife.gemspec
CHANGED
|
@@ -15,9 +15,10 @@ Gem::Specification.new do |s|
|
|
|
15
15
|
|
|
16
16
|
s.required_ruby_version = ">= 3.1.0"
|
|
17
17
|
|
|
18
|
-
s.add_dependency "chef-config", "
|
|
19
|
-
s.add_dependency "chef-utils", "
|
|
20
|
-
s.add_dependency "chef", "
|
|
18
|
+
s.add_dependency "chef-config", "~> 18.6"
|
|
19
|
+
s.add_dependency "chef-utils", "~> 18.6"
|
|
20
|
+
s.add_dependency "chef", "~> 18.6"
|
|
21
|
+
s.add_dependency "chef-bin", "~> 18.6"
|
|
21
22
|
s.add_dependency "train-core", "~> 3.10" # 3.2.28 fixes sudo prompts. See https://github.com/chef/chef/pull/9635
|
|
22
23
|
s.add_dependency "train-winrm", ">= 0.2.5"
|
|
23
24
|
s.add_dependency "license-acceptance", ">= 1.0.5", "< 3"
|
|
@@ -44,6 +45,8 @@ Gem::Specification.new do |s|
|
|
|
44
45
|
|
|
45
46
|
s.add_dependency "proxifier2", "~> 1.1"
|
|
46
47
|
|
|
48
|
+
s.add_dependency "chef-licensing", "~> 1.0"
|
|
49
|
+
|
|
47
50
|
s.bindir = "bin"
|
|
48
51
|
s.executables = %w{ knife }
|
|
49
52
|
|
|
@@ -19,6 +19,9 @@ require "chef/application"
|
|
|
19
19
|
require_relative "../knife"
|
|
20
20
|
require "mixlib/log"
|
|
21
21
|
require "ohai/config"
|
|
22
|
+
require "chef-licensing"
|
|
23
|
+
require "chef/utils/licensing_handler"
|
|
24
|
+
require "chef/knife/core/ui"
|
|
22
25
|
module Net
|
|
23
26
|
autoload :HTTP, "net/http"
|
|
24
27
|
end
|
|
@@ -171,7 +171,14 @@ do_download() {
|
|
|
171
171
|
<% if @config[:bootstrap_install_command] %>
|
|
172
172
|
<%= @config[:bootstrap_install_command] %>
|
|
173
173
|
<% else %>
|
|
174
|
-
|
|
174
|
+
<% if @config[:bootstrap_url] %>
|
|
175
|
+
install_sh="<%= @config[:bootstrap_url] %>"
|
|
176
|
+
<% elsif license_available? %>
|
|
177
|
+
install_sh="<%= config[:license_url] %>"
|
|
178
|
+
<% else %>
|
|
179
|
+
install_sh="https://omnitruck.chef.io/chef/install.sh"
|
|
180
|
+
<% end %>
|
|
181
|
+
|
|
175
182
|
if test -f /usr/bin/<%= ChefUtils::Dist::Infra::CLIENT %>; then
|
|
176
183
|
echo "-----> Existing <%= ChefUtils::Dist::Infra::PRODUCT %> installation detected"
|
|
177
184
|
else
|
data/lib/chef/knife/bootstrap.rb
CHANGED
|
@@ -21,6 +21,8 @@ require_relative "data_bag_secret_options"
|
|
|
21
21
|
require "chef-utils/dist" unless defined?(ChefUtils::Dist)
|
|
22
22
|
require "license_acceptance/cli_flags/mixlib_cli"
|
|
23
23
|
require "chef/json_compat" unless defined?(Chef::JSONCompat) # can't be lazy loaded since it's used in options
|
|
24
|
+
require "chef/utils/licensing_config"
|
|
25
|
+
require "chef/utils/licensing_handler"
|
|
24
26
|
|
|
25
27
|
module LicenseAcceptance
|
|
26
28
|
autoload :Acceptor, "license_acceptance/acceptor"
|
|
@@ -442,7 +444,7 @@ class Chef
|
|
|
442
444
|
|
|
443
445
|
# Determine if we need to accept the Chef Infra license locally in order to successfully bootstrap
|
|
444
446
|
# the remote node. Remote 'chef-client' run will fail if it is >= 15 and the license is not accepted locally.
|
|
445
|
-
def
|
|
447
|
+
def check_eula_license
|
|
446
448
|
Chef::Log.debug("Checking if we need to accept Chef license to bootstrap node")
|
|
447
449
|
version = config[:bootstrap_version] || Chef::VERSION.split(".").first
|
|
448
450
|
acceptor = LicenseAcceptance::Acceptor.new(logger: Chef::Log, provided: Chef::Config[:chef_license])
|
|
@@ -550,7 +552,8 @@ class Chef
|
|
|
550
552
|
end
|
|
551
553
|
|
|
552
554
|
def run
|
|
553
|
-
|
|
555
|
+
check_eula_license if ChefUtils::Dist::Org::ENFORCE_LICENSE
|
|
556
|
+
fetch_license
|
|
554
557
|
|
|
555
558
|
plugin_setup!
|
|
556
559
|
validate_name_args!
|
|
@@ -572,6 +575,7 @@ class Chef
|
|
|
572
575
|
bootstrap_path = upload_bootstrap(content)
|
|
573
576
|
perform_bootstrap(bootstrap_path)
|
|
574
577
|
plugin_finalize
|
|
578
|
+
warn_license_usage
|
|
575
579
|
ensure
|
|
576
580
|
connection.del_file!(bootstrap_path) if connection && bootstrap_path
|
|
577
581
|
end
|
|
@@ -1188,6 +1192,33 @@ class Chef
|
|
|
1188
1192
|
|
|
1189
1193
|
connection&.connection&.transport_options&.merge! opts
|
|
1190
1194
|
end
|
|
1195
|
+
|
|
1196
|
+
# Fetch the workstation license stored in the system
|
|
1197
|
+
def fetch_license
|
|
1198
|
+
license = Chef::Utils::LicensingHandler.validate!
|
|
1199
|
+
config[:license_url] = license.install_sh_url
|
|
1200
|
+
config[:license_id] = license.license_key
|
|
1201
|
+
config[:license_type] = license.license_type
|
|
1202
|
+
end
|
|
1203
|
+
|
|
1204
|
+
def warn_license_usage
|
|
1205
|
+
return if config[:license_type].present?
|
|
1206
|
+
|
|
1207
|
+
ui.warn(<<~MSG
|
|
1208
|
+
|
|
1209
|
+
+---------------------------------------------------------------------------------------------------------------------+
|
|
1210
|
+
To ensure uninterrupted downloads of Infra Client, Knife Bootstrap will soon require a license key.
|
|
1211
|
+
|
|
1212
|
+
Here's what you need to know:
|
|
1213
|
+
* Adding a License: Use the < knife license > command to easily add a license key.
|
|
1214
|
+
* For Commercial Customers: Obtain your license key from the customer portal.
|
|
1215
|
+
* For Free/Trial Users: Non-commercial users can generate a license key from https://www.chef.io/license-generation-free-trial
|
|
1216
|
+
|
|
1217
|
+
No action is require at this time, but please prepare for this change.
|
|
1218
|
+
+---------------------------------------------------------------------------------------------------------------------+
|
|
1219
|
+
MSG
|
|
1220
|
+
)
|
|
1221
|
+
end
|
|
1191
1222
|
end
|
|
1192
1223
|
end
|
|
1193
1224
|
end
|
|
@@ -203,7 +203,13 @@ class Chef
|
|
|
203
203
|
def version_to_install
|
|
204
204
|
return config[:bootstrap_version] if config[:bootstrap_version]
|
|
205
205
|
|
|
206
|
-
if config[:
|
|
206
|
+
if config[:license_url]
|
|
207
|
+
if config[:channel] == "stable" && config[:license_type] == "commercial"
|
|
208
|
+
Chef::VERSION.split(".").first
|
|
209
|
+
else
|
|
210
|
+
"latest"
|
|
211
|
+
end
|
|
212
|
+
elsif config[:channel] == "stable"
|
|
207
213
|
Chef::VERSION.split(".").first
|
|
208
214
|
else
|
|
209
215
|
"latest"
|
|
@@ -223,6 +229,10 @@ class Chef
|
|
|
223
229
|
end
|
|
224
230
|
end
|
|
225
231
|
|
|
232
|
+
def license_available?
|
|
233
|
+
config[:license_id] && config[:license_type]
|
|
234
|
+
end
|
|
235
|
+
|
|
226
236
|
private
|
|
227
237
|
|
|
228
238
|
# Returns a string for copying the trusted certificates on the workstation to the system being bootstrapped
|
|
@@ -242,6 +242,18 @@ class Chef
|
|
|
242
242
|
objADOStream.SaveToFile path
|
|
243
243
|
objADOStream.Close
|
|
244
244
|
Set objADOStream = Nothing
|
|
245
|
+
ElseIf objXMLHTTP.Status = 400 Then
|
|
246
|
+
errorBody = objXMLHTTP.ResponseText
|
|
247
|
+
WScript.Echo "Error: 400 BadRequest"
|
|
248
|
+
WScript.Echo "Error Body:"
|
|
249
|
+
WScript.Echo errorBody
|
|
250
|
+
Else
|
|
251
|
+
WScript.Echo "An error occurred while downloading the file:"
|
|
252
|
+
errorBody = objXMLHTTP.ResponseText
|
|
253
|
+
WScript.Echo "Status: "
|
|
254
|
+
WScript.Echo objXMLHTTP.Status
|
|
255
|
+
WScript.Echo "Status Text: "
|
|
256
|
+
WScript.Echo errorBody
|
|
245
257
|
End If
|
|
246
258
|
Set objXMLHTTP = Nothing
|
|
247
259
|
End If
|
|
@@ -266,7 +278,28 @@ class Chef
|
|
|
266
278
|
$WebClient.Proxy = $WebProxy
|
|
267
279
|
}
|
|
268
280
|
|
|
269
|
-
|
|
281
|
+
try {
|
|
282
|
+
$webClient.DownloadFile($remoteUrl, $localPath);
|
|
283
|
+
|
|
284
|
+
Write-Host "Download complete. The file has been saved to $localPath."
|
|
285
|
+
} catch [System.Net.WebException] {
|
|
286
|
+
$response = $_.Exception.Response
|
|
287
|
+
|
|
288
|
+
if ($response.StatusCode -eq [System.Net.HttpStatusCode]::BadRequest) {
|
|
289
|
+
$streamReader = New-Object System.IO.StreamReader($response.GetResponseStream())
|
|
290
|
+
$errorBody = $streamReader.ReadToEnd()
|
|
291
|
+
$streamReader.Dispose()
|
|
292
|
+
|
|
293
|
+
Write-Host "Error: 400 BadRequest"
|
|
294
|
+
Write-Host "Error Body:"
|
|
295
|
+
Write-Host $errorBody
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
Write-Host "An error occurred while downloading the file:"
|
|
299
|
+
Write-Host $_.Exception.Message
|
|
300
|
+
}
|
|
301
|
+
Exit 1
|
|
302
|
+
}
|
|
270
303
|
WGET_PS
|
|
271
304
|
|
|
272
305
|
escape_and_echo(win_wget_ps)
|
|
@@ -297,11 +330,16 @@ class Chef
|
|
|
297
330
|
# Build a URL that will redirect to the correct Chef Infra msi download.
|
|
298
331
|
def msi_url(machine_os = nil, machine_arch = nil, download_context = nil)
|
|
299
332
|
if config[:msi_url].nil? || config[:msi_url].empty?
|
|
300
|
-
url =
|
|
333
|
+
url = if config[:license_url]
|
|
334
|
+
format(config[:license_url], config[:channel]) + "/chef/download?p=windows"
|
|
335
|
+
else
|
|
336
|
+
"https://omnitruck.chef.io/chef/download?p=windows"
|
|
337
|
+
end
|
|
301
338
|
url += "&pv=#{machine_os}" unless machine_os.nil?
|
|
302
339
|
url += "&m=#{machine_arch}" unless machine_arch.nil?
|
|
303
340
|
url += "&DownloadContext=#{download_context}" unless download_context.nil?
|
|
304
|
-
url += "&channel=#{config[:channel]}"
|
|
341
|
+
url += "&channel=#{config[:channel]}" if config[:license_url].blank?
|
|
342
|
+
url += "&license_id=#{config[:license_id]}" unless config[:license_id].blank?
|
|
305
343
|
url += "&v=#{version_to_install}"
|
|
306
344
|
else
|
|
307
345
|
config[:msi_url]
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
|
3
|
+
# License:: Apache License, Version 2.0
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
require_relative "../knife"
|
|
19
|
+
|
|
20
|
+
class Chef
|
|
21
|
+
class Knife
|
|
22
|
+
class License < Chef::Knife
|
|
23
|
+
category "license"
|
|
24
|
+
banner <<~BANNER
|
|
25
|
+
knife license [--chef-license-key <LICENSE_KEY>]
|
|
26
|
+
knife license list
|
|
27
|
+
knife license add [--chef-license-key <LICENSE_KEY>]
|
|
28
|
+
BANNER
|
|
29
|
+
|
|
30
|
+
deps do
|
|
31
|
+
require "chef/utils/licensing_handler" unless defined?(ChefLicensing)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
option :chef_license_key,
|
|
35
|
+
long: "--chef-license-key <KEY>",
|
|
36
|
+
description: "Free/Trial/Commercial License key to activate the Chef product"
|
|
37
|
+
|
|
38
|
+
def run
|
|
39
|
+
case ARGV[1]
|
|
40
|
+
when "list"
|
|
41
|
+
ChefLicensing.list_license_keys_info
|
|
42
|
+
when "add"
|
|
43
|
+
ChefLicensing.add_license
|
|
44
|
+
else
|
|
45
|
+
ChefLicensing.fetch_and_persist.each do |key|
|
|
46
|
+
ui.msg("License_key: #{key}")
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
data/lib/chef/knife/version.rb
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require "chef-licensing"
|
|
2
|
+
|
|
3
|
+
ChefLicensing.configure do |config|
|
|
4
|
+
config.chef_product_name = "Knife"
|
|
5
|
+
config.chef_entitlement_id = "x6f3bc76-a94f-4b6c-bc97-4b7ed2b045c0"
|
|
6
|
+
config.chef_executable_name = "knife"
|
|
7
|
+
config.license_server_url = "https://services.chef.io/licensing"
|
|
8
|
+
end
|
|
9
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require_relative "licensing_config"
|
|
2
|
+
|
|
3
|
+
class Chef
|
|
4
|
+
class Utils
|
|
5
|
+
class LicensingHandler
|
|
6
|
+
LEGACY_OMNITRUCK_URL = "https://omnitruck.chef.io".freeze
|
|
7
|
+
|
|
8
|
+
OMNITRUCK_URLS = {
|
|
9
|
+
"free" => "https://chefdownload-trial.chef.io",
|
|
10
|
+
"trial" => "https://chefdownload-trial.chef.io",
|
|
11
|
+
"commercial" => "https://chefdownload-commerical.chef.io",
|
|
12
|
+
}.freeze
|
|
13
|
+
|
|
14
|
+
attr_reader :license_key, :license_type
|
|
15
|
+
|
|
16
|
+
def initialize(key, type)
|
|
17
|
+
@license_key = key
|
|
18
|
+
@license_type = type
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def omnitruck_url
|
|
22
|
+
url = OMNITRUCK_URLS[license_type] || LEGACY_OMNITRUCK_URL
|
|
23
|
+
|
|
24
|
+
"#{url}/%s#{license_key ? "?license_id=#{license_key}" : ""}"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def install_sh_url
|
|
28
|
+
format(omnitruck_url, "install.sh")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
class << self
|
|
32
|
+
def validate!
|
|
33
|
+
license_keys = begin
|
|
34
|
+
ChefLicensing::LicenseKeyFetcher.fetch
|
|
35
|
+
# If the env is airgapped or the local licensing service is unreachable,
|
|
36
|
+
# the licensing gem will raise ChefLicensing::RestfulClientConnectionError.
|
|
37
|
+
# In such cases, we are assuming the license is not available.
|
|
38
|
+
rescue ChefLicensing::RestfulClientConnectionError
|
|
39
|
+
[]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
return new(nil, nil) if license_keys&.empty?
|
|
43
|
+
|
|
44
|
+
licenses_metadata = ChefLicensing::Api::Describe.list({
|
|
45
|
+
license_keys: license_keys,
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
new(licenses_metadata.last.id, licenses_metadata.last.license_type)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -50,7 +50,7 @@ describe Chef::Knife::Bootstrap do
|
|
|
50
50
|
k
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
context "#
|
|
53
|
+
context "#check_eula_license" do
|
|
54
54
|
let(:acceptor) { instance_double(LicenseAcceptance::Acceptor) }
|
|
55
55
|
|
|
56
56
|
before do
|
|
@@ -60,7 +60,7 @@ describe Chef::Knife::Bootstrap do
|
|
|
60
60
|
describe "when a license is not required" do
|
|
61
61
|
it "does not set the chef_license" do
|
|
62
62
|
expect(acceptor).to receive(:license_required?).and_return(false)
|
|
63
|
-
knife.
|
|
63
|
+
knife.check_eula_license
|
|
64
64
|
expect(Chef::Config[:chef_license]).to eq(nil)
|
|
65
65
|
end
|
|
66
66
|
end
|
|
@@ -71,7 +71,7 @@ describe Chef::Knife::Bootstrap do
|
|
|
71
71
|
expect(acceptor).to receive(:id_from_mixlib).and_return("id")
|
|
72
72
|
expect(acceptor).to receive(:check_and_persist)
|
|
73
73
|
expect(acceptor).to receive(:acceptance_value).and_return("accept-no-persist")
|
|
74
|
-
knife.
|
|
74
|
+
knife.check_eula_license
|
|
75
75
|
expect(Chef::Config[:chef_license]).to eq("accept-no-persist")
|
|
76
76
|
end
|
|
77
77
|
end
|
|
@@ -347,7 +347,7 @@ describe Chef::Knife::Bootstrap do
|
|
|
347
347
|
knife.parse_options(["--json-attribute-file", jsonfile.path])
|
|
348
348
|
knife.merge_configs
|
|
349
349
|
allow(knife).to receive(:validate_name_args!)
|
|
350
|
-
expect(knife).to receive(:
|
|
350
|
+
expect(knife).to receive(:check_eula_license)
|
|
351
351
|
|
|
352
352
|
expect { knife.run }.to raise_error(Chef::Exceptions::BootstrapCommandInputError)
|
|
353
353
|
jsonfile.close
|
|
@@ -1686,7 +1686,7 @@ describe Chef::Knife::Bootstrap do
|
|
|
1686
1686
|
end
|
|
1687
1687
|
describe "#run" do
|
|
1688
1688
|
it "performs the steps we expect to run a bootstrap" do
|
|
1689
|
-
expect(knife).to receive(:
|
|
1689
|
+
expect(knife).to receive(:check_eula_license)
|
|
1690
1690
|
expect(knife).to receive(:validate_name_args!).ordered
|
|
1691
1691
|
expect(knife).to receive(:validate_protocol!).ordered
|
|
1692
1692
|
expect(knife).to receive(:validate_first_boot_attributes!).ordered
|
|
@@ -1956,7 +1956,7 @@ describe Chef::Knife::Bootstrap do
|
|
|
1956
1956
|
|
|
1957
1957
|
it "verifies that a server to bootstrap was given as a command line arg" do
|
|
1958
1958
|
knife.name_args = nil
|
|
1959
|
-
expect(knife).to receive(:
|
|
1959
|
+
expect(knife).to receive(:check_eula_license)
|
|
1960
1960
|
expect { knife.run }.to raise_error(SystemExit)
|
|
1961
1961
|
expect(stderr.string).to match(/ERROR:.+FQDN or ip/)
|
|
1962
1962
|
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
|
3
|
+
# License:: Apache License, Version 2.0
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
require "knife_spec_helper"
|
|
19
|
+
require "chef-licensing"
|
|
20
|
+
|
|
21
|
+
describe Chef::Knife::License do
|
|
22
|
+
include SpecHelpers::Knife
|
|
23
|
+
|
|
24
|
+
let(:knife) { described_class.new }
|
|
25
|
+
|
|
26
|
+
context "arguments" do
|
|
27
|
+
it "should have the chef-license-key as an option" do
|
|
28
|
+
expect(knife.options).to include(:chef_license_key)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context "license command" do
|
|
33
|
+
it "should invoke the fetch and persist" do
|
|
34
|
+
expect(ChefLicensing).to receive(:fetch_and_persist).and_return([])
|
|
35
|
+
|
|
36
|
+
knife.run
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should print the key returned from the chef-licensing" do
|
|
40
|
+
allow(ChefLicensing).to receive(:fetch_and_persist).and_return(["key-123"])
|
|
41
|
+
|
|
42
|
+
expect(knife.run).to eq(["key-123"])
|
|
43
|
+
expect(knife.ui).to receive(:msg).and_return("License Key: key-123")
|
|
44
|
+
knife.run
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should fail if no license provided" do
|
|
48
|
+
allow(STDOUT).to receive(:isatty).and_return(false)
|
|
49
|
+
ChefLicensing.configure do |c|
|
|
50
|
+
c.output = STDOUT
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
expect { knife.run }.to raise_error(ChefLicensing::LicenseKeyFetcher::LicenseKeyNotFetchedError, "Unable to obtain a License Key.")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
context "license list command" do
|
|
58
|
+
before do
|
|
59
|
+
allow(STDOUT).to receive(:isatty).and_return(false)
|
|
60
|
+
ChefLicensing.configure do |c|
|
|
61
|
+
c.output = STDOUT
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "should invoke list command method" do
|
|
66
|
+
with_argv(%w{license list}) do
|
|
67
|
+
expect(ChefLicensing).to receive(:list_license_keys_info).and_return(["key-123"])
|
|
68
|
+
|
|
69
|
+
knife.run
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
context "license add command" do
|
|
75
|
+
before do
|
|
76
|
+
allow(STDOUT).to receive(:isatty).and_return(false)
|
|
77
|
+
ChefLicensing.configure do |c|
|
|
78
|
+
c.output = STDOUT
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "should invoke license add method" do
|
|
83
|
+
with_argv(%w{license add --chef-license-key key-123}) do
|
|
84
|
+
expect(ChefLicensing).to receive(:add_license).and_return(true)
|
|
85
|
+
|
|
86
|
+
knife.run
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
metadata
CHANGED
|
@@ -1,57 +1,70 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: knife
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 18.
|
|
4
|
+
version: 18.6.13
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adam Jacob
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 2025-01-29 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: chef-config
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
|
-
- - "
|
|
16
|
+
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '18'
|
|
18
|
+
version: '18.6'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
|
-
- - "
|
|
23
|
+
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '18'
|
|
25
|
+
version: '18.6'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
27
|
name: chef-utils
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
|
-
- - "
|
|
30
|
+
- - "~>"
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '18'
|
|
32
|
+
version: '18.6'
|
|
34
33
|
type: :runtime
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
|
-
- - "
|
|
37
|
+
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '18'
|
|
39
|
+
version: '18.6'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
41
|
name: chef
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
44
43
|
requirements:
|
|
45
|
-
- - "
|
|
44
|
+
- - "~>"
|
|
46
45
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '18'
|
|
46
|
+
version: '18.6'
|
|
48
47
|
type: :runtime
|
|
49
48
|
prerelease: false
|
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
50
|
requirements:
|
|
52
|
-
- - "
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '18.6'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: chef-bin
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
53
59
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '18'
|
|
60
|
+
version: '18.6'
|
|
61
|
+
type: :runtime
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '18.6'
|
|
55
68
|
- !ruby/object:Gem::Dependency
|
|
56
69
|
name: train-core
|
|
57
70
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -368,6 +381,20 @@ dependencies:
|
|
|
368
381
|
- - "~>"
|
|
369
382
|
- !ruby/object:Gem::Version
|
|
370
383
|
version: '1.1'
|
|
384
|
+
- !ruby/object:Gem::Dependency
|
|
385
|
+
name: chef-licensing
|
|
386
|
+
requirement: !ruby/object:Gem::Requirement
|
|
387
|
+
requirements:
|
|
388
|
+
- - "~>"
|
|
389
|
+
- !ruby/object:Gem::Version
|
|
390
|
+
version: '1.0'
|
|
391
|
+
type: :runtime
|
|
392
|
+
prerelease: false
|
|
393
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
394
|
+
requirements:
|
|
395
|
+
- - "~>"
|
|
396
|
+
- !ruby/object:Gem::Version
|
|
397
|
+
version: '1.0'
|
|
371
398
|
description: The knife CLI for Chef Infra.
|
|
372
399
|
email: adam@chef.io
|
|
373
400
|
executables:
|
|
@@ -475,6 +502,7 @@ files:
|
|
|
475
502
|
- lib/chef/knife/key_list.rb
|
|
476
503
|
- lib/chef/knife/key_list_base.rb
|
|
477
504
|
- lib/chef/knife/key_show.rb
|
|
505
|
+
- lib/chef/knife/license.rb
|
|
478
506
|
- lib/chef/knife/list.rb
|
|
479
507
|
- lib/chef/knife/node_bulk_delete.rb
|
|
480
508
|
- lib/chef/knife/node_create.rb
|
|
@@ -553,6 +581,8 @@ files:
|
|
|
553
581
|
- lib/chef/knife/version.rb
|
|
554
582
|
- lib/chef/knife/xargs.rb
|
|
555
583
|
- lib/chef/knife/yaml_convert.rb
|
|
584
|
+
- lib/chef/utils/licensing_config.rb
|
|
585
|
+
- lib/chef/utils/licensing_handler.rb
|
|
556
586
|
- spec/data/apt/chef-integration-test-1.0/debian/changelog
|
|
557
587
|
- spec/data/apt/chef-integration-test-1.0/debian/compat
|
|
558
588
|
- spec/data/apt/chef-integration-test-1.0/debian/control
|
|
@@ -1063,6 +1093,7 @@ files:
|
|
|
1063
1093
|
- spec/unit/knife/key_helper.rb
|
|
1064
1094
|
- spec/unit/knife/key_list_spec.rb
|
|
1065
1095
|
- spec/unit/knife/key_show_spec.rb
|
|
1096
|
+
- spec/unit/knife/license_spec.rb
|
|
1066
1097
|
- spec/unit/knife/node_bulk_delete_spec.rb
|
|
1067
1098
|
- spec/unit/knife/node_delete_spec.rb
|
|
1068
1099
|
- spec/unit/knife/node_edit_spec.rb
|
|
@@ -1130,7 +1161,6 @@ metadata:
|
|
|
1130
1161
|
homepage_uri: https://www.chef.io
|
|
1131
1162
|
mailing_list_uri: https://discourse.chef.io/
|
|
1132
1163
|
source_code_uri: https://github.com/chef/chef/
|
|
1133
|
-
post_install_message:
|
|
1134
1164
|
rdoc_options: []
|
|
1135
1165
|
require_paths:
|
|
1136
1166
|
- lib
|
|
@@ -1145,8 +1175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
1145
1175
|
- !ruby/object:Gem::Version
|
|
1146
1176
|
version: '0'
|
|
1147
1177
|
requirements: []
|
|
1148
|
-
rubygems_version: 3.3
|
|
1149
|
-
signing_key:
|
|
1178
|
+
rubygems_version: 3.6.3
|
|
1150
1179
|
specification_version: 4
|
|
1151
1180
|
summary: The knife CLI for Chef Infra.
|
|
1152
1181
|
test_files: []
|