kitchen-azurerm 0.14.5 → 0.14.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48686c1b93c3d916cca41346cda4eb141a021d8d6308d148575253ad883cf248
4
- data.tar.gz: 44a8318d01777d3b94d953981d80c189d5962493fdedf4a8b73b6d7b2750e135
3
+ metadata.gz: 117af76802af7dfe99cdbbd2dc8f04c2f604eb31ae84c13f0387f4d485d835a0
4
+ data.tar.gz: 81451cac13793b0e8e29c83ba9f3a9eafcc2e44db7cd39db7957fa7662497fd3
5
5
  SHA512:
6
- metadata.gz: 9211a640370d4bd09dde5545dc115bd9844cbf09d25f4c5e01096141f5946163d8190182c04e6ad686328268ba5296881811ad61b452e052b8e76d89f35a2171
7
- data.tar.gz: ef1d03c0850274e6cdebdfd980a13b030f36a3334f910113937c936b59036d9a9da59dcd71362b34bb9bfdf55fec496b08610c1fec49e893d4a7081456dd0b92
6
+ metadata.gz: ac2d7df5bbd0220e0a9b3d8b75c51c2c88e510fce94f8bf03a5f35e7f8e3b41a5e14755656668d1cd3c5532277c230a7c230650473a25bf5c6f22b0dfcd845d2
7
+ data.tar.gz: f2cac3f9976a1849fedfabbad3c50400b4a11858a988338eb72412258002b11d6d0c1717cb7a7814717412eaa5774da8e908daa3516eaf3e343bbcc95f9bed37
data/README.md CHANGED
@@ -91,7 +91,7 @@ Where <n> is the number of threads to create. Note that any failure (e.g. an Azu
91
91
 
92
92
  ### .kitchen.yml example 2 - Windows
93
93
 
94
- Here's a further example ```.kitchen.yml``` file that will provision a Windows Server 2012 R2 instance, using WinRM as the transport. The resource created in Azure will enable itself for remote access at deployment time (it does this by customizing the machine at provisioning time):
94
+ Here's a further example ```.kitchen.yml``` file that will provision a Windows Server 2012 R2 instance, using WinRM as the transport. The resource created in Azure will enable itself for remote access at deployment time (it does this by customizing the machine at provisioning time) and tags the Azure Resource Group with metadata using the ```resource_group_tags``` property. Notice that the ```vm_tags``` and ```resource_group_tags``` properties use a simple ```key : value``` structure per line:
95
95
 
96
96
  ```yaml
97
97
  ---
@@ -108,6 +108,9 @@ platforms:
108
108
  - name: windows2012-r2
109
109
  driver:
110
110
  image_urn: MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:latest
111
+ resource_group_tags:
112
+ project: 'My Cool Project'
113
+ contact: 'me@somewhere.com'
111
114
  transport:
112
115
  name: winrm
113
116
  suites:
@@ -1,14 +1,14 @@
1
- require 'kitchen'
2
- require 'kitchen/driver/credentials'
3
- require 'securerandom'
4
- require 'azure_mgmt_resources'
5
- require 'azure_mgmt_network'
6
- require 'base64'
7
- require 'sshkey'
8
- require 'fileutils'
9
- require 'erb'
10
- require 'ostruct'
11
- require 'json'
1
+ require "kitchen"
2
+ require "kitchen/driver/credentials"
3
+ require "securerandom"
4
+ require "azure_mgmt_resources"
5
+ require "azure_mgmt_network"
6
+ require "base64"
7
+ require "sshkey"
8
+ require "fileutils"
9
+ require "erb"
10
+ require "ostruct"
11
+ require "json"
12
12
 
13
13
  module Kitchen
14
14
  module Driver
@@ -19,11 +19,11 @@ module Kitchen
19
19
  attr_accessor :resource_management_client
20
20
 
21
21
  default_config(:azure_resource_group_prefix) do |_config|
22
- 'kitchen-'
22
+ "kitchen-"
23
23
  end
24
24
 
25
25
  default_config(:azure_resource_group_suffix) do |_config|
26
- ''
26
+ ""
27
27
  end
28
28
 
29
29
  default_config(:azure_resource_group_name) do |config|
@@ -34,64 +34,68 @@ module Kitchen
34
34
  nil
35
35
  end
36
36
 
37
+ default_config(:resource_group_tags) do |_config|
38
+ {}
39
+ end
40
+
37
41
  default_config(:image_urn) do |_config|
38
- 'Canonical:UbuntuServer:14.04.3-LTS:latest'
42
+ "Canonical:UbuntuServer:14.04.3-LTS:latest"
39
43
  end
40
44
 
41
45
  default_config(:image_url) do |_config|
42
- ''
46
+ ""
43
47
  end
44
48
 
45
49
  default_config(:image_id) do |_config|
46
- ''
50
+ ""
47
51
  end
48
52
 
49
53
  default_config(:os_disk_size_gb) do |_config|
50
- ''
54
+ ""
51
55
  end
52
56
 
53
57
  default_config(:os_type) do |_config|
54
- 'linux'
58
+ "linux"
55
59
  end
56
60
 
57
61
  default_config(:custom_data) do |_config|
58
- ''
62
+ ""
59
63
  end
60
64
 
61
65
  default_config(:username) do |_config|
62
- 'azure'
66
+ "azure"
63
67
  end
64
68
 
65
69
  default_config(:password) do |_config|
66
- 'P2ssw0rd'
70
+ "P2ssw0rd"
67
71
  end
68
72
 
69
73
  default_config(:vm_name) do |_config|
70
- 'vm'
74
+ "vm"
71
75
  end
72
76
 
73
77
  default_config(:vnet_id) do |_config|
74
- ''
78
+ ""
75
79
  end
76
80
 
77
81
  default_config(:subnet_id) do |_config|
78
- ''
82
+ ""
79
83
  end
80
84
 
81
85
  default_config(:storage_account_type) do |_config|
82
- 'Standard_LRS'
86
+ "Standard_LRS"
83
87
  end
84
88
 
85
89
  default_config(:existing_storage_account_blob_url) do |_config|
86
- ''
90
+ ""
87
91
  end
88
92
 
89
93
  default_config(:existing_storage_account_container) do |_config|
90
- 'vhds'
94
+ "vhds"
91
95
  end
92
96
 
93
97
  default_config(:boot_diagnostics_enabled) do |_config|
94
- 'true'
98
+ "true"
95
99
  end
96
100
 
97
101
  default_config(:winrm_powershell_script) do |_config|
@@ -99,11 +103,11 @@ module Kitchen
99
103
  end
100
104
 
101
105
  default_config(:azure_environment) do |_config|
102
- 'Azure'
106
+ "Azure"
103
107
  end
104
108
 
105
109
  default_config(:pre_deployment_template) do |_config|
106
- ''
110
+ ""
107
111
  end
108
112
 
109
113
  default_config(:pre_deployment_parameters) do |_config|
@@ -111,7 +115,7 @@ module Kitchen
111
115
  end
112
116
 
113
117
  default_config(:post_deployment_template) do |_config|
114
- ''
118
+ ""
115
119
  end
116
120
 
117
121
  default_config(:post_deployment_parameters) do |_config|
@@ -159,48 +163,48 @@ module Kitchen
159
163
  bootDiagnosticsEnabled: config[:boot_diagnostics_enabled],
160
164
  newStorageAccountName: "storage#{state[:uuid]}",
161
165
  adminUsername: state[:username],
162
- adminPassword: state[:password] || 'P2ssw0rd',
166
+ adminPassword: state[:password] || "P2ssw0rd",
163
167
  dnsNameForPublicIP: "kitchen-#{state[:uuid]}",
164
- vmName: state[:vm_name]
168
+ vmName: state[:vm_name],
165
169
  }
166
170
 
167
- if config[:subscription_id].to_s == ''
168
- raise 'A subscription_id config value was not detected and kitchen-azurerm cannot continue. Please check your .kitchen.yml configuration. Exiting.'
171
+ if config[:subscription_id].to_s == ""
172
+ raise "A subscription_id config value was not detected and kitchen-azurerm cannot continue. Please check your .kitchen.yml configuration. Exiting."
169
173
  end
170
174
 
171
- if config[:custom_data].to_s != ''
172
- deployment_parameters['customData'] = prepared_custom_data
175
+ if config[:custom_data].to_s != ""
176
+ deployment_parameters["customData"] = prepared_custom_data
173
177
  end
174
178
  # When deploying in a shared storage account, we needs to add
175
179
  # a unique suffix to support multiple kitchen instances
176
- if config[:existing_storage_account_blob_url].to_s != ''
177
- deployment_parameters['osDiskNameSuffix'] = "-#{state[:azure_resource_group_name]}"
180
+ if config[:existing_storage_account_blob_url].to_s != ""
181
+ deployment_parameters["osDiskNameSuffix"] = "-#{state[:azure_resource_group_name]}"
178
182
  end
179
- if config[:existing_storage_account_blob_url].to_s != ''
180
- deployment_parameters['existingStorageAccountBlobURL'] = config[:existing_storage_account_blob_url]
183
+ if config[:existing_storage_account_blob_url].to_s != ""
184
+ deployment_parameters["existingStorageAccountBlobURL"] = config[:existing_storage_account_blob_url]
181
185
  end
182
- if config[:existing_storage_account_container].to_s != ''
183
- deployment_parameters['existingStorageAccountBlobContainer'] = config[:existing_storage_account_container]
186
+ if config[:existing_storage_account_container].to_s != ""
187
+ deployment_parameters["existingStorageAccountBlobContainer"] = config[:existing_storage_account_container]
184
188
  end
185
- if config[:os_disk_size_gb].to_s != ''
186
- deployment_parameters['osDiskSizeGb'] = config[:os_disk_size_gb]
189
+ if config[:os_disk_size_gb].to_s != ""
190
+ deployment_parameters["osDiskSizeGb"] = config[:os_disk_size_gb]
187
191
  end
188
192
 
189
193
  # The three deployment modes
190
194
  # a) Private Image: Managed VM Image (by id)
191
195
  # b) Private Image: Using a VHD URL (note: we must use existing_storage_account_blob_url due to azure limitations)
192
196
  # c) Public Image: Using a marketplace image (urn)
193
- if config[:image_id].to_s != ''
194
- deployment_parameters['imageId'] = config[:image_id]
195
- elsif config[:image_url].to_s != ''
196
- deployment_parameters['imageUrl'] = config[:image_url]
197
- deployment_parameters['osType'] = config[:os_type]
197
+ if config[:image_id].to_s != ""
198
+ deployment_parameters["imageId"] = config[:image_id]
199
+ elsif config[:image_url].to_s != ""
200
+ deployment_parameters["imageUrl"] = config[:image_url]
201
+ deployment_parameters["osType"] = config[:os_type]
198
202
  else
199
- image_publisher, image_offer, image_sku, image_version = config[:image_urn].split(':', 4)
200
- deployment_parameters['imagePublisher'] = image_publisher
201
- deployment_parameters['imageOffer'] = image_offer
202
- deployment_parameters['imageSku'] = image_sku
203
- deployment_parameters['imageVersion'] = image_version
203
+ image_publisher, image_offer, image_sku, image_version = config[:image_urn].split(":", 4)
204
+ deployment_parameters["imagePublisher"] = image_publisher
205
+ deployment_parameters["imageOffer"] = image_offer
206
+ deployment_parameters["imageSku"] = image_sku
207
+ deployment_parameters["imageVersion"] = image_version
204
208
  end
205
209
 
206
210
  options = Kitchen::Driver::Credentials.new.azure_options_for_subscription(config[:subscription_id], config[:azure_environment])
@@ -211,6 +215,7 @@ module Kitchen
211
215
  # Create Resource Group
212
216
  resource_group = ::Azure::Resources::Profiles::Latest::Mgmt::Models::ResourceGroup.new
213
217
  resource_group.location = config[:location]
218
+ resource_group.tags = config[:resource_group_tags]
214
219
  begin
215
220
  info "Creating Resource Group: #{state[:azure_resource_group_name]}"
216
221
  resource_management_client.resource_groups.create_or_update(state[:azure_resource_group_name], resource_group)
@@ -238,8 +243,8 @@ module Kitchen
238
243
  follow_deployment_until_end_state(state[:azure_resource_group_name], post_deployment_name)
239
244
  end
240
245
  rescue ::MsRestAzure::AzureOperationError => operation_error
241
- rest_error = operation_error.body['error']
242
- deployment_active = rest_error['code'] == 'DeploymentActive'
246
+ rest_error = operation_error.body["error"]
247
+ deployment_active = rest_error["code"] == "DeploymentActive"
243
248
  if deployment_active
244
249
  info "Deployment for resource group #{state[:azure_resource_group_name]} is ongoing."
245
250
  info "If you need to change the deployment template you'll need to rerun `kitchen create` for this instance."
@@ -251,15 +256,15 @@ module Kitchen
251
256
 
252
257
  network_management_client = ::Azure::Network::Profiles::Latest::Mgmt::Client.new(options)
253
258
 
254
- if config[:vnet_id] == '' || config[:public_ip]
259
+ if config[:vnet_id] == "" || config[:public_ip]
255
260
  # Retrieve the public IP from the resource group:
256
- result = network_management_client.public_ipaddresses.get(state[:azure_resource_group_name], 'publicip')
261
+ result = network_management_client.public_ipaddresses.get(state[:azure_resource_group_name], "publicip")
257
262
  info "IP Address is: #{result.ip_address} [#{result.dns_settings.fqdn}]"
258
263
  state[:hostname] = result.ip_address
259
264
  else
260
265
  # Retrieve the internal IP from the resource group:
261
266
  network_interfaces = ::Azure::Network::Profiles::Latest::Mgmt::NetworkInterfaces.new(network_management_client)
262
- result = network_interfaces.get(state[:azure_resource_group_name], 'nic')
267
+ result = network_interfaces.get(state[:azure_resource_group_name], "nic")
263
268
  info "IP Address is: #{result.ip_configurations[0].private_ipaddress}"
264
269
  state[:hostname] = result.ip_configurations[0].private_ipaddress
265
270
  end
@@ -273,7 +278,7 @@ module Kitchen
273
278
  state[:uuid] = SecureRandom.hex(8) unless existing_state_value?(state, :uuid)
274
279
  state[:server_id] = "vm#{state[:uuid]}" unless existing_state_value?(state, :server_id)
275
280
  state[:azure_resource_group_name] = azure_resource_group_name unless existing_state_value?(state, :azure_resource_group_name)
276
- %i[subscription_id username password vm_name azure_environment use_managed_disks].each do |config_element|
281
+ %i{subscription_id username password vm_name azure_environment use_managed_disks}.each do |config_element|
277
282
  state[config_element] = config[config_element] unless existing_state_value?(state, config_element)
278
283
  end
279
284
  state.delete(:password) unless instance.transport[:ssh_key].nil?
@@ -281,7 +286,7 @@ module Kitchen
281
286
  end
282
287
 
283
288
  def azure_resource_group_name
284
- formatted_time = Time.now.utc.strftime '%Y%m%dT%H%M%S'
289
+ formatted_time = Time.now.utc.strftime "%Y%m%dT%H%M%S"
285
290
  return "#{config[:azure_resource_group_prefix]}#{config[:azure_resource_group_name]}-#{formatted_time}#{config[:azure_resource_group_suffix]}" unless config[:explicit_resource_group_name]
286
291
  config[:explicit_resource_group_name]
287
292
  end
@@ -292,7 +297,7 @@ module Kitchen
292
297
 
293
298
  if config[:use_managed_disks]
294
299
  config[:data_disks].each do |data_disk|
295
- disks << { name: "datadisk#{data_disk[:lun]}", lun: data_disk[:lun], diskSizeGB: data_disk[:disk_size_gb], createOption: 'Empty' }
300
+ disks << { name: "datadisk#{data_disk[:lun]}", lun: data_disk[:lun], diskSizeGB: data_disk[:disk_size_gb], createOption: "Empty" }
296
301
  end
297
302
  debug "Additional disks being added to configuration: #{disks.inspect}"
298
303
  else
@@ -303,13 +308,13 @@ module Kitchen
303
308
 
304
309
  def template_for_transport_name
305
310
  template = JSON.parse(virtual_machine_deployment_template)
306
- if instance.transport.name.casecmp('winrm').zero?
307
- if instance.platform.name.index('nano').nil?
308
- info 'Adding WinRM configuration to provisioning profile.'
311
+ if instance.transport.name.casecmp("winrm") == 0
312
+ if instance.platform.name.index("nano").nil?
313
+ info "Adding WinRM configuration to provisioning profile."
309
314
  encoded_command = Base64.strict_encode64(custom_data_script_windows)
310
- template['resources'].select { |h| h['type'] == 'Microsoft.Compute/virtualMachines' }.each do |resource|
311
- resource['properties']['osProfile']['customData'] = encoded_command
312
- resource['properties']['osProfile']['windowsConfiguration'] = windows_unattend_content
315
+ template["resources"].select { |h| h["type"] == "Microsoft.Compute/virtualMachines" }.each do |resource|
316
+ resource["properties"]["osProfile"]["customData"] = encoded_command
317
+ resource["properties"]["osProfile"]["windowsConfiguration"] = windows_unattend_content
313
318
  end
314
319
  end
315
320
  end
@@ -317,8 +322,8 @@ module Kitchen
317
322
  unless instance.transport[:ssh_key].nil?
318
323
  info "Adding public key from #{File.expand_path(instance.transport[:ssh_key])}.pub to the deployment."
319
324
  public_key = public_key_for_deployment(File.expand_path(instance.transport[:ssh_key]))
320
- template['resources'].select { |h| h['type'] == 'Microsoft.Compute/virtualMachines' }.each do |resource|
321
- resource['properties']['osProfile']['linuxConfiguration'] = JSON.parse(custom_linux_configuration(public_key))
325
+ template["resources"].select { |h| h["type"] == "Microsoft.Compute/virtualMachines" }.each do |resource|
326
+ resource["properties"]["osProfile"]["linuxConfiguration"] = JSON.parse(custom_linux_configuration(public_key))
322
327
  end
323
328
  end
324
329
  template.to_json
@@ -330,12 +335,12 @@ module Kitchen
330
335
 
331
336
  ::FileUtils.mkdir_p(File.dirname(private_key_filename))
332
337
 
333
- private_key_file = File.new(private_key_filename, 'w')
338
+ private_key_file = File.new(private_key_filename, "w")
334
339
  private_key_file.syswrite(k.private_key)
335
340
  private_key_file.chmod(0600)
336
341
  private_key_file.close
337
342
 
338
- public_key_file = File.new("#{private_key_filename}.pub", 'w')
343
+ public_key_file = File.new("#{private_key_filename}.pub", "w")
339
344
  public_key_file.syswrite(k.ssh_public_key)
340
345
  public_key_file.chmod(0600)
341
346
  public_key_file.close
@@ -381,7 +386,7 @@ module Kitchen
381
386
  end
382
387
 
383
388
  def empty_deployment
384
- template = virtual_machine_deployment_template_file('empty.erb', nil)
389
+ template = virtual_machine_deployment_template_file("empty.erb", nil)
385
390
  empty_deployment = ::Azure::Resources::Profiles::Latest::Mgmt::Models::Deployment.new
386
391
  empty_deployment.properties = ::Azure::Resources::Profiles::Latest::Mgmt::Models::DeploymentProperties.new
387
392
  empty_deployment.properties.mode = ::Azure::Resources::Profiles::Latest::Mgmt::Models::DeploymentMode::Complete
@@ -391,7 +396,7 @@ module Kitchen
391
396
  end
392
397
 
393
398
  def vm_tag_string(vm_tags_in)
394
- tag_string = ''
399
+ tag_string = ""
395
400
  unless vm_tags_in.empty?
396
401
  tag_array = vm_tags_in.map do |key, value|
397
402
  "\"#{key}\": \"#{value}\",\n"
@@ -405,34 +410,34 @@ module Kitchen
405
410
 
406
411
  def parameters_in_values_format(parameters_in)
407
412
  parameters = parameters_in.map do |key, value|
408
- { key.to_sym => { 'value' => value } }
413
+ { key.to_sym => { "value" => value } }
409
414
  end
410
415
  parameters.reduce(:merge!)
411
416
  end
412
417
 
413
418
  def follow_deployment_until_end_state(resource_group, deployment_name)
414
- end_provisioning_states = 'Canceled,Failed,Deleted,Succeeded'
419
+ end_provisioning_states = "Canceled,Failed,Deleted,Succeeded"
415
420
  end_provisioning_state_reached = false
416
421
  until end_provisioning_state_reached
417
422
  list_outstanding_deployment_operations(resource_group, deployment_name)
418
423
  sleep 10
419
424
  deployment_provisioning_state = deployment_state(resource_group, deployment_name)
420
- end_provisioning_state_reached = end_provisioning_states.split(',').include?(deployment_provisioning_state)
425
+ end_provisioning_state_reached = end_provisioning_states.split(",").include?(deployment_provisioning_state)
421
426
  end
422
427
  info "Resource Template deployment reached end state of '#{deployment_provisioning_state}'."
423
- show_failed_operations(resource_group, deployment_name) if deployment_provisioning_state == 'Failed'
428
+ show_failed_operations(resource_group, deployment_name) if deployment_provisioning_state == "Failed"
424
429
  end
425
430
 
426
431
  def show_failed_operations(resource_group, deployment_name)
427
432
  failed_operations = resource_management_client.deployment_operations.list(resource_group, deployment_name)
428
433
  failed_operations.each do |val|
429
434
  resource_code = val.properties.status_code
430
- raise val.properties.status_message.inspect.to_s if resource_code != 'OK'
435
+ raise val.properties.status_message.inspect.to_s if resource_code != "OK"
431
436
  end
432
437
  end
433
438
 
434
439
  def list_outstanding_deployment_operations(resource_group, deployment_name)
435
- end_operation_states = 'Failed,Succeeded'
440
+ end_operation_states = "Failed,Succeeded"
436
441
  deployment_operations = resource_management_client.deployment_operations.list(resource_group, deployment_name)
437
442
  deployment_operations.each do |val|
438
443
  resource_provisioning_state = val.properties.provisioning_state
@@ -440,7 +445,7 @@ module Kitchen
440
445
  resource_name = val.properties.target_resource.resource_name
441
446
  resource_type = val.properties.target_resource.resource_type
442
447
  end
443
- end_operation_state_reached = end_operation_states.split(',').include?(resource_provisioning_state)
448
+ end_operation_state_reached = end_operation_states.split(",").include?(resource_provisioning_state)
444
449
  unless end_operation_state_reached
445
450
  info "Resource #{resource_type} '#{resource_name}' provisioning status is #{resource_provisioning_state}"
446
451
  end
@@ -457,7 +462,7 @@ module Kitchen
457
462
  options = Kitchen::Driver::Credentials.new.azure_options_for_subscription(state[:subscription_id], state[:azure_environment])
458
463
  @resource_management_client = ::Azure::Resources::Profiles::Latest::Mgmt::Client.new(options)
459
464
  if config[:destroy_resource_group_contents] == true
460
- info 'Destroying individual resources within the Resource Group.'
465
+ info "Destroying individual resources within the Resource Group."
461
466
  empty_deployment_name = "empty-deploy-#{state[:uuid]}"
462
467
  begin
463
468
  info "Creating deployment: #{empty_deployment_name}"
@@ -477,7 +482,7 @@ module Kitchen
477
482
  begin
478
483
  info "Destroying Resource Group: #{state[:azure_resource_group_name]}"
479
484
  resource_management_client.resource_groups.begin_delete(state[:azure_resource_group_name])
480
- info 'Destroy operation accepted and will continue in the background.'
485
+ info "Destroy operation accepted and will continue in the background."
481
486
  rescue ::MsRestAzure::AzureOperationError => operation_error
482
487
  error operation_error.body
483
488
  raise operation_error
@@ -503,7 +508,7 @@ module Kitchen
503
508
 
504
509
  def format_data_disks_powershell_script
505
510
  return unless config[:format_data_disks]
506
- info 'Data disks will be initialized and formatted NTFS automatically.' unless config[:data_disks].nil?
511
+ info "Data disks will be initialized and formatted NTFS automatically." unless config[:data_disks].nil?
507
512
  config[:format_data_disks_powershell_script] ||
508
513
  <<-PS1
509
514
  Write-Host "Initializing and formatting raw disks"
@@ -559,45 +564,45 @@ module Kitchen
559
564
  {
560
565
  additionalUnattendContent: [
561
566
  {
562
- passName: 'oobeSystem',
563
- componentName: 'Microsoft-Windows-Shell-Setup',
564
- settingName: 'FirstLogonCommands',
565
- content: '<FirstLogonCommands><SynchronousCommand><CommandLine>cmd /c "copy C:\\AzureData\\CustomData.bin C:\\Config.ps1"</CommandLine><Description>copy</Description><Order>1</Order></SynchronousCommand><SynchronousCommand><CommandLine>%windir%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -ExecutionPolicy Bypass -file C:\\Config.ps1</CommandLine><Description>script</Description><Order>2</Order></SynchronousCommand></FirstLogonCommands>'
567
+ passName: "oobeSystem",
568
+ componentName: "Microsoft-Windows-Shell-Setup",
569
+ settingName: "FirstLogonCommands",
570
+ content: '<FirstLogonCommands><SynchronousCommand><CommandLine>cmd /c "copy C:\\AzureData\\CustomData.bin C:\\Config.ps1"</CommandLine><Description>copy</Description><Order>1</Order></SynchronousCommand><SynchronousCommand><CommandLine>%windir%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -ExecutionPolicy Bypass -file C:\\Config.ps1</CommandLine><Description>script</Description><Order>2</Order></SynchronousCommand></FirstLogonCommands>',
566
571
  },
567
572
  {
568
- passName: 'oobeSystem',
569
- componentName: 'Microsoft-Windows-Shell-Setup',
570
- settingName: 'AutoLogon',
571
- content: "[concat('<AutoLogon><Password><Value>', parameters('adminPassword'), '</Value></Password><Enabled>true</Enabled><LogonCount>1</LogonCount><Username>', parameters('adminUserName'), '</Username></AutoLogon>')]"
573
+ passName: "oobeSystem",
574
+ componentName: "Microsoft-Windows-Shell-Setup",
575
+ settingName: "AutoLogon",
576
+ content: "[concat('<AutoLogon><Password><Value>', parameters('adminPassword'), '</Value></Password><Enabled>true</Enabled><LogonCount>1</LogonCount><Username>', parameters('adminUserName'), '</Username></AutoLogon>')]",
572
577
  }
573
- ]
578
+ ],
574
579
  }
575
580
  end
576
581
 
577
582
  def virtual_machine_deployment_template
578
- if config[:vnet_id] == ''
579
- virtual_machine_deployment_template_file('public.erb', vm_tags: vm_tag_string(config[:vm_tags]), use_managed_disks: config[:use_managed_disks], image_url: config[:image_url], existing_storage_account_blob_url: config[:existing_storage_account_blob_url], image_id: config[:image_id], existing_storage_account_container: config[:existing_storage_account_container], custom_data: config[:custom_data], os_disk_size_gb: config[:os_disk_size_gb], data_disks_for_vm_json: data_disks_for_vm_json)
583
+ if config[:vnet_id] == ""
584
+ virtual_machine_deployment_template_file("public.erb", vm_tags: vm_tag_string(config[:vm_tags]), use_managed_disks: config[:use_managed_disks], image_url: config[:image_url], existing_storage_account_blob_url: config[:existing_storage_account_blob_url], image_id: config[:image_id], existing_storage_account_container: config[:existing_storage_account_container], custom_data: config[:custom_data], os_disk_size_gb: config[:os_disk_size_gb], data_disks_for_vm_json: data_disks_for_vm_json)
580
585
  else
581
586
  info "Using custom vnet: #{config[:vnet_id]}"
582
- virtual_machine_deployment_template_file('internal.erb', vnet_id: config[:vnet_id], subnet_id: config[:subnet_id], public_ip: config[:public_ip], vm_tags: vm_tag_string(config[:vm_tags]), use_managed_disks: config[:use_managed_disks], image_url: config[:image_url], existing_storage_account_blob_url: config[:existing_storage_account_blob_url], image_id: config[:image_id], existing_storage_account_container: config[:existing_storage_account_container], custom_data: config[:custom_data], os_disk_size_gb: config[:os_disk_size_gb], data_disks_for_vm_json: data_disks_for_vm_json)
587
+ virtual_machine_deployment_template_file("internal.erb", vnet_id: config[:vnet_id], subnet_id: config[:subnet_id], public_ip: config[:public_ip], vm_tags: vm_tag_string(config[:vm_tags]), use_managed_disks: config[:use_managed_disks], image_url: config[:image_url], existing_storage_account_blob_url: config[:existing_storage_account_blob_url], image_id: config[:image_id], existing_storage_account_container: config[:existing_storage_account_container], custom_data: config[:custom_data], os_disk_size_gb: config[:os_disk_size_gb], data_disks_for_vm_json: data_disks_for_vm_json)
583
588
  end
584
589
  end
585
590
 
586
591
  def virtual_machine_deployment_template_file(template_file, data = {})
587
- template = File.read(File.expand_path(File.join(__dir__, '../../../templates', template_file)))
592
+ template = File.read(File.expand_path(File.join(__dir__, "../../../templates", template_file)))
588
593
  render_binding = OpenStruct.new(data)
589
- ERB.new(template, nil, '-').result(render_binding.instance_eval { binding })
594
+ ERB.new(template, nil, "-").result(render_binding.instance_eval { binding })
590
595
  end
591
596
 
592
597
  def resource_manager_endpoint_url(azure_environment)
593
598
  case azure_environment.downcase
594
- when 'azureusgovernment'
599
+ when "azureusgovernment"
595
600
  MsRestAzure::AzureEnvironments::AzureUSGovernment.resource_manager_endpoint_url
596
- when 'azurechina'
601
+ when "azurechina"
597
602
  MsRestAzure::AzureEnvironments::AzureChinaCloud.resource_manager_endpoint_url
598
- when 'azuregermancloud'
603
+ when "azuregermancloud"
599
604
  MsRestAzure::AzureEnvironments::AzureGermanCloud.resource_manager_endpoint_url
600
- when 'azure'
605
+ when "azure"
601
606
  MsRestAzure::AzureEnvironments::AzureCloud.resource_manager_endpoint_url
602
607
  end
603
608
  end
@@ -1,4 +1,4 @@
1
- require 'inifile'
1
+ require "inifile"
2
2
 
3
3
  module Kitchen
4
4
  module Driver
@@ -12,7 +12,7 @@ module Kitchen
12
12
  # Creates and initializes a new instance of the Credentials class.
13
13
  #
14
14
  def initialize
15
- config_file = ENV['AZURE_CONFIG_FILE'] || File.expand_path(CONFIG_PATH)
15
+ config_file = ENV["AZURE_CONFIG_FILE"] || File.expand_path(CONFIG_PATH)
16
16
  if File.file?(config_file)
17
17
  @credentials = IniFile.load(File.expand_path(config_file))
18
18
  else
@@ -29,10 +29,10 @@ module Kitchen
29
29
  #
30
30
  # @return [Object] Object that can be supplied along with all Azure client requests.
31
31
  #
32
- def azure_options_for_subscription(subscription_id, azure_environment = 'Azure')
33
- tenant_id = ENV['AZURE_TENANT_ID'] || @credentials[subscription_id]['tenant_id']
34
- client_id = ENV['AZURE_CLIENT_ID'] || @credentials[subscription_id]['client_id']
35
- client_secret = ENV['AZURE_CLIENT_SECRET'] || @credentials[subscription_id]['client_secret']
32
+ def azure_options_for_subscription(subscription_id, azure_environment = "Azure")
33
+ tenant_id = ENV["AZURE_TENANT_ID"] || @credentials[subscription_id]["tenant_id"]
34
+ client_id = ENV["AZURE_CLIENT_ID"] || @credentials[subscription_id]["client_id"]
35
+ client_secret = ENV["AZURE_CLIENT_SECRET"] || @credentials[subscription_id]["client_secret"]
36
36
  token_provider = ::MsRestAzure::ApplicationTokenProvider.new(tenant_id, client_id, client_secret, ad_settings_for_azure_environment(azure_environment))
37
37
  options = { tenant_id: tenant_id,
38
38
  client_id: client_id,
@@ -52,13 +52,13 @@ module Kitchen
52
52
  #
53
53
  def ad_settings_for_azure_environment(azure_environment)
54
54
  case azure_environment.downcase
55
- when 'azureusgovernment'
55
+ when "azureusgovernment"
56
56
  ::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_us_government_settings
57
- when 'azurechina'
57
+ when "azurechina"
58
58
  ::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_china_settings
59
- when 'azuregermancloud'
59
+ when "azuregermancloud"
60
60
  ::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_german_settings
61
- when 'azure'
61
+ when "azure"
62
62
  ::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_settings
63
63
  end
64
64
  end
@@ -71,13 +71,13 @@ module Kitchen
71
71
  #
72
72
  def endpoint_settings_for_azure_environment(azure_environment)
73
73
  case azure_environment.downcase
74
- when 'azureusgovernment'
74
+ when "azureusgovernment"
75
75
  ::MsRestAzure::AzureEnvironments::AzureUSGovernment
76
- when 'azurechina'
76
+ when "azurechina"
77
77
  ::MsRestAzure::AzureEnvironments::AzureChinaCloud
78
- when 'azuregermancloud'
78
+ when "azuregermancloud"
79
79
  ::MsRestAzure::AzureEnvironments::AzureGermanCloud
80
- when 'azure'
80
+ when "azure"
81
81
  ::MsRestAzure::AzureEnvironments::AzureCloud
82
82
  end
83
83
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-azurerm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.5
4
+ version: 0.14.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Preston
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-30 00:00:00.000000000 Z
11
+ date: 2018-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: azure_mgmt_network
@@ -16,40 +16,40 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.15'
20
- - - ">="
19
+ version: '0.18'
20
+ - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.15.0
22
+ version: 0.18.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '0.15'
30
- - - ">="
29
+ version: '0.18'
30
+ - - '='
31
31
  - !ruby/object:Gem::Version
32
- version: 0.15.0
32
+ version: 0.18.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: azure_mgmt_resources
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.15'
40
- - - ">="
39
+ version: '0.17'
40
+ - - '='
41
41
  - !ruby/object:Gem::Version
42
- version: 0.15.0
42
+ version: 0.17.2
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '0.15'
50
- - - ">="
49
+ version: '0.17'
50
+ - - '='
51
51
  - !ruby/object:Gem::Version
52
- version: 0.15.0
52
+ version: 0.17.2
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: inifile
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -108,36 +108,30 @@ dependencies:
108
108
  name: rake
109
109
  requirement: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - "~>"
111
+ - - ">="
112
112
  - !ruby/object:Gem::Version
113
113
  version: '11.0'
114
114
  type: :development
115
115
  prerelease: false
116
116
  version_requirements: !ruby/object:Gem::Requirement
117
117
  requirements:
118
- - - "~>"
118
+ - - ">="
119
119
  - !ruby/object:Gem::Version
120
120
  version: '11.0'
121
121
  - !ruby/object:Gem::Dependency
122
- name: rubocop
122
+ name: chefstyle
123
123
  requirement: !ruby/object:Gem::Requirement
124
124
  requirements:
125
- - - "~>"
126
- - !ruby/object:Gem::Version
127
- version: '0.58'
128
125
  - - ">="
129
126
  - !ruby/object:Gem::Version
130
- version: 0.58.1
127
+ version: '0'
131
128
  type: :development
132
129
  prerelease: false
133
130
  version_requirements: !ruby/object:Gem::Requirement
134
131
  requirements:
135
- - - "~>"
136
- - !ruby/object:Gem::Version
137
- version: '0.58'
138
132
  - - ">="
139
133
  - !ruby/object:Gem::Version
140
- version: 0.58.1
134
+ version: '0'
141
135
  description: Test Kitchen driver for the Microsoft Azure Resource Manager (ARM) API
142
136
  email:
143
137
  - stuart@chef.io
@@ -145,7 +139,6 @@ executables: []
145
139
  extensions: []
146
140
  extra_rdoc_files: []
147
141
  files:
148
- - CHANGELOG.md
149
142
  - LICENSE
150
143
  - README.md
151
144
  - lib/kitchen/driver/azurerm.rb
data/CHANGELOG.md DELETED
@@ -1,129 +0,0 @@
1
- # kitchen-azurerm Changelog
2
-
3
- ## [0.14.5] - 2018-09-30
4
- - Support Shared Image Gallery (preview Azure feature) (@zanecodes)
5
-
6
- ## [0.14.4] - 2018-08-10
7
- - Adding capability to execute ARM template after VM deployment, ```post_deployment_template``` and ```post_deployment_parameters``` added (@sebastiankasprzak)
8
-
9
- ## [0.14.3] - 2018-07-16
10
- - Add `destroy_resource_group_contents` (default: false) property to allow contents of Azure Resource Group to be deleted rather than entire Resource Group, fixes [#90](https://github.com/test-kitchen/kitchen-azurerm/issues/85)
11
-
12
- ## [0.14.2] - 2018-07-09
13
- - Add `destroy_explicit_resource_group` (default: false) property to allow reuse of specific Azure RG, fixes [#85](https://github.com/test-kitchen/kitchen-azurerm/issues/85)
14
-
15
- ## [0.14.1] - 2018-05-10
16
- - Support for soverign clouds with latest Azure SDK for Ruby, fixes [#79](https://github.com/test-kitchen/kitchen-azurerm/issues/79)
17
- - Raise error when subscription_id is not available, fixes [#74](https://github.com/test-kitchen/kitchen-azurerm/issues/74)
18
-
19
- ## [0.14.0] - 2018-04-10
20
- - Update Azure SDK to latest version, upgrade to latest build tools
21
-
22
- ## [0.13.0] - 2017-12-26
23
- - Switch to new Microsoft telemetry system [#73](https://github.com/test-kitchen/kitchen-azurerm/issues/73)
24
-
25
- ## [0.12.4] - 2017-11-17
26
- - Adding `explicit_resource_group_name` property to driver configuration
27
-
28
- ## [0.12.3] - 2017-10-18
29
- - Pinning to version 0.14.0 of Microsoft Azure SDK for Ruby, avoid namespace changes
30
-
31
- ## [0.12.2] - 2017-09-20
32
- - Fix issue with location of data_disks in internal.erb [#67](https://github.com/test-kitchen/kitchen-azurerm/pull/67https://github.com/test-kitchen/kitchen-azurerm/pull/67) (@ehanlon)
33
-
34
- ## [0.12.1] - 2017-09-10
35
- - Fix for undefined local variable when using pre_deployment_template [#65](https://github.com/test-kitchen/kitchen-azurerm/issue/65)
36
-
37
- ## [0.12.0] - 2017-09-01
38
- - Additional managed disks can be specified in configuration and left unformatted or formatted on Windows(@stuartpreston)
39
- - Added `azure_resource_group_prefix` and `azure_resource_group_suffix` parameter (@stuartpreston)
40
-
41
- ## [0.11.0] - 2017-07-20
42
- - Pin to latest ARM SDK and constants [#59](https://github.com/test-kitchen/kitchen-azurerm/pull/59) (@smurawski)
43
-
44
- ## [0.10.0] - 2017-07-03
45
- - Support for custom images (@elconas)
46
- - Support for custom-data (Linux only) (@elconas)
47
- - Support for custom OS sizes (@elconas)
48
-
49
- ## [0.9.1] - 2017-05-25
50
- - Support for Managed Disks enabled by default (@stuartpreston)
51
- - Add ```use_managed_disks``` driver_config parameter (@stuartpreston)
52
-
53
- ## [0.9.0] - 2017-04-28
54
- - Support for AzureUSGovernment, AzureChina and AzureGermanCloud environments
55
- - Add ```azure_environment``` driver_config parameter (@stuartpreston)
56
-
57
- ## [0.8.1] - 2017-02-28
58
- - Adding provider identifier tag to all created resources (@stuartpreston)
59
-
60
- ## [0.8.0] - 2017-01-16
61
- - [Unattend.xml used instead of Custom Script Extension to inject WinRM configuration/AKA support proxy server configurations](https://github.com/pendrica/kitchen-azurerm/pull/44) (@hbuckle)
62
- - [Public IP addresses can now be used to connect even if the VM is connected to an existing subnet](https://github.com/pendrica/kitchen-azurerm/pull/42) (@vlesierse)
63
- - [Resource Tags can now be applied to the created VMsPR](https://github.com/pendrica/kitchen-azurerm/pull/38) (@liamkirwan)
64
-
65
- ## [0.7.2] - 2016-11-03
66
- - Bug: When repeating a completed deployment, deployment would fail with a nil error on resource_name (@stuartpreston)
67
-
68
- ## [0.7.1] - 2016-09-17
69
- - Bug: WinRM is not enabled where the platform name does not contain 'nano' (@stuartpreston)
70
-
71
- ## [0.7.0] - 2016-09-15
72
- - Support creation of Windows Nano Server (ignoring automatic WinRM setting application) (@stuartpreston)
73
-
74
- ## [0.6.0] - 2016-08-22
75
- - Supports latest autogenerated resources from Azure SDK for Ruby (0.5.0) (@stuartpreston)
76
- - Removes unnecessary direct depdendencies on older ms_rest libraries (@stuartpreston)
77
- - ssh_key will be used in preference to password if both are supplied (@stuartpreston)
78
-
79
- ## [0.5.0] - 2016-08-07
80
- - Adding support for internal (e.g. ExpressRoute/VPN) access to created VM (@stuartpreston)
81
-
82
- ## [0.4.1] - 2016-07-01
83
- - Adding explicit depdendency on concurrent-ruby gem (@stuartpreston)
84
-
85
- ## [0.4.0] - 2016-06-26
86
- - Adding capability to execute ARM template prior to VM deployment, ```pre_deployment_template``` and ```pre_deployment_parameters``` added (@stuartpreston)
87
-
88
- ## [0.3.6] - 2016-05-10
89
- - Remove version pin on inifile gem dependency, compatible with newer ChefDK (@stuartpreston)
90
-
91
- ## [0.3.5] - 2016-03-21
92
- - Remove transport name restriction on SSH key upload (allow rsync support) (@stuartpreston)
93
- - Support SSH public keys with newlines as generated by ssh-keygen (@stuartpreston)
94
-
95
- ## [0.3.4] - 2016-03-19
96
- - Additional diagnostics when Azure Resource Group fails to create successfully (@stuartpreston)
97
-
98
- ## [0.3.3] - 2016-03-07
99
- - Pinning ms_rest_azure dependencies to avoid errors when using latest ms_rest_azure library (@stuartpreston)
100
-
101
- ## [0.3.2] - 2016-03-07
102
- - Breaking: Linux machines are now created using a temporary sshkey (~/.ssh/id_kitchen-azurerm) instead of password (@stuartpreston)
103
- - Real error message shown if credentials are incorrect (@stuartpreston)
104
-
105
- ## [0.2.4] - 2016-01-26
106
- - Support Premium Storage and Boot Diagnostics (@stuartpreston)
107
- - If deployment fails, show the message from the failing operation (@stuartpreston)
108
- - Updated Windows 2008 R2 example (@stuartpreston)
109
-
110
- ## [0.2.3] - 2015-12-17
111
- - ```kitchen create``` can now be executed multiple times, updating an existing deployment if an error occurs (@smurawski)
112
-
113
- ## [0.2.2] - 2015-12-10
114
- - Add an option for users to specify a custom script for WinRM (support Windows 2008 R2) (@andrewelizondo)
115
- - Add azure_management_url parameter for Azure Stack support (@andrewelizondo)
116
-
117
- ## [0.2.1] - 2015-10-06
118
- - Pointing to updated Azure SDK for Ruby, supports Linux
119
-
120
- ## [0.2.0] - 2015-09-29
121
- - Logs should be sent to info, not stdout (@stuartpreston)
122
- - Added WinRM support, enables WinRM and WinRM/s and configures server for Basic/Negotiate authentication (@stuartpreston)
123
- - Store server_id earlier so it can be retrieved if resources fail to create in Azure (@stuartpreston)
124
-
125
- ## [0.1.3] - 2015-09-23
126
- - Support *nix by changing the driver name to lowercase 'azurerm', remove Chef references (@gadgetmg)
127
-
128
- ## [0.1.2] - 2015-09-23
129
- - Initial release, supports provision of all public image types in Azure (@stuartpreston)