kitchen-azurerm 0.7.2 → 0.8.0

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
  SHA1:
3
- metadata.gz: 902ca908848a5eb2cad80be658cf595a20c2410d
4
- data.tar.gz: 4fc62716438e52d4fa77a0a230395eeee85cdabc
3
+ metadata.gz: 8bdf1db7e77250e108907f1a40b0d84d08616a99
4
+ data.tar.gz: 4852f16314f228cd1f244bb037bb59f9598d5bbd
5
5
  SHA512:
6
- metadata.gz: 5dd19bda00f9a9554900c5be73bf1f7da044350281950f5477a6a4009f7a18b5784e01ec4347c8c7a96e75176eb74f7d429a67792a275f640c8c3dc008aef3a6
7
- data.tar.gz: 182b6c01b0bb5e94269d3d734ce93213fe7d650a8b3b5a4337dcd78b6142593b864673591b3f77f1d867496268cc1a5ba5650c73227328d3a076b0b4d4d16ca1
6
+ metadata.gz: 8fd391130fdbae24c08acd39e2756c15b2e7bcb0c730d5cfccf00f2043d02fa0a015d461d5acfe4aa1e9cbc90930f8deafd58d8a35876b9ccecb9d2c620bd8c3
7
+ data.tar.gz: 017185e55b0dc46478343af727d1e0bb04b7ec01de3fbdd276c8ba802847b3eb73df548049bc5d9f347af6aeba416e9da0970c50bf25da6ea312f82b9005504c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # kitchen-azurerm Changelog
2
2
 
