knife-azure 2.0.17 → 3.0.0
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 +1 -1
- data/lib/azure/resource_management/vnet_config.rb +1 -1
- data/lib/azure/resource_management/windows_credentials.rb +1 -1
- 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 +2 -2
- 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 +1 -1
- data/lib/azure/service_management/role.rb +1 -1
- 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 +70 -70
- 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 +43 -43
- data/lib/chef/knife/azurerm_server_delete.rb +6 -6
- data/lib/chef/knife/azurerm_server_list.rb +2 -2
- data/lib/chef/knife/azurerm_server_show.rb +2 -2
- 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 +8 -8
- data/lib/chef/knife/bootstrap_azurerm.rb +5 -5
- data/lib/chef/knife/helpers/azure_base.rb +46 -55
- data/lib/chef/knife/helpers/azurerm_base.rb +30 -39
- data/lib/knife-azure/version.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e88a7081dafbf64000602515bbcf0d7a94626b01b10b0eeceacfc9422af357a
|
4
|
+
data.tar.gz: 1b5bcb5fa0b5d4b714786960a31dec0227341dffaa78912d659f815333c07f57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fc54ec3e79cc6334b5a2963474864be613e4b181ce5bab21a95773b0dea1de5a3ea3aab1dada8650df5c1f339e99973ac857d0d5e2870fc98cdbd164199744b
|
7
|
+
data.tar.gz: 1580127f2c555cd0112b18acb703114a9c5ebf6fbfe596573a3411540dc9982d54edc668fc6fd0b4190fb6dbbf9e378f8a9426945538a909c5036c0555d7232a
|
data/lib/azure/custom_errors.rb
CHANGED
data/lib/azure/helpers.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Nimisha Sharad (nimisha.sharad@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");
|
@@ -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");
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Nimisha Sharad (nimisha.sharad@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");
|
@@ -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:: Mukta Aphale (mukta.aphale@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");
|
@@ -142,7 +142,7 @@ module Azure
|
|
142
142
|
puts "Certificate Thumbprint: #{@thumbprint.to_s.upcase}"
|
143
143
|
puts "*" * 70
|
144
144
|
|
145
|
-
|
145
|
+
config[:ca_trust_file] = file_path + ".pem" if config[:ca_trust_file].nil?
|
146
146
|
cert_data = File.read (file_path + ".b64")
|
147
147
|
add_certificate cert_data, @winrm_cert_passphrase, "pfx", cert_params[:azure_dns_name]
|
148
148
|
@thumbprint
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Barry Davis (barryd@jetstreamsoftware.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:: Barry Davis (barryd@jetstreamsoftware.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:: Barry Davis (barryd@jetstreamsoftware.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:: Barry Davis (barryd@jetstreamsoftware.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:: Barry Davis (barryd@jetstreamsoftware.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:: Aiman Alsari (aiman.alsari@gmail.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:: Barry Davis (barryd@jetstreamsoftware.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:: Barry Davis (barryd@jetstreamsoftware.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:: Barry Davis (barryd@jetstreamsoftware.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:: Barry Davis (barryd@jetstreamsoftware.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:: 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:: 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,9 +50,9 @@ class Chef
|
|
50
50
|
:azure_service_location)
|
51
51
|
|
52
52
|
params = {
|
53
|
-
azure_ag_name:
|
54
|
-
azure_ag_desc:
|
55
|
-
azure_location:
|
53
|
+
azure_ag_name: config[:azure_affinity_group],
|
54
|
+
azure_ag_desc: config[:azure_ag_desc],
|
55
|
+
azure_location: config[:azure_service_location],
|
56
56
|
}
|
57
57
|
|
58
58
|
rsp = service.create_affinity_group(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");
|
@@ -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");
|
@@ -40,7 +40,7 @@ class Chef
|
|
40
40
|
validate_asm_keys!
|
41
41
|
items = service.list_images
|
42
42
|
|
43
|
-
image_labels = !
|
43
|
+
image_labels = !config[:show_all_fields] ? %w{Name OS Location} : %w{Name Category Label OS Location}
|
44
44
|
image_list = image_labels.map { |label| ui.color(label, :bold) }
|
45
45
|
|
46
46
|
image_items = image_labels.map(&:downcase)
|
@@ -49,7 +49,7 @@ class Chef
|
|
49
49
|
end
|
50
50
|
|
51
51
|
puts "\n"
|
52
|
-
puts ui.list(image_list, :uneven_columns_across, !
|
52
|
+
puts ui.list(image_list, :uneven_columns_across, !config[:show_all_fields] ? 3 : 5)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Aiman Alsari (aiman.alsari@gmail.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_load_balancer)
|
51
51
|
|
52
52
|
params = {
|
53
|
-
azure_load_balancer:
|
54
|
-
azure_lb_static_vip:
|
55
|
-
azure_subnet_name:
|
56
|
-
azure_dns_name:
|
53
|
+
azure_load_balancer: config[:azure_load_balancer],
|
54
|
+
azure_lb_static_vip: config[:azure_lb_static_vip],
|
55
|
+
azure_subnet_name: config[:azure_subnet_name],
|
56
|
+
azure_dns_name: config[:azure_dns_name],
|
57
57
|
}
|
58
58
|
|
59
59
|
rsp = service.create_internal_lb(params)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Aiman Alsari (aiman.alsari@gmail.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");
|
@@ -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");
|
@@ -196,7 +196,7 @@ class Chef
|
|
196
196
|
|
197
197
|
config[:connection_port] = server_def[:port]
|
198
198
|
config[:connection_protocol] = server_def[:connection_protocol]
|
199
|
-
config[:chef_node_name] =
|
199
|
+
config[:chef_node_name] = config[:chef_node_name] || server_name
|
200
200
|
rescue => error
|
201
201
|
ui.error("Something went wrong. Please use -VV option for more details.")
|
202
202
|
Chef::Log.debug(error.backtrace.join("\n").to_s)
|
@@ -216,7 +216,7 @@ class Chef
|
|
216
216
|
alias host_descriptor server_name
|
217
217
|
|
218
218
|
def plugin_finalize
|
219
|
-
if
|
219
|
+
if config[:connection_protocol] == "cloud-api" && config[:extended_logs]
|
220
220
|
print "\nWaiting for the first chef-client run"
|
221
221
|
fetch_chef_client_logs(Time.now, 30)
|
222
222
|
end
|
@@ -228,8 +228,8 @@ class Chef
|
|
228
228
|
def wait_until_virtual_machine_ready(retry_interval_in_seconds = 30)
|
229
229
|
vm_status = nil
|
230
230
|
begin
|
231
|
-
azure_vm_startup_timeout =
|
232
|
-
azure_vm_ready_timeout =
|
231
|
+
azure_vm_startup_timeout = config[:azure_vm_startup_timeout].to_i
|
232
|
+
azure_vm_ready_timeout = config[:azure_vm_ready_timeout].to_i
|
233
233
|
vm_status = wait_for_virtual_machine_state(:vm_status_provisioning, azure_vm_startup_timeout, retry_interval_in_seconds)
|
234
234
|
if vm_status != :vm_status_ready
|
235
235
|
begin
|
@@ -242,7 +242,7 @@ class Chef
|
|
242
242
|
|
243
243
|
msg_server_summary(@server)
|
244
244
|
|
245
|
-
if
|
245
|
+
if config[:connection_protocol] == "cloud-api"
|
246
246
|
extension_status = wait_for_resource_extension_state(:wagent_provisioning, 5, retry_interval_in_seconds)
|
247
247
|
|
248
248
|
if extension_status != :extension_installing
|
@@ -323,7 +323,7 @@ class Chef
|
|
323
323
|
end
|
324
324
|
|
325
325
|
def get_virtual_machine_status
|
326
|
-
@server = service.get_role_server(
|
326
|
+
@server = service.get_role_server(config[:azure_dns_name], config[:azure_vm_name])
|
327
327
|
if @server.nil?
|
328
328
|
:vm_status_not_detected
|
329
329
|
else
|
@@ -340,14 +340,14 @@ class Chef
|
|
340
340
|
end
|
341
341
|
|
342
342
|
def get_extension_status
|
343
|
-
deployment_name = service.deployment_name(
|
344
|
-
deployment = service.deployment("hostedservices/#{
|
343
|
+
deployment_name = service.deployment_name(config[:azure_dns_name])
|
344
|
+
deployment = service.deployment("hostedservices/#{config[:azure_dns_name]}/deployments/#{deployment_name}")
|
345
345
|
extension_status = {}
|
346
346
|
|
347
347
|
if deployment.at_css("Deployment Name") != nil
|
348
348
|
role_list_xml = deployment.css("RoleInstanceList RoleInstance")
|
349
349
|
role_list_xml.each do |role|
|
350
|
-
if role.at_css("RoleName").text ==
|
350
|
+
if role.at_css("RoleName").text == config[:azure_vm_name]
|
351
351
|
lnx_waagent_fail_msg = "Failed to deserialize the status reported by the Guest Agent"
|
352
352
|
waagent_status_msg = role.at_css("GuestAgentStatus FormattedMessage Message").text
|
353
353
|
if role.at_css("GuestAgentStatus Status").text == "Ready"
|
@@ -384,32 +384,32 @@ class Chef
|
|
384
384
|
|
385
385
|
def create_server_def
|
386
386
|
server_def = {
|
387
|
-
azure_storage_account:
|
388
|
-
azure_api_host_name:
|
389
|
-
azure_dns_name:
|
390
|
-
azure_vm_name:
|
391
|
-
azure_service_location:
|
392
|
-
azure_os_disk_name:
|
393
|
-
azure_source_image:
|
394
|
-
azure_vm_size:
|
395
|
-
tcp_endpoints:
|
396
|
-
udp_endpoints:
|
397
|
-
connection_protocol:
|
398
|
-
azure_connect_to_existing_dns:
|
399
|
-
connection_user:
|
400
|
-
azure_availability_set:
|
401
|
-
azure_affinity_group:
|
402
|
-
azure_network_name:
|
403
|
-
azure_subnet_name:
|
404
|
-
ssl_cert_fingerprint:
|
405
|
-
cert_path:
|
406
|
-
cert_password:
|
407
|
-
winrm_ssl:
|
408
|
-
winrm_max_timeout:
|
409
|
-
winrm_max_memory_per_shell:
|
387
|
+
azure_storage_account: config[:azure_storage_account],
|
388
|
+
azure_api_host_name: config[:azure_api_host_name],
|
389
|
+
azure_dns_name: config[:azure_dns_name],
|
390
|
+
azure_vm_name: config[:azure_vm_name],
|
391
|
+
azure_service_location: config[:azure_service_location],
|
392
|
+
azure_os_disk_name: config[:azure_os_disk_name],
|
393
|
+
azure_source_image: config[:azure_source_image],
|
394
|
+
azure_vm_size: config[:azure_vm_size],
|
395
|
+
tcp_endpoints: config[:tcp_endpoints],
|
396
|
+
udp_endpoints: config[:udp_endpoints],
|
397
|
+
connection_protocol: config[:connection_protocol],
|
398
|
+
azure_connect_to_existing_dns: config[:azure_connect_to_existing_dns],
|
399
|
+
connection_user: config[:connection_user],
|
400
|
+
azure_availability_set: config[:azure_availability_set],
|
401
|
+
azure_affinity_group: config[:azure_affinity_group],
|
402
|
+
azure_network_name: config[:azure_network_name],
|
403
|
+
azure_subnet_name: config[:azure_subnet_name],
|
404
|
+
ssl_cert_fingerprint: config[:thumbprint],
|
405
|
+
cert_path: config[:cert_path],
|
406
|
+
cert_password: config[:cert_passphrase],
|
407
|
+
winrm_ssl: config[:winrm_ssl],
|
408
|
+
winrm_max_timeout: config[:winrm_max_timeout].to_i * 60 * 1000, # converting minutes to milliseconds
|
409
|
+
winrm_max_memory_per_shell: config[:winrm_max_memory_per_shell],
|
410
410
|
}
|
411
411
|
|
412
|
-
if
|
412
|
+
if config[:connection_protocol] == "cloud-api"
|
413
413
|
server_def[:chef_extension] = get_chef_extension_name
|
414
414
|
server_def[:chef_extension_publisher] = get_chef_extension_publisher
|
415
415
|
server_def[:chef_extension_version] = get_chef_extension_version
|
@@ -420,20 +420,20 @@ class Chef
|
|
420
420
|
# We can specify the AdminUsername after API version 2013-03-01. However, in this API version,
|
421
421
|
# the AdminUsername is a required parameter.
|
422
422
|
# Also, the user name cannot be Administrator, Admin, Admin1 etc, for enhanced security (provided by Azure)
|
423
|
-
if
|
423
|
+
if config[:connection_user].nil? || config[:connection_user].downcase =~ /admin*/
|
424
424
|
ui.error("Connection User is compulsory parameter and it cannot be named 'admin*'")
|
425
425
|
exit 1
|
426
426
|
# take cares of when user name contains domain
|
427
427
|
# azure add role api doesn't support '\\' in user name
|
428
|
-
elsif
|
429
|
-
server_def[:connection_user] =
|
428
|
+
elsif config[:connection_user].split('\\').length.eql?(2)
|
429
|
+
server_def[:connection_user] = config[:connection_user].split('\\')[1]
|
430
430
|
end
|
431
431
|
else
|
432
|
-
unless
|
432
|
+
unless config[:connection_user]
|
433
433
|
ui.error("Connection User is compulsory parameter")
|
434
434
|
exit 1
|
435
435
|
end
|
436
|
-
unless
|
436
|
+
unless config[:connection_password] || config[:ssh_identity_file]
|
437
437
|
ui.error("Specify either SSH Key or SSH Password")
|
438
438
|
exit 1
|
439
439
|
end
|
@@ -442,52 +442,52 @@ class Chef
|
|
442
442
|
|
443
443
|
if is_image_windows?
|
444
444
|
server_def[:os_type] = "Windows"
|
445
|
-
server_def[:admin_password] =
|
446
|
-
server_def[:connection_protocol] =
|
445
|
+
server_def[:admin_password] = config[:connection_password]
|
446
|
+
server_def[:connection_protocol] = config[:connection_protocol] || "winrm"
|
447
447
|
else
|
448
448
|
server_def[:os_type] = "Linux"
|
449
|
-
server_def[:connection_protocol] =
|
450
|
-
server_def[:connection_user] =
|
451
|
-
server_def[:connection_password] =
|
452
|
-
server_def[:ssh_identity_file] =
|
453
|
-
server_def[:identity_file_passphrase] =
|
449
|
+
server_def[:connection_protocol] = config[:connection_protocol].nil? || config[:connection_protocol] == "winrm" ? "ssh" : config[:connection_protocol]
|
450
|
+
server_def[:connection_user] = config[:connection_user]
|
451
|
+
server_def[:connection_password] = config[:connection_password]
|
452
|
+
server_def[:ssh_identity_file] = config[:ssh_identity_file]
|
453
|
+
server_def[:identity_file_passphrase] = config[:identity_file_passphrase]
|
454
454
|
end
|
455
455
|
|
456
|
-
azure_connect_to_existing_dns =
|
456
|
+
azure_connect_to_existing_dns = config[:azure_connect_to_existing_dns]
|
457
457
|
if is_image_windows? && server_def[:connection_protocol] == "winrm"
|
458
|
-
port =
|
459
|
-
port =
|
458
|
+
port = config[:connection_port] || "5985"
|
459
|
+
port = config[:connection_port] || Random.rand(64000) + 1000 if azure_connect_to_existing_dns
|
460
460
|
elsif server_def[:connection_protocol] == "ssh"
|
461
|
-
port =
|
462
|
-
port =
|
461
|
+
port = config[:connection_port] || "22"
|
462
|
+
port = config[:connection_port] || Random.rand(64000) + 1000 if azure_connect_to_existing_dns
|
463
463
|
end
|
464
464
|
|
465
465
|
server_def[:port] = port
|
466
466
|
|
467
|
-
server_def[:is_vm_image] = service.vm_image?(
|
468
|
-
server_def[:azure_domain_name] =
|
467
|
+
server_def[:is_vm_image] = service.vm_image?(config[:azure_source_image])
|
468
|
+
server_def[:azure_domain_name] = config[:azure_domain_name] if config[:azure_domain_name]
|
469
469
|
|
470
|
-
if
|
470
|
+
if config[:azure_domain_user]
|
471
471
|
# extract domain name since it should be part of username
|
472
|
-
case
|
472
|
+
case config[:azure_domain_user]
|
473
473
|
when /(\S+)\\(.+)/ # format - fully-qualified-DNS-domain\username
|
474
|
-
server_def[:azure_domain_name] = $1 if
|
474
|
+
server_def[:azure_domain_name] = $1 if config[:azure_domain_name].nil?
|
475
475
|
server_def[:azure_user_domain_name] = $1
|
476
476
|
server_def[:azure_domain_user] = $2
|
477
477
|
when /(.+)@(\S+)/ # format - user@fully-qualified-DNS-domain
|
478
|
-
server_def[:azure_domain_name] = $2 if
|
478
|
+
server_def[:azure_domain_name] = $2 if config[:azure_domain_name].nil?
|
479
479
|
server_def[:azure_user_domain_name] = $2
|
480
480
|
server_def[:azure_domain_user] = $1
|
481
481
|
else
|
482
|
-
if
|
482
|
+
if config[:azure_domain_name].nil?
|
483
483
|
ui.error('--azure-domain-name should be specified if --azure-domain-user is not in one of the following formats: fully-qualified-DNS-domain\username, user@fully-qualified-DNS-domain')
|
484
484
|
exit 1
|
485
485
|
end
|
486
|
-
server_def[:azure_domain_user] =
|
486
|
+
server_def[:azure_domain_user] = config[:azure_domain_user]
|
487
487
|
end
|
488
488
|
end
|
489
|
-
server_def[:azure_domain_passwd] =
|
490
|
-
server_def[:azure_domain_ou_dn] =
|
489
|
+
server_def[:azure_domain_passwd] = config[:azure_domain_passwd]
|
490
|
+
server_def[:azure_domain_ou_dn] = config[:azure_domain_ou_dn]
|
491
491
|
|
492
492
|
server_def
|
493
493
|
end
|
@@ -499,17 +499,17 @@ class Chef
|
|
499
499
|
end
|
500
500
|
|
501
501
|
def set_configs
|
502
|
-
unless
|
503
|
-
config[:connection_user] =
|
502
|
+
unless config[:connection_user].nil?
|
503
|
+
config[:connection_user] = config[:connection_user]
|
504
504
|
end
|
505
505
|
|
506
|
-
unless
|
507
|
-
config[:connection_password] =
|
506
|
+
unless config[:connection_password].nil?
|
507
|
+
config[:connection_password] = config[:connection_password]
|
508
508
|
end
|
509
509
|
|
510
|
-
config[:azure_dns_name] = get_dns_name(
|
511
|
-
config[:azure_vm_name] =
|
512
|
-
config[:chef_node_name] =
|
510
|
+
config[:azure_dns_name] = get_dns_name(config[:azure_dns_name])
|
511
|
+
config[:azure_vm_name] = config[:azure_dns_name] unless config[:azure_vm_name]
|
512
|
+
config[:chef_node_name] = config[:azure_vm_name] unless config[:chef_node_name]
|
513
513
|
end
|
514
514
|
|
515
515
|
# This is related to Windows VM's specifically and computer name
|
@@ -520,10 +520,10 @@ class Chef
|
|
520
520
|
def get_dns_name(azure_dns_name, prefix = "az-")
|
521
521
|
return azure_dns_name unless azure_dns_name.nil?
|
522
522
|
|
523
|
-
if
|
523
|
+
if config[:azure_vm_name].nil?
|
524
524
|
(prefix + SecureRandom.hex((MAX_VM_NAME_CHARACTERS - prefix.length) / 2))
|
525
525
|
else
|
526
|
-
|
526
|
+
config[:azure_vm_name]
|
527
527
|
end
|
528
528
|
end
|
529
529
|
end
|