knife-azure 2.0.13 → 3.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/azure/azure_interface.rb +1 -1
- data/lib/azure/custom_errors.rb +1 -1
- data/lib/azure/helpers.rb +1 -1
- data/lib/azure/resource_management/ARM_deployment_template.rb +1 -1
- data/lib/azure/resource_management/ARM_interface.rb +7 -9
- data/lib/azure/resource_management/vnet_config.rb +2 -2
- data/lib/azure/resource_management/windows_credentials.rb +6 -7
- data/lib/azure/service_management/ASM_interface.rb +1 -1
- data/lib/azure/service_management/ag.rb +1 -1
- data/lib/azure/service_management/certificate.rb +4 -4
- data/lib/azure/service_management/connection.rb +1 -1
- data/lib/azure/service_management/deploy.rb +1 -1
- data/lib/azure/service_management/disk.rb +1 -1
- data/lib/azure/service_management/host.rb +1 -1
- data/lib/azure/service_management/image.rb +1 -1
- data/lib/azure/service_management/loadbalancer.rb +1 -1
- data/lib/azure/service_management/rest.rb +5 -4
- data/lib/azure/service_management/role.rb +2 -2
- data/lib/azure/service_management/storageaccount.rb +1 -1
- data/lib/azure/service_management/utility.rb +1 -1
- data/lib/azure/service_management/vnet.rb +1 -1
- data/lib/chef/knife/azure_ag_create.rb +4 -4
- data/lib/chef/knife/azure_ag_list.rb +1 -1
- data/lib/chef/knife/azure_image_list.rb +3 -3
- data/lib/chef/knife/azure_internal-lb_create.rb +5 -5
- data/lib/chef/knife/azure_internal-lb_list.rb +1 -1
- data/lib/chef/knife/azure_server_create.rb +71 -71
- data/lib/chef/knife/azure_server_delete.rb +7 -7
- data/lib/chef/knife/azure_server_list.rb +1 -1
- data/lib/chef/knife/azure_server_show.rb +1 -1
- data/lib/chef/knife/azure_vnet_create.rb +5 -5
- data/lib/chef/knife/azure_vnet_list.rb +1 -1
- data/lib/chef/knife/azurerm_server_create.rb +45 -45
- data/lib/chef/knife/azurerm_server_delete.rb +8 -8
- data/lib/chef/knife/azurerm_server_list.rb +3 -3
- data/lib/chef/knife/azurerm_server_show.rb +3 -3
- data/lib/chef/knife/bootstrap/bootstrapper.rb +29 -35
- data/lib/chef/knife/bootstrap/common_bootstrap_options.rb +3 -5
- data/lib/chef/knife/bootstrap_azure.rb +15 -15
- data/lib/chef/knife/bootstrap_azurerm.rb +7 -7
- data/lib/chef/knife/helpers/azure_base.rb +54 -65
- data/lib/chef/knife/helpers/azurerm_base.rb +46 -57
- data/lib/knife-azure/version.rb +2 -2
- metadata +13 -13
@@ -2,7 +2,7 @@
|
|
2
2
|
# Author:: Barry Davis (barryd@jetstreamsoftware.com)
|
3
3
|
# Author:: Adam Jacob (<adam@chef.io>)
|
4
4
|
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
5
|
-
# Copyright:: Copyright
|
5
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
6
6
|
# License:: Apache License, Version 2.0
|
7
7
|
#
|
8
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -94,7 +94,7 @@ class Chef
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def validate_disk_and_storage
|
97
|
-
if
|
97
|
+
if config[:preserve_azure_os_disk] && config[:delete_azure_storage_account]
|
98
98
|
ui.warn("Cannot delete storage account while keeping OS Disk. Please set any one option.")
|
99
99
|
exit
|
100
100
|
else
|
@@ -107,11 +107,11 @@ class Chef
|
|
107
107
|
validate_disk_and_storage
|
108
108
|
@name_args.each do |name|
|
109
109
|
begin
|
110
|
-
service.delete_server( { name: name, preserve_azure_os_disk:
|
111
|
-
preserve_azure_vhd:
|
112
|
-
preserve_azure_dns_name:
|
113
|
-
delete_azure_storage_account:
|
114
|
-
wait:
|
110
|
+
service.delete_server( { name: name, preserve_azure_os_disk: config[:preserve_azure_os_disk],
|
111
|
+
preserve_azure_vhd: config[:preserve_azure_vhd],
|
112
|
+
preserve_azure_dns_name: config[:preserve_azure_dns_name],
|
113
|
+
delete_azure_storage_account: config[:delete_azure_storage_account],
|
114
|
+
wait: config[:wait] } )
|
115
115
|
|
116
116
|
if config[:purge]
|
117
117
|
node_to_delete = config[:chef_node_name] || name
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# Author:: Barry Davis (barryd@jetstreamsoftware.com)
|
3
3
|
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
4
4
|
# Author:: Adam Jacob (<adam@chef.io>)
|
5
|
-
# Copyright:: Copyright
|
5
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
6
6
|
# License:: Apache License, Version 2.0
|
7
7
|
#
|
8
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# Author:: Barry Davis (barryd@jetstreamsoftware.com)
|
3
3
|
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
4
4
|
# Author:: Adam Jacob (<adam@chef.io>)
|
5
|
-
# Copyright:: Copyright
|
5
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
6
6
|
# License:: Apache License, Version 2.0
|
7
7
|
#
|
8
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Jeff Mendoza (jeffmendoza@live.com)
|
3
|
-
# Copyright:: Copyright
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -50,10 +50,10 @@ class Chef
|
|
50
50
|
validate_asm_keys!(:azure_network_name, :azure_affinity_group, :azure_address_space)
|
51
51
|
|
52
52
|
params = {
|
53
|
-
azure_vnet_name:
|
54
|
-
azure_ag_name:
|
55
|
-
azure_address_space:
|
56
|
-
azure_subnet_name:
|
53
|
+
azure_vnet_name: config[:azure_network_name],
|
54
|
+
azure_ag_name: config[:azure_affinity_group],
|
55
|
+
azure_address_space: config[:azure_address_space],
|
56
|
+
azure_subnet_name: config[:azure_subnet_name] || "Subnet-#{Random.rand(10)}",
|
57
57
|
}
|
58
58
|
|
59
59
|
rsp = service.create_vnet(params)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Jeff Mendoza (jeffmendoza@live.com)
|
3
|
-
# Copyright:: Copyright
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Aliasgar Batterywala (aliasgar.batterywala@clogeny.com)
|
3
|
-
# Copyright:: Copyright
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -31,8 +31,8 @@ class Chef
|
|
31
31
|
include Knife::Bootstrap::Bootstrapper
|
32
32
|
|
33
33
|
deps do
|
34
|
-
require "securerandom"
|
35
|
-
include Knife::AzurermBase
|
34
|
+
require "securerandom" unless defined?(SecureRandom)
|
35
|
+
include Knife::AzurermBase
|
36
36
|
end
|
37
37
|
|
38
38
|
banner "knife azurerm server create (options)"
|
@@ -156,55 +156,55 @@ class Chef
|
|
156
156
|
|
157
157
|
def create_server_def
|
158
158
|
server_def = {
|
159
|
-
azure_resource_group_name:
|
160
|
-
azure_storage_account:
|
161
|
-
azure_storage_account_type:
|
162
|
-
azure_vm_name:
|
163
|
-
azure_service_location:
|
164
|
-
azure_os_disk_name:
|
165
|
-
azure_os_disk_caching:
|
166
|
-
azure_os_disk_create_option:
|
167
|
-
azure_vm_size:
|
168
|
-
azure_image_reference_publisher:
|
169
|
-
azure_image_reference_offer:
|
170
|
-
azure_image_reference_sku:
|
171
|
-
azure_image_reference_version:
|
172
|
-
azure_availability_set:
|
173
|
-
azure_vnet_name:
|
174
|
-
azure_vnet_subnet_name:
|
175
|
-
ssl_cert_fingerprint:
|
176
|
-
cert_path:
|
177
|
-
cert_password:
|
178
|
-
vnet_subnet_address_prefix:
|
179
|
-
server_count:
|
159
|
+
azure_resource_group_name: config[:azure_resource_group_name],
|
160
|
+
azure_storage_account: config[:azure_storage_account],
|
161
|
+
azure_storage_account_type: config[:azure_storage_account_type],
|
162
|
+
azure_vm_name: config[:azure_vm_name],
|
163
|
+
azure_service_location: config[:azure_service_location],
|
164
|
+
azure_os_disk_name: config[:azure_os_disk_name],
|
165
|
+
azure_os_disk_caching: config[:azure_os_disk_caching],
|
166
|
+
azure_os_disk_create_option: config[:azure_os_disk_create_option],
|
167
|
+
azure_vm_size: config[:azure_vm_size],
|
168
|
+
azure_image_reference_publisher: config[:azure_image_reference_publisher],
|
169
|
+
azure_image_reference_offer: config[:azure_image_reference_offer],
|
170
|
+
azure_image_reference_sku: config[:azure_image_reference_sku],
|
171
|
+
azure_image_reference_version: config[:azure_image_reference_version],
|
172
|
+
azure_availability_set: config[:azure_availability_set],
|
173
|
+
azure_vnet_name: config[:azure_vnet_name],
|
174
|
+
azure_vnet_subnet_name: config[:azure_vnet_subnet_name],
|
175
|
+
ssl_cert_fingerprint: config[:thumbprint],
|
176
|
+
cert_path: config[:cert_path],
|
177
|
+
cert_password: config[:cert_passphrase],
|
178
|
+
vnet_subnet_address_prefix: config[:vnet_subnet_address_prefix],
|
179
|
+
server_count: config[:server_count],
|
180
180
|
}
|
181
181
|
|
182
|
-
server_def[:tcp_endpoints] =
|
182
|
+
server_def[:tcp_endpoints] = config[:tcp_endpoints] if config[:tcp_endpoints]
|
183
183
|
|
184
184
|
# We assign azure_vm_name to chef_node_name If node name is nill because storage account name is combination of hash value and node name.
|
185
|
-
config[:chef_node_name] ||=
|
185
|
+
config[:chef_node_name] ||= config[:azure_vm_name]
|
186
186
|
|
187
|
-
server_def[:azure_storage_account] =
|
187
|
+
server_def[:azure_storage_account] = config[:azure_vm_name] if server_def[:azure_storage_account].nil?
|
188
188
|
server_def[:azure_storage_account] = server_def[:azure_storage_account].gsub(/[!@#$%^&*()_-]/, "")
|
189
189
|
|
190
|
-
server_def[:azure_os_disk_name] =
|
190
|
+
server_def[:azure_os_disk_name] = config[:azure_vm_name] if server_def[:azure_os_disk_name].nil?
|
191
191
|
server_def[:azure_os_disk_name] = server_def[:azure_os_disk_name].gsub(/[!@#$%^&*()_-]/, "")
|
192
192
|
|
193
|
-
server_def[:azure_vnet_name] =
|
194
|
-
server_def[:azure_vnet_subnet_name] =
|
193
|
+
server_def[:azure_vnet_name] = config[:azure_vm_name] if server_def[:azure_vnet_name].nil?
|
194
|
+
server_def[:azure_vnet_subnet_name] = config[:azure_vm_name] if config[:azure_vnet_subnet_name].nil?
|
195
195
|
|
196
196
|
server_def[:chef_extension] = get_chef_extension_name
|
197
197
|
server_def[:chef_extension_publisher] = get_chef_extension_publisher
|
198
|
-
server_def[:chef_extension_version] =
|
198
|
+
server_def[:chef_extension_version] = config[:azure_chef_extension_version]
|
199
199
|
server_def[:chef_extension_public_param] = get_chef_extension_public_params
|
200
200
|
server_def[:chef_extension_private_param] = get_chef_extension_private_params
|
201
201
|
server_def[:auto_upgrade_minor_version] = false
|
202
|
-
server_def[:connection_user] =
|
203
|
-
server_def[:disablePasswordAuthentication] = if
|
204
|
-
server_def[:ssh_public_key] = File.read(
|
202
|
+
server_def[:connection_user] = config[:connection_user]
|
203
|
+
server_def[:disablePasswordAuthentication] = if config[:ssh_public_key]
|
204
|
+
server_def[:ssh_public_key] = File.read(config[:ssh_public_key])
|
205
205
|
"true"
|
206
206
|
else
|
207
|
-
server_def[:connection_password] =
|
207
|
+
server_def[:connection_password] = config[:connection_password]
|
208
208
|
"false"
|
209
209
|
end
|
210
210
|
|
@@ -229,7 +229,7 @@ class Chef
|
|
229
229
|
end
|
230
230
|
|
231
231
|
def validate_ohai_hints
|
232
|
-
hint_values =
|
232
|
+
hint_values = config[:ohai_hints].split(",")
|
233
233
|
hint_values.each do |hint|
|
234
234
|
unless is_supported_ohai_hint?(hint)
|
235
235
|
raise ArgumentError, "Ohai Hint name #{hint} passed is not supported. Please run the command help to see the list of supported values."
|
@@ -245,22 +245,22 @@ class Chef
|
|
245
245
|
end
|
246
246
|
|
247
247
|
def set_configs
|
248
|
-
unless
|
249
|
-
config[:connection_user] =
|
248
|
+
unless config[:connection_user].nil?
|
249
|
+
config[:connection_user] = config[:connection_user]
|
250
250
|
end
|
251
251
|
|
252
|
-
unless
|
253
|
-
config[:connection_password] =
|
252
|
+
unless config[:connection_password].nil?
|
253
|
+
config[:connection_password] = config[:connection_password]
|
254
254
|
end
|
255
255
|
end
|
256
256
|
|
257
257
|
def set_default_image_reference!
|
258
258
|
begin
|
259
|
-
if
|
259
|
+
if config[:azure_image_os_type]
|
260
260
|
validate_publisher_and_offer
|
261
261
|
## if azure_image_os_type is given (with or without azure-image-reference-sku) and other image reference parameters are not given,
|
262
262
|
# set default image reference parameters
|
263
|
-
case
|
263
|
+
case config[:azure_image_os_type]
|
264
264
|
when "ubuntu"
|
265
265
|
set_os_image("Canonical", "UbuntuServer", "14.04.2-LTS")
|
266
266
|
when "centos"
|
@@ -292,15 +292,15 @@ class Chef
|
|
292
292
|
def set_os_image(publisher, img_offer, default_os_version)
|
293
293
|
config[:azure_image_reference_publisher] = publisher
|
294
294
|
config[:azure_image_reference_offer] = img_offer
|
295
|
-
config[:azure_image_reference_sku] =
|
295
|
+
config[:azure_image_reference_sku] = config[:azure_image_reference_sku] ? config[:azure_image_reference_sku] : default_os_version
|
296
296
|
end
|
297
297
|
|
298
298
|
def is_image_os_type?
|
299
|
-
|
299
|
+
config[:azure_image_reference_publisher] && config[:azure_image_reference_offer] && config[:azure_image_reference_sku] && config[:azure_image_reference_version]
|
300
300
|
end
|
301
301
|
|
302
302
|
def validate_publisher_and_offer
|
303
|
-
if
|
303
|
+
if config[:azure_image_reference_publisher] || config[:azure_image_reference_offer]
|
304
304
|
# if azure_image_os_type is given and any of the other image reference parameters like publisher or offer are also given,
|
305
305
|
# raise error
|
306
306
|
raise ArgumentError, 'Please specify either --azure-image-os-type OR --azure-image-os-type with --azure-image-reference-sku or 4 image reference parameters i.e.
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# Author:: Barry Davis (barryd@jetstreamsoftware.com)
|
3
3
|
# Author:: Adam Jacob (<adam@chef.io>)
|
4
4
|
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
5
|
-
# Copyright:: Copyright
|
5
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
6
6
|
# License:: Apache License, Version 2.0
|
7
7
|
#
|
8
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -30,7 +30,7 @@ class Chef
|
|
30
30
|
# These two are needed for the '--purge' deletion case
|
31
31
|
require "chef/node"
|
32
32
|
require "chef/api_client"
|
33
|
-
include Knife::AzurermBase
|
33
|
+
include Knife::AzurermBase
|
34
34
|
end
|
35
35
|
|
36
36
|
banner "knife azurerm server delete SERVER [SERVER] (options)"
|
@@ -51,7 +51,7 @@ class Chef
|
|
51
51
|
long: "--delete-resource-group",
|
52
52
|
boolean: true,
|
53
53
|
default: false,
|
54
|
-
description: "Deletes corresponding resource group along with
|
54
|
+
description: "Deletes corresponding resource group along with Virtual Machine."
|
55
55
|
|
56
56
|
# Extracted from Chef::Knife.delete_object, because it has a
|
57
57
|
# confirmation step built in... By specifying the '--purge'
|
@@ -74,10 +74,10 @@ class Chef
|
|
74
74
|
validate_arm_keys!(:azure_resource_group_name)
|
75
75
|
@vm_name = @name_args[0]
|
76
76
|
|
77
|
-
if
|
77
|
+
if config[:delete_resource_group]
|
78
78
|
delete_resource_group
|
79
79
|
else
|
80
|
-
service.delete_server(
|
80
|
+
service.delete_server(config[:azure_resource_group_name], @vm_name)
|
81
81
|
end
|
82
82
|
|
83
83
|
if config[:purge]
|
@@ -90,18 +90,18 @@ class Chef
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def delete_resource_group
|
93
|
-
resource_group_name =
|
93
|
+
resource_group_name = config[:azure_resource_group_name]
|
94
94
|
ui.warn "Deleting resource group will delete all the virtual_machines inside it."
|
95
95
|
begin
|
96
96
|
ui.confirm("Do you really want to delete resource group")
|
97
97
|
rescue SystemExit # Need to handle this as confirming with N/n raises SystemExit exception
|
98
98
|
server = nil # Cleanup is implicitly performed in other cloud plugins
|
99
99
|
ui.warn "Resource group not deleted. Proceeding for server delete ..."
|
100
|
-
service.delete_server(
|
100
|
+
service.delete_server(config[:azure_resource_group_name], @vm_name)
|
101
101
|
exit
|
102
102
|
end
|
103
103
|
ui.info "Deleting Resource Group " + resource_group_name + " and Virtual Machine " + @vm_name + " .."
|
104
|
-
service.delete_resource_group(
|
104
|
+
service.delete_resource_group(config[:azure_resource_group_name])
|
105
105
|
ui.warn "Deleted resource_group_name #{resource_group_name} and #{@vm_name}"
|
106
106
|
end
|
107
107
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -27,7 +27,7 @@ class Chef
|
|
27
27
|
banner "knife azurerm server list (options)"
|
28
28
|
|
29
29
|
deps do
|
30
|
-
include Knife::AzurermBase
|
30
|
+
include Knife::AzurermBase
|
31
31
|
end
|
32
32
|
|
33
33
|
def run
|
@@ -36,7 +36,7 @@ class Chef
|
|
36
36
|
get_azure_cli_version
|
37
37
|
validate_arm_keys!
|
38
38
|
begin
|
39
|
-
service.list_servers(
|
39
|
+
service.list_servers(config[:azure_resource_group_name])
|
40
40
|
rescue => error
|
41
41
|
service.common_arm_rescue_block(error)
|
42
42
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Meera Navale (meera.navale@msystechnologies.com)
|
3
|
-
# Copyright:: Copyright
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -27,7 +27,7 @@ class Chef
|
|
27
27
|
banner "knife azurerm server show SERVER (options)"
|
28
28
|
|
29
29
|
deps do
|
30
|
-
include Knife::AzurermBase
|
30
|
+
include Knife::AzurermBase
|
31
31
|
end
|
32
32
|
|
33
33
|
def run
|
@@ -36,7 +36,7 @@ class Chef
|
|
36
36
|
get_azure_cli_version
|
37
37
|
validate_arm_keys!(:azure_resource_group_name)
|
38
38
|
begin
|
39
|
-
service.show_server(@name_args[0],
|
39
|
+
service.show_server(@name_args[0], config[:azure_resource_group_name])
|
40
40
|
rescue => error
|
41
41
|
service.common_arm_rescue_block(error)
|
42
42
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Aliasgar Batterywala (aliasgar.batterywala@clogeny.com)
|
3
|
-
# Copyright:: Copyright
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -16,6 +16,8 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
+
require_relative "../../../azure/resource_management/ARM_interface"
|
20
|
+
|
19
21
|
class Chef
|
20
22
|
class Knife
|
21
23
|
class Bootstrap
|
@@ -39,13 +41,13 @@ class Chef
|
|
39
41
|
|
40
42
|
# get latest version
|
41
43
|
def get_chef_extension_version(chef_extension_name = nil)
|
42
|
-
if
|
43
|
-
|
44
|
+
if config[:azure_chef_extension_version]
|
45
|
+
config[:azure_chef_extension_version]
|
44
46
|
else
|
45
47
|
chef_extension_name ||= get_chef_extension_name
|
46
48
|
if @service.instance_of? Azure::ResourceManagement::ARMInterface
|
47
49
|
service.get_latest_chef_extension_version(
|
48
|
-
azure_service_location:
|
50
|
+
azure_service_location: config[:azure_service_location],
|
49
51
|
chef_extension_publisher: get_chef_extension_publisher,
|
50
52
|
chef_extension: chef_extension_name
|
51
53
|
)
|
@@ -57,7 +59,7 @@ class Chef
|
|
57
59
|
end
|
58
60
|
|
59
61
|
def ohai_hints
|
60
|
-
hint_values =
|
62
|
+
hint_values = config[:ohai_hints]
|
61
63
|
if hint_values.casecmp("default") == 0
|
62
64
|
default_hint_options
|
63
65
|
else
|
@@ -67,47 +69,39 @@ class Chef
|
|
67
69
|
|
68
70
|
def get_chef_extension_public_params
|
69
71
|
pub_config = {}
|
70
|
-
if
|
71
|
-
pub_config[:client_rb] = File.read(File.expand_path(
|
72
|
+
if config[:azure_extension_client_config]
|
73
|
+
pub_config[:client_rb] = File.read(File.expand_path(config[:azure_extension_client_config]))
|
72
74
|
else
|
73
75
|
pub_config[:client_rb] = "chef_server_url \t #{Chef::Config[:chef_server_url].to_json}\nvalidation_client_name\t#{Chef::Config[:validation_client_name].to_json}"
|
74
76
|
end
|
75
77
|
|
76
|
-
pub_config[:runlist] =
|
77
|
-
pub_config[:custom_json_attr] =
|
78
|
-
pub_config[:extendedLogs] =
|
79
|
-
pub_config[:hints] = ohai_hints if @service.instance_of?(Azure::ResourceManagement::ARMInterface) && !
|
80
|
-
pub_config[:chef_daemon_interval] =
|
81
|
-
pub_config[:daemon] =
|
78
|
+
pub_config[:runlist] = config[:run_list].empty? ? "" : config[:run_list].join(",").to_json
|
79
|
+
pub_config[:custom_json_attr] = config[:json_attributes] || {}
|
80
|
+
pub_config[:extendedLogs] = config[:extended_logs] ? "true" : "false"
|
81
|
+
pub_config[:hints] = ohai_hints if @service.instance_of?(Azure::ResourceManagement::ARMInterface) && !config[:ohai_hints].nil?
|
82
|
+
pub_config[:chef_daemon_interval] = config[:chef_daemon_interval] if config[:chef_daemon_interval]
|
83
|
+
pub_config[:daemon] = config[:daemon] if config[:daemon]
|
82
84
|
|
83
85
|
# bootstrap attributes
|
84
86
|
pub_config[:bootstrap_options] = {}
|
85
|
-
pub_config[:bootstrap_options][:environment] =
|
86
|
-
pub_config[:bootstrap_options][:chef_node_name] =
|
87
|
+
pub_config[:bootstrap_options][:environment] = config[:environment] if config[:environment]
|
88
|
+
pub_config[:bootstrap_options][:chef_node_name] = config[:chef_node_name] if config[:chef_node_name]
|
87
89
|
pub_config[:bootstrap_options][:chef_server_url] = Chef::Config[:chef_server_url] if Chef::Config[:chef_server_url]
|
88
90
|
pub_config[:bootstrap_options][:validation_client_name] = Chef::Config[:validation_client_name] if Chef::Config[:validation_client_name]
|
89
|
-
pub_config[:bootstrap_options][:node_verify_api_cert] =
|
90
|
-
pub_config[:bootstrap_options][:bootstrap_version] =
|
91
|
-
pub_config[:bootstrap_options][:node_ssl_verify_mode] =
|
92
|
-
pub_config[:bootstrap_options][:bootstrap_proxy] =
|
91
|
+
pub_config[:bootstrap_options][:node_verify_api_cert] = config[:node_verify_api_cert] ? "true" : "false" if config.key?(:node_verify_api_cert)
|
92
|
+
pub_config[:bootstrap_options][:bootstrap_version] = config[:bootstrap_version] if config[:bootstrap_version]
|
93
|
+
pub_config[:bootstrap_options][:node_ssl_verify_mode] = config[:node_ssl_verify_mode] if config[:node_ssl_verify_mode]
|
94
|
+
pub_config[:bootstrap_options][:bootstrap_proxy] = config[:bootstrap_proxy] if config[:bootstrap_proxy]
|
93
95
|
pub_config
|
94
96
|
end
|
95
97
|
|
96
98
|
def load_correct_secret
|
97
|
-
|
98
|
-
|
99
|
-
cli_secret_file = config[:encrypted_data_bag_secret_file]
|
100
|
-
cli_secret = config[:encrypted_data_bag_secret]
|
101
|
-
|
102
|
-
# The value set in knife.rb gets set in config object too
|
103
|
-
# That's why setting cli objects to nil if the values are specified in knife.rb
|
104
|
-
cli_secret_file = nil if cli_secret_file == knife_secret_file
|
105
|
-
cli_secret = nil if cli_secret == knife_secret
|
99
|
+
secret_file = config[:encrypted_data_bag_secret_file]
|
100
|
+
secret = config[:encrypted_data_bag_secret]
|
106
101
|
|
107
|
-
|
108
|
-
knife_secret_file = Chef::EncryptedDataBagItem.load_secret(knife_secret_file) unless knife_secret_file.nil?
|
102
|
+
secret_file = Chef::EncryptedDataBagItem.load_secret(secret_file) unless secret_file.nil?
|
109
103
|
|
110
|
-
|
104
|
+
secret_file || secret
|
111
105
|
end
|
112
106
|
|
113
107
|
def create_node_and_client_pem
|
@@ -115,7 +109,7 @@ class Chef
|
|
115
109
|
require "chef/knife/bootstrap/client_builder"
|
116
110
|
Chef::Knife::Bootstrap::ClientBuilder.new(
|
117
111
|
chef_config: Chef::Config,
|
118
|
-
|
112
|
+
config: config,
|
119
113
|
ui: ui
|
120
114
|
)
|
121
115
|
end
|
@@ -153,9 +147,9 @@ class Chef
|
|
153
147
|
end
|
154
148
|
|
155
149
|
# SSL cert bootstrap support
|
156
|
-
if
|
157
|
-
if File.exist?(File.expand_path(
|
158
|
-
pri_config[:chef_server_crt] = File.read(File.expand_path(
|
150
|
+
if config[:cert_path]
|
151
|
+
if File.exist?(File.expand_path(config[:cert_path]))
|
152
|
+
pri_config[:chef_server_crt] = File.read(File.expand_path(config[:cert_path]))
|
159
153
|
else
|
160
154
|
ui.error("Specified SSL certificate does not exist.")
|
161
155
|
exit 1
|