3
+ ## [0.8.0] - 2017-01-16
4
+ - [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)
5
+ - [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)
6
+ - [Resource Tags can now be applied to the created VMsPR](https://github.com/pendrica/kitchen-azurerm/pull/38) (@liamkirwan)
7
+
3
8
  ## [0.7.2] - 2016-11-03
4
9
  - Bug: When repeating a completed deployment, deployment would fail with a nil error on resource_name (@stuartpreston)
5
10
 
data/LICENSE CHANGED
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright {yyyy} {name of copyright owner}
189
+ Copyright 2017 Pendrica Ltd.
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
data/README.md CHANGED
@@ -71,6 +71,9 @@ platforms:
71
71
  driver_config:
72
72
  image_urn: Canonical:UbuntuServer:14.04.4-LTS:latest
73
73
  vm_name: trusty-vm
74
+ vm_tags:
75
+ ostype: linux
76
+ distro: ubuntu
74
77
 
75
78
  suites:
76
79
  - name: default
@@ -210,7 +213,7 @@ Example predeploy.json:
210
213
  The following example introduces the ```vnet_id``` and ```subnet_id``` properties under driver_config in the configuration file. This can be applied at the top level, or per platform.
211
214
  You can use this capability to create the VM on an existing virtual network and subnet created in a different resource group.
212
215
 
213
- In this case, the public IP address is not used.
216
+ In this case, the public IP address is not used unless ```public_ip``` is set to ```true```
214
217
 
215
218
 
216
219
  ```yaml
@@ -281,6 +284,7 @@ info: vm image list command OK
281
284
  - Note that the ```driver_config``` section also takes a ```username``` and ```password``` parameter, the defaults if these are not specified are "azure" and "P2ssw0rd" respectively.
282
285
  - The ```storage_account_type``` parameter defaults to 'Standard_LRS' and allows you to switch to premium storage (e.g. 'Premium_LRS')
283
286
  - The ```enable_boot_diagnostics``` parameter defaults to 'true' and allows you to switch off boot diagnostics in case you are using premium storage.
287
+ - The optional ```vm_tags``` parameter allows you to define key:value pairs to tag VMs with on creation.
284
288
 
285
289
  ## Contributing
286
290
 
@@ -6,6 +6,7 @@ require 'azure_mgmt_network'
6
6
  require 'base64'
7
7
  require 'sshkey'
8
8
  require 'fileutils'
9
+ require 'erb'
9
10
 
10
11
  module Kitchen
11
12
  module Driver
@@ -67,6 +68,14 @@ module Kitchen
67
68
  {}
68
69
  end
69
70
 
71
+ default_config(:vm_tags) do |_config|
72
+ {}
73
+ end
74
+
75
+ default_config(:public_ip) do |_config|
76
+ false
77
+ end
78
+
70
79
  def create(state)
71
80
  state = validate_state(state)
72
81
  image_publisher, image_offer, image_sku, image_version = config[:image_urn].split(':', 4)
@@ -127,7 +136,7 @@ module Kitchen
127
136
  # Monitor all operations until completion
128
137
  follow_deployment_until_end_state(state[:azure_resource_group_name], deployment_name)
129
138
 
130
- if config[:vnet_id] == ''
139
+ if config[:vnet_id] == '' || config[:public_ip]
131
140
  # Retrieve the public IP from the resource group:
132
141
  network_management_client = ::Azure::ARM::Network::NetworkManagementClient.new(credentials)
133
142
  network_management_client.subscription_id = config[:subscription_id]
@@ -171,11 +180,10 @@ module Kitchen
171
180
  if instance.platform.name.index('nano').nil?
172
181
  info 'Adding WinRM configuration to provisioning profile.'
173
182
  encoded_command = Base64.strict_encode64(enable_winrm_powershell_script)
174
- command = command_to_execute
175
183
  template['resources'].select { |h| h['type'] == 'Microsoft.Compute/virtualMachines' }.each do |resource|
176
184
  resource['properties']['osProfile']['customData'] = encoded_command
185
+ resource['properties']['osProfile']['windowsConfiguration'] = windows_unattend_content
177
186
  end
178
- template['resources'] << JSON.parse(custom_script_extension_template(command))
179
187
  end
180
188
  end
181
189
 
@@ -234,6 +242,19 @@ module Kitchen
234
242
  deployment
235
243
  end
236
244
 
245
+ def vm_tag_string(vm_tags_in)
246
+ tag_string = ''
247
+ unless vm_tags_in.empty?
248
+ tag_array = vm_tags_in.map do |key, value|
249
+ "\"#{key}\": \"#{value}\",\n"
250
+ end
251
+ # Strip punctuation from last item
252
+ tag_array[-1] = tag_array[-1][0..-3]
253
+ tag_string = tag_array.join
254
+ end
255
+ tag_string
256
+ end
257
+
237
258
  def parameters_in_values_format(parameters_in)
238
259
  parameters = parameters_in.map do |key, value|
239
260
  { key.to_sym => { 'value' => value } }
@@ -311,13 +332,10 @@ winrm set winrm/config/service/auth '@{Basic="true";Kerberos="false";Negotiate="
311
332
  New-NetFirewallRule -DisplayName "Windows Remote Management (HTTPS-In)" -Name "Windows Remote Management (HTTPS-In)" -Profile Any -LocalPort 5986 -Protocol TCP
312
333
  winrm set winrm/config/service '@{AllowUnencrypted="true"}'
313
334
  New-NetFirewallRule -DisplayName "Windows Remote Management (HTTP-In)" -Name "Windows Remote Management (HTTP-In)" -Profile Any -LocalPort 5985 -Protocol TCP
335
+ logoff
314
336
  PS1
315
337
  end
316
338
 
317
- def command_to_execute
318
- 'copy /y c:\\\\azuredata\\\\customdata.bin c:\\\\azuredata\\\\customdata.ps1 && powershell.exe -ExecutionPolicy Unrestricted -Command \\"start-process powershell.exe -verb runas -argumentlist c:\\\\azuredata\\\\customdata.ps1\\"'
319
- end
320
-
321
339
  def custom_linux_configuration(public_key)
322
340
  <<-EOH
323
341
  {
@@ -334,459 +352,39 @@ New-NetFirewallRule -DisplayName "Windows Remote Management (HTTP-In)" -Name "Wi
334
352
  EOH
335
353
  end
336
354
 
337
- def custom_script_extension_template(command)
338
- <<-EOH
355
+ def windows_unattend_content
339
356
  {
340
- "type": "Microsoft.Compute/virtualMachines/extensions",
341
- "name": "[concat(variables('vmName'),'/','enableWinRM')]",
342
- "apiVersion": "2015-05-01-preview",
343
- "location": "[variables('location')]",
344
- "dependsOn": [
345
- "[concat('Microsoft.Compute/virtualMachines/',variables('vmName'))]"
346
- ],
347
- "properties": {
348
- "publisher": "Microsoft.Compute",
349
- "type": "CustomScriptExtension",
350
- "typeHandlerVersion": "1.4",
351
- "settings": {
352
- "commandToExecute": "#{command}"
353
- }
354
- }
357
+ additionalUnattendContent: [
358
+ {
359
+ passName: 'oobeSystem',
360
+ componentName: 'Microsoft-Windows-Shell-Setup',
361
+ settingName: 'FirstLogonCommands',
362
+ 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>'
363
+ },
364
+ {
365
+ passName: 'oobeSystem',
366
+ componentName: 'Microsoft-Windows-Shell-Setup',
367
+ settingName: 'AutoLogon',
368
+ content: "[concat('<AutoLogon><Password><Value>', parameters('adminPassword'), '</Value></Password><Enabled>true</Enabled><LogonCount>1</LogonCount><Username>', parameters('adminUserName'), '</Username></AutoLogon>')]"
369
+ }
370
+ ]
355
371
  }
356
- EOH
357
372
  end
358
373
 
359
374
  def virtual_machine_deployment_template
360
375
  if config[:vnet_id] == ''
361
- virtual_machine_deployment_template_public
376
+ virtual_machine_deployment_template_file('public.erb', vm_tags: vm_tag_string(config[:vm_tags]))
362
377
  else
363
378
  info "Using custom vnet: #{config[:vnet_id]}"
364
- virtual_machine_deployment_template_internal(config[:vnet_id], config[:subnet_id])
379
+ 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]))
365
380
  end
366
381
  end
367
382
 
368
- def virtual_machine_deployment_template_internal(vnet_id, subnet_id)
369
- <<-EOH
370
- {
371
- "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
372
- "contentVersion": "1.0.0.0",
373
- "parameters": {
374
- "location": {
375
- "type": "string",
376
- "metadata": {
377
- "description": "The location where the resources will be created."
378
- }
379
- },
380
- "vmSize": {
381
- "type": "string",
382
- "metadata": {
383
- "description": "The size of the VM to be created"
384
- }
385
- },
386
- "newStorageAccountName": {
387
- "type": "string",
388
- "metadata": {
389
- "description": "Unique DNS Name for the Storage Account where the Virtual Machine's disks will be placed."
390
- }
391
- },
392
- "adminUsername": {
393
- "type": "string",
394
- "metadata": {
395
- "description": "User name for the Virtual Machine."
396
- }
397
- },
398
- "adminPassword": {
399
- "type": "securestring",
400
- "metadata": {
401
- "description": "Password for the Virtual Machine."
402
- }
403
- },
404
- "dnsNameForPublicIP": {
405
- "type": "string",
406
- "metadata": {
407
- "description": "Unique DNS Name for the Public IP used to access the Virtual Machine."
408
- }
409
- },
410
- "imagePublisher": {
411
- "type": "string",
412
- "defaultValue": "Canonical",
413
- "metadata": {
414
- "description": "Publisher for the VM, e.g. Canonical, MicrosoftWindowsServer"
415
- }
416
- },
417
- "imageOffer": {
418
- "type": "string",
419
- "defaultValue": "UbuntuServer",
420
- "metadata": {
421
- "description": "Offer for the VM, e.g. UbuntuServer, WindowsServer."
422
- }
423
- },
424
- "imageSku": {
425
- "type": "string",
426
- "defaultValue": "14.04.3-LTS",
427
- "metadata": {
428
- "description": "Sku for the VM, e.g. 14.04.3-LTS"
429
- }
430
- },
431
- "imageVersion": {
432
- "type": "string",
433
- "defaultValue": "latest",
434
- "metadata": {
435
- "description": "Either a date or latest."
436
- }
437
- },
438
- "vmName": {
439
- "type": "string",
440
- "defaultValue": "vm",
441
- "metadata": {
442
- "description": "The vm name created inside of the resource group."
443
- }
444
- },
445
- "storageAccountType": {
446
- "type": "string",
447
- "defaultValue": "Standard_LRS",
448
- "metadata": {
449
- "description": "The type of storage to use (e.g. Standard_LRS or Premium_LRS)."
450
- }
451
- },
452
- "bootDiagnosticsEnabled": {
453
- "type": "string",
454
- "defaultValue": "true",
455
- "metadata": {
456
- "description": "Whether to enable (true) or disable (false) boot diagnostics. Default: true (requires Standard storage)."
457
- }
458
- }
459
- },
460
- "variables": {
461
- "location": "[parameters('location')]",
462
- "OSDiskName": "osdisk",
463
- "nicName": "nic",
464
- "addressPrefix": "10.0.0.0/16",
465
- "subnetName": "#{subnet_id}",
466
- "subnetPrefix": "10.0.0.0/24",
467
- "storageAccountType": "[parameters('storageAccountType')]",
468
- "publicIPAddressName": "publicip",
469
- "publicIPAddressType": "Dynamic",
470
- "vmStorageAccountContainerName": "vhds",
471
- "vmName": "[parameters('vmName')]",
472
- "vmSize": "[parameters('vmSize')]",
473
- "virtualNetworkName": "vnet",
474
- "vnetID": "#{vnet_id}",
475
- "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]"
476
- },
477
- "resources": [
478
- {
479
- "type": "Microsoft.Storage/storageAccounts",
480
- "name": "[parameters('newStorageAccountName')]",
481
- "apiVersion": "2015-05-01-preview",
482
- "location": "[variables('location')]",
483
- "properties": {
484
- "accountType": "[variables('storageAccountType')]"
485
- }
486
- },
487
- {
488
- "apiVersion": "2015-05-01-preview",
489
- "type": "Microsoft.Network/networkInterfaces",
490
- "name": "[variables('nicName')]",
491
- "location": "[variables('location')]",
492
- "properties": {
493
- "ipConfigurations": [
494
- {
495
- "name": "ipconfig1",
496
- "properties": {
497
- "privateIPAllocationMethod": "Dynamic",
498
- "subnet": {
499
- "id": "[variables('subnetRef')]"
500
- }
501
- }
502
- }
503
- ]
504
- }
505
- },
506
- {
507
- "apiVersion": "2015-06-15",
508
- "type": "Microsoft.Compute/virtualMachines",
509
- "name": "[variables('vmName')]",
510
- "location": "[variables('location')]",
511
- "dependsOn": [
512
- "[concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName'))]",
513
- "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
514
- ],
515
- "properties": {
516
- "hardwareProfile": {
517
- "vmSize": "[variables('vmSize')]"
518
- },
519
- "osProfile": {
520
- "computername": "[variables('vmName')]",
521
- "adminUsername": "[parameters('adminUsername')]",
522
- "adminPassword": "[parameters('adminPassword')]"
523
- },
524
- "storageProfile": {
525
- "imageReference": {
526
- "publisher": "[parameters('imagePublisher')]",
527
- "offer": "[parameters('imageOffer')]",
528
- "sku": "[parameters('imageSku')]",
529
- "version": "[parameters('imageVersion')]"
530
- },
531
- "osDisk": {
532
- "name": "osdisk",
533
- "vhd": {
534
- "uri": "[concat('http://',parameters('newStorageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('OSDiskName'),'.vhd')]"
535
- },
536
- "caching": "ReadWrite",
537
- "createOption": "FromImage"
538
- }
539
- },
540
- "networkProfile": {
541
- "networkInterfaces": [
542
- {
543
- "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
544
- }
545
- ]
546
- },
547
- "diagnosticsProfile": {
548
- "bootDiagnostics": {
549
- "enabled": "[parameters('bootDiagnosticsEnabled')]",
550
- "storageUri": "[concat('http://',parameters('newStorageAccountName'),'.blob.core.windows.net')]"
551
- }
552
- }
553
- }
554
- }
555
- ]
556
- }
557
- EOH
558
- end
559
-
560
- def virtual_machine_deployment_template_public
561
- <<-EOH
562
- {
563
- "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
564
- "contentVersion": "1.0.0.0",
565
- "parameters": {
566
- "location": {
567
- "type": "string",
568
- "metadata": {
569
- "description": "The location where the resources will be created."
570
- }
571
- },
572
- "vmSize": {
573
- "type": "string",
574
- "metadata": {
575
- "description": "The size of the VM to be created"
576
- }
577
- },
578
- "newStorageAccountName": {
579
- "type": "string",
580
- "metadata": {
581
- "description": "Unique DNS Name for the Storage Account where the Virtual Machine's disks will be placed."
582
- }
583
- },
584
- "adminUsername": {
585
- "type": "string",
586
- "metadata": {
587
- "description": "User name for the Virtual Machine."
588
- }
589
- },
590
- "adminPassword": {
591
- "type": "securestring",
592
- "metadata": {
593
- "description": "Password for the Virtual Machine."
594
- }
595
- },
596
- "dnsNameForPublicIP": {
597
- "type": "string",
598
- "metadata": {
599
- "description": "Unique DNS Name for the Public IP used to access the Virtual Machine."
600
- }
601
- },
602
- "imagePublisher": {
603
- "type": "string",
604
- "defaultValue": "Canonical",
605
- "metadata": {
606
- "description": "Publisher for the VM, e.g. Canonical, MicrosoftWindowsServer"
607
- }
608
- },
609
- "imageOffer": {
610
- "type": "string",
611
- "defaultValue": "UbuntuServer",
612
- "metadata": {
613
- "description": "Offer for the VM, e.g. UbuntuServer, WindowsServer."
614
- }
615
- },
616
- "imageSku": {
617
- "type": "string",
618
- "defaultValue": "14.04.3-LTS",
619
- "metadata": {
620
- "description": "Sku for the VM, e.g. 14.04.3-LTS"
621
- }
622
- },
623
- "imageVersion": {
624
- "type": "string",
625
- "defaultValue": "latest",
626
- "metadata": {
627
- "description": "Either a date or latest."
628
- }
629
- },
630
- "vmName": {
631
- "type": "string",
632
- "defaultValue": "vm",
633
- "metadata": {
634
- "description": "The vm name created inside of the resource group."
635
- }
636
- },
637
- "storageAccountType": {
638
- "type": "string",
639
- "defaultValue": "Standard_LRS",
640
- "metadata": {
641
- "description": "The type of storage to use (e.g. Standard_LRS or Premium_LRS)."
642
- }
643
- },
644
- "bootDiagnosticsEnabled": {
645
- "type": "string",
646
- "defaultValue": "true",
647
- "metadata": {
648
- "description": "Whether to enable (true) or disable (false) boot diagnostics. Default: true (requires Standard storage)."
649
- }
650
- }
651
- },
652
- "variables": {
653
- "location": "[parameters('location')]",
654
- "OSDiskName": "osdisk",
655
- "nicName": "nic",
656
- "addressPrefix": "10.0.0.0/16",
657
- "subnetName": "Subnet",
658
- "subnetPrefix": "10.0.0.0/24",
659
- "storageAccountType": "[parameters('storageAccountType')]",
660
- "publicIPAddressName": "publicip",
661
- "publicIPAddressType": "Dynamic",
662
- "vmStorageAccountContainerName": "vhds",
663
- "vmName": "[parameters('vmName')]",
664
- "vmSize": "[parameters('vmSize')]",
665
- "virtualNetworkName": "vnet",
666
- "vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
667
- "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]"
668
- },
669
- "resources": [
670
- {
671
- "type": "Microsoft.Storage/storageAccounts",
672
- "name": "[parameters('newStorageAccountName')]",
673
- "apiVersion": "2015-05-01-preview",
674
- "location": "[variables('location')]",
675
- "properties": {
676
- "accountType": "[variables('storageAccountType')]"
677
- }
678
- },
679
- {
680
- "apiVersion": "2015-05-01-preview",
681
- "type": "Microsoft.Network/publicIPAddresses",
682
- "name": "[variables('publicIPAddressName')]",
683
- "location": "[variables('location')]",
684
- "properties": {
685
- "publicIPAllocationMethod": "[variables('publicIPAddressType')]",
686
- "dnsSettings": {
687
- "domainNameLabel": "[parameters('dnsNameForPublicIP')]"
688
- }
689
- }
690
- },
691
- {
692
- "apiVersion": "2015-05-01-preview",
693
- "type": "Microsoft.Network/virtualNetworks",
694
- "name": "[variables('virtualNetworkName')]",
695
- "location": "[variables('location')]",
696
- "properties": {
697
- "addressSpace": {
698
- "addressPrefixes": [
699
- "[variables('addressPrefix')]"
700
- ]
701
- },
702
- "subnets": [
703
- {
704
- "name": "[variables('subnetName')]",
705
- "properties": {
706
- "addressPrefix": "[variables('subnetPrefix')]"
707
- }
708
- }
709
- ]
710
- }
711
- },
712
- {
713
- "apiVersion": "2015-05-01-preview",
714
- "type": "Microsoft.Network/networkInterfaces",
715
- "name": "[variables('nicName')]",
716
- "location": "[variables('location')]",
717
- "dependsOn": [
718
- "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]",
719
- "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
720
- ],
721
- "properties": {
722
- "ipConfigurations": [
723
- {
724
- "name": "ipconfig1",
725
- "properties": {
726
- "privateIPAllocationMethod": "Dynamic",
727
- "publicIPAddress": {
728
- "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
729
- },
730
- "subnet": {
731
- "id": "[variables('subnetRef')]"
732
- }
733
- }
734
- }
735
- ]
736
- }
737
- },
738
- {
739
- "apiVersion": "2015-06-15",
740
- "type": "Microsoft.Compute/virtualMachines",
741
- "name": "[variables('vmName')]",
742
- "location": "[variables('location')]",
743
- "dependsOn": [
744
- "[concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName'))]",
745
- "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
746
- ],
747
- "properties": {
748
- "hardwareProfile": {
749
- "vmSize": "[variables('vmSize')]"
750
- },
751
- "osProfile": {
752
- "computername": "[variables('vmName')]",
753
- "adminUsername": "[parameters('adminUsername')]",
754
- "adminPassword": "[parameters('adminPassword')]"
755
- },
756
- "storageProfile": {
757
- "imageReference": {
758
- "publisher": "[parameters('imagePublisher')]",
759
- "offer": "[parameters('imageOffer')]",
760
- "sku": "[parameters('imageSku')]",
761
- "version": "[parameters('imageVersion')]"
762
- },
763
- "osDisk": {
764
- "name": "osdisk",
765
- "vhd": {
766
- "uri": "[concat('http://',parameters('newStorageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('OSDiskName'),'.vhd')]"
767
- },
768
- "caching": "ReadWrite",
769
- "createOption": "FromImage"
770
- }
771
- },
772
- "networkProfile": {
773
- "networkInterfaces": [
774
- {
775
- "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
776
- }
777
- ]
778
- },
779
- "diagnosticsProfile": {
780
- "bootDiagnostics": {
781
- "enabled": "[parameters('bootDiagnosticsEnabled')]",
782
- "storageUri": "[concat('http://',parameters('newStorageAccountName'),'.blob.core.windows.net')]"
783
- }
784
- }
785
- }
786
- }
787
- ]
788
- }
789
- EOH
383
+ def virtual_machine_deployment_template_file(template_file, data = {})
384
+ template = File.read(File.expand_path(File.join(__dir__, '../../../templates', template_file)))
385
+ render_binding = binding
386
+ data.each { |key, value| render_binding.local_variable_set(key.to_sym, value) }
387
+ ERB.new(template, nil, '-').result(render_binding)
790
388
  end
791
389
  end
792
390
  end
@@ -0,0 +1,214 @@
1
+ {
2
+ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
3
+ "contentVersion": "1.0.0.0",
4
+ "parameters": {
5
+ "location": {
6
+ "type": "string",
7
+ "metadata": {
8
+ "description": "The location where the resources will be created."
9
+ }
10
+ },
11
+ "vmSize": {
12
+ "type": "string",
13
+ "metadata": {
14
+ "description": "The size of the VM to be created"
15
+ }
16
+ },
17
+ "newStorageAccountName": {
18
+ "type": "string",
19
+ "metadata": {
20
+ "description": "Unique DNS Name for the Storage Account where the Virtual Machine's disks will be placed."
21
+ }
22
+ },
23
+ "adminUsername": {
24
+ "type": "string",
25
+ "metadata": {
26
+ "description": "User name for the Virtual Machine."
27
+ }
28
+ },
29
+ "adminPassword": {
30
+ "type": "securestring",
31
+ "metadata": {
32
+ "description": "Password for the Virtual Machine."
33
+ }
34
+ },
35
+ "dnsNameForPublicIP": {
36
+ "type": "string",
37
+ "metadata": {
38
+ "description": "Unique DNS Name for the Public IP used to access the Virtual Machine."
39
+ }
40
+ },
41
+ "imagePublisher": {
42
+ "type": "string",
43
+ "defaultValue": "Canonical",
44
+ "metadata": {
45
+ "description": "Publisher for the VM, e.g. Canonical, MicrosoftWindowsServer"
46
+ }
47
+ },
48
+ "imageOffer": {
49
+ "type": "string",
50
+ "defaultValue": "UbuntuServer",
51
+ "metadata": {
52
+ "description": "Offer for the VM, e.g. UbuntuServer, WindowsServer."
53
+ }
54
+ },
55
+ "imageSku": {
56
+ "type": "string",
57
+ "defaultValue": "14.04.3-LTS",
58
+ "metadata": {
59
+ "description": "Sku for the VM, e.g. 14.04.3-LTS"
60
+ }
61
+ },
62
+ "imageVersion": {
63
+ "type": "string",
64
+ "defaultValue": "latest",
65
+ "metadata": {
66
+ "description": "Either a date or latest."
67
+ }
68
+ },
69
+ "vmName": {
70
+ "type": "string",
71
+ "defaultValue": "vm",
72
+ "metadata": {
73
+ "description": "The vm name created inside of the resource group."
74
+ }
75
+ },
76
+ "storageAccountType": {
77
+ "type": "string",
78
+ "defaultValue": "Standard_LRS",
79
+ "metadata": {
80
+ "description": "The type of storage to use (e.g. Standard_LRS or Premium_LRS)."
81
+ }
82
+ },
83
+ "bootDiagnosticsEnabled": {
84
+ "type": "string",
85
+ "defaultValue": "true",
86
+ "metadata": {
87
+ "description": "Whether to enable (true) or disable (false) boot diagnostics. Default: true (requires Standard storage)."
88
+ }
89
+ }
90
+ },
91
+ "variables": {
92
+ "location": "[parameters('location')]",
93
+ "OSDiskName": "osdisk",
94
+ "nicName": "nic",
95
+ "addressPrefix": "10.0.0.0/16",
96
+ "subnetName": "<%= subnet_id %>",
97
+ "subnetPrefix": "10.0.0.0/24",
98
+ "storageAccountType": "[parameters('storageAccountType')]",
99
+ "publicIPAddressName": "publicip",
100
+ "publicIPAddressType": "Dynamic",
101
+ "vmStorageAccountContainerName": "vhds",
102
+ "vmName": "[parameters('vmName')]",
103
+ "vmSize": "[parameters('vmSize')]",
104
+ "virtualNetworkName": "vnet",
105
+ "vnetID": "<%= vnet_id %>",
106
+ "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]"
107
+ },
108
+ "resources": [
109
+ {
110
+ "type": "Microsoft.Storage/storageAccounts",
111
+ "name": "[parameters('newStorageAccountName')]",
112
+ "apiVersion": "2015-05-01-preview",
113
+ "location": "[variables('location')]",
114
+ "properties": {
115
+ "accountType": "[variables('storageAccountType')]"
116
+ }
117
+ },
118
+ <%- if public_ip -%>
119
+ {
120
+ "apiVersion": "2015-05-01-preview",
121
+ "type": "Microsoft.Network/publicIPAddresses",
122
+ "name": "[variables('publicIPAddressName')]",
123
+ "location": "[variables('location')]",
124
+ "properties": {
125
+ "publicIPAllocationMethod": "[variables('publicIPAddressType')]",
126
+ "dnsSettings": {
127
+ "domainNameLabel": "[parameters('dnsNameForPublicIP')]"
128
+ }
129
+ }
130
+ },
131
+ <%- end -%>
132
+ {
133
+ "apiVersion": "2015-05-01-preview",
134
+ "type": "Microsoft.Network/networkInterfaces",
135
+ "name": "[variables('nicName')]",
136
+ "location": "[variables('location')]",
137
+ <%- if public_ip -%>
138
+ "dependsOn": [
139
+ "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]"
140
+ ],
141
+ <%- end -%>
142
+ "properties": {
143
+ "ipConfigurations": [
144
+ {
145
+ "name": "ipconfig1",
146
+ "properties": {
147
+ "privateIPAllocationMethod": "Dynamic",
148
+ <%- if public_ip -%>
149
+ "publicIPAddress": {
150
+ "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
151
+ },
152
+ <%- end -%>
153
+ "subnet": {
154
+ "id": "[variables('subnetRef')]"
155
+ }
156
+ }
157
+ }
158
+ ]
159
+ }
160
+ },
161
+ {
162
+ "apiVersion": "2015-06-15",
163
+ "type": "Microsoft.Compute/virtualMachines",
164
+ "name": "[variables('vmName')]",
165
+ "location": "[variables('location')]",
166
+ "dependsOn": [
167
+ "[concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName'))]",
168
+ "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
169
+ ],
170
+ "properties": {
171
+ "hardwareProfile": {
172
+ "vmSize": "[variables('vmSize')]"
173
+ },
174
+ "osProfile": {
175
+ "computername": "[variables('vmName')]",
176
+ "adminUsername": "[parameters('adminUsername')]",
177
+ "adminPassword": "[parameters('adminPassword')]"
178
+ },
179
+ "storageProfile": {
180
+ "imageReference": {
181
+ "publisher": "[parameters('imagePublisher')]",
182
+ "offer": "[parameters('imageOffer')]",
183
+ "sku": "[parameters('imageSku')]",
184
+ "version": "[parameters('imageVersion')]"
185
+ },
186
+ "osDisk": {
187
+ "name": "osdisk",
188
+ "vhd": {
189
+ "uri": "[concat('http://',parameters('newStorageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('OSDiskName'),'.vhd')]"
190
+ },
191
+ "caching": "ReadWrite",
192
+ "createOption": "FromImage"
193
+ }
194
+ },
195
+ "networkProfile": {
196
+ "networkInterfaces": [
197
+ {
198
+ "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
199
+ }
200
+ ]
201
+ },
202
+ "diagnosticsProfile": {
203
+ "bootDiagnostics": {
204
+ "enabled": "[parameters('bootDiagnosticsEnabled')]",
205
+ "storageUri": "[concat('http://',parameters('newStorageAccountName'),'.blob.core.windows.net')]"
206
+ }
207
+ }
208
+ },
209
+ "tags": {
210
+ <%= vm_tags %>
211
+ }
212
+ }
213
+ ]
214
+ }
@@ -0,0 +1,230 @@
1
+ {
2
+ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
3
+ "contentVersion": "1.0.0.0",
4
+ "parameters": {
5
+ "location": {
6
+ "type": "string",
7
+ "metadata": {
8
+ "description": "The location where the resources will be created."
9
+ }
10
+ },
11
+ "vmSize": {
12
+ "type": "string",
13
+ "metadata": {
14
+ "description": "The size of the VM to be created"
15
+ }
16
+ },
17
+ "newStorageAccountName": {
18
+ "type": "string",
19
+ "metadata": {
20
+ "description": "Unique DNS Name for the Storage Account where the Virtual Machine's disks will be placed."
21
+ }
22
+ },
23
+ "adminUsername": {
24
+ "type": "string",
25
+ "metadata": {
26
+ "description": "User name for the Virtual Machine."
27
+ }
28
+ },
29
+ "adminPassword": {
30
+ "type": "securestring",
31
+ "metadata": {
32
+ "description": "Password for the Virtual Machine."
33
+ }
34
+ },
35
+ "dnsNameForPublicIP": {
36
+ "type": "string",
37
+ "metadata": {
38
+ "description": "Unique DNS Name for the Public IP used to access the Virtual Machine."
39
+ }
40
+ },
41
+ "imagePublisher": {
42
+ "type": "string",
43
+ "defaultValue": "Canonical",
44
+ "metadata": {
45
+ "description": "Publisher for the VM, e.g. Canonical, MicrosoftWindowsServer"
46
+ }
47
+ },
48
+ "imageOffer": {
49
+ "type": "string",
50
+ "defaultValue": "UbuntuServer",
51
+ "metadata": {
52
+ "description": "Offer for the VM, e.g. UbuntuServer, WindowsServer."
53
+ }
54
+ },
55
+ "imageSku": {
56
+ "type": "string",
57
+ "defaultValue": "14.04.3-LTS",
58
+ "metadata": {
59
+ "description": "Sku for the VM, e.g. 14.04.3-LTS"
60
+ }
61
+ },
62
+ "imageVersion": {
63
+ "type": "string",
64
+ "defaultValue": "latest",
65
+ "metadata": {
66
+ "description": "Either a date or latest."
67
+ }
68
+ },
69
+ "vmName": {
70
+ "type": "string",
71
+ "defaultValue": "vm",
72
+ "metadata": {
73
+ "description": "The vm name created inside of the resource group."
74
+ }
75
+ },
76
+ "storageAccountType": {
77
+ "type": "string",
78
+ "defaultValue": "Standard_LRS",
79
+ "metadata": {
80
+ "description": "The type of storage to use (e.g. Standard_LRS or Premium_LRS)."
81
+ }
82
+ },
83
+ "bootDiagnosticsEnabled": {
84
+ "type": "string",
85
+ "defaultValue": "true",
86
+ "metadata": {
87
+ "description": "Whether to enable (true) or disable (false) boot diagnostics. Default: true (requires Standard storage)."
88
+ }
89
+ }
90
+ },
91
+ "variables": {
92
+ "location": "[parameters('location')]",
93
+ "OSDiskName": "osdisk",
94
+ "nicName": "nic",
95
+ "addressPrefix": "10.0.0.0/16",
96
+ "subnetName": "Subnet",
97
+ "subnetPrefix": "10.0.0.0/24",
98
+ "storageAccountType": "[parameters('storageAccountType')]",
99
+ "publicIPAddressName": "publicip",
100
+ "publicIPAddressType": "Dynamic",
101
+ "vmStorageAccountContainerName": "vhds",
102
+ "vmName": "[parameters('vmName')]",
103
+ "vmSize": "[parameters('vmSize')]",
104
+ "virtualNetworkName": "vnet",
105
+ "vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
106
+ "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]"
107
+ },
108
+ "resources": [
109
+ {
110
+ "type": "Microsoft.Storage/storageAccounts",
111
+ "name": "[parameters('newStorageAccountName')]",
112
+ "apiVersion": "2015-05-01-preview",
113
+ "location": "[variables('location')]",
114
+ "properties": {
115
+ "accountType": "[variables('storageAccountType')]"
116
+ }
117
+ },
118
+ {
119
+ "apiVersion": "2015-05-01-preview",
120
+ "type": "Microsoft.Network/publicIPAddresses",
121
+ "name": "[variables('publicIPAddressName')]",
122
+ "location": "[variables('location')]",
123
+ "properties": {
124
+ "publicIPAllocationMethod": "[variables('publicIPAddressType')]",
125
+ "dnsSettings": {
126
+ "domainNameLabel": "[parameters('dnsNameForPublicIP')]"
127
+ }
128
+ }
129
+ },
130
+ {
131
+ "apiVersion": "2015-05-01-preview",
132
+ "type": "Microsoft.Network/virtualNetworks",
133
+ "name": "[variables('virtualNetworkName')]",
134
+ "location": "[variables('location')]",
135
+ "properties": {
136
+ "addressSpace": {
137
+ "addressPrefixes": [
138
+ "[variables('addressPrefix')]"
139
+ ]
140
+ },
141
+ "subnets": [
142
+ {
143
+ "name": "[variables('subnetName')]",
144
+ "properties": {
145
+ "addressPrefix": "[variables('subnetPrefix')]"
146
+ }
147
+ }
148
+ ]
149
+ }
150
+ },
151
+ {
152
+ "apiVersion": "2015-05-01-preview",
153
+ "type": "Microsoft.Network/networkInterfaces",
154
+ "name": "[variables('nicName')]",
155
+ "location": "[variables('location')]",
156
+ "dependsOn": [
157
+ "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]",
158
+ "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
159
+ ],
160
+ "properties": {
161
+ "ipConfigurations": [
162
+ {
163
+ "name": "ipconfig1",
164
+ "properties": {
165
+ "privateIPAllocationMethod": "Dynamic",
166
+ "publicIPAddress": {
167
+ "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
168
+ },
169
+ "subnet": {
170
+ "id": "[variables('subnetRef')]"
171
+ }
172
+ }
173
+ }
174
+ ]
175
+ }
176
+ },
177
+ {
178
+ "apiVersion": "2015-06-15",
179
+ "type": "Microsoft.Compute/virtualMachines",
180
+ "name": "[variables('vmName')]",
181
+ "location": "[variables('location')]",
182
+ "dependsOn": [
183
+ "[concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName'))]",
184
+ "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
185
+ ],
186
+ "properties": {
187
+ "hardwareProfile": {
188
+ "vmSize": "[variables('vmSize')]"
189
+ },
190
+ "osProfile": {
191
+ "computername": "[variables('vmName')]",
192
+ "adminUsername": "[parameters('adminUsername')]",
193
+ "adminPassword": "[parameters('adminPassword')]"
194
+ },
195
+ "storageProfile": {
196
+ "imageReference": {
197
+ "publisher": "[parameters('imagePublisher')]",
198
+ "offer": "[parameters('imageOffer')]",
199
+ "sku": "[parameters('imageSku')]",
200
+ "version": "[parameters('imageVersion')]"
201
+ },
202
+ "osDisk": {
203
+ "name": "osdisk",
204
+ "vhd": {
205
+ "uri": "[concat('http://',parameters('newStorageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('OSDiskName'),'.vhd')]"
206
+ },
207
+ "caching": "ReadWrite",
208
+ "createOption": "FromImage"
209
+ }
210
+ },
211
+ "networkProfile": {
212
+ "networkInterfaces": [
213
+ {
214
+ "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
215
+ }
216
+ ]
217
+ },
218
+ "diagnosticsProfile": {
219
+ "bootDiagnostics": {
220
+ "enabled": "[parameters('bootDiagnosticsEnabled')]",
221
+ "storageUri": "[concat('http://',parameters('newStorageAccountName'),'.blob.core.windows.net')]"
222
+ }
223
+ }
224
+ },
225
+ "tags": {
226
+ <%= vm_tags %>
227
+ }
228
+ }
229
+ ]
230
+ }
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.7.2
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Preston
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-03 00:00:00.000000000 Z
11
+ date: 2017-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inifile
@@ -158,6 +158,8 @@ files:
158
158
  - README.md
159
159
  - lib/kitchen/driver/azurerm.rb
160
160
  - lib/kitchen/driver/credentials.rb
161
+ - templates/internal.erb
162
+ - templates/public.erb
161
163
  homepage: https://github.com/pendrica/kitchen-azurerm
162
164
  licenses:
163
165
  - Apache-2.0
@@ -178,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
180
  version: '0'
179
181
  requirements: []
180
182
  rubyforge_project:
181
- rubygems_version: 2.6.6
183
+ rubygems_version: 2.6.8
182
184
  signing_key:
183
185
  specification_version: 4
184
186
  summary: Test Kitchen driver for Azure Resource Manager.