kitchen-azurerm 1.3.0 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f2cefad48dc76f5e168f8409b8ea3e002d07312c8684a719084ffdf1b833550
4
- data.tar.gz: 7234c182b57734cd042faaa857a0779aee6bab34aa409f4d9a3b0a7918ef85e5
3
+ metadata.gz: '04287eb76a3ad593e18ca9036eee9bdb72dc6a6d67b32c2153cb9e58f862d4bc'
4
+ data.tar.gz: 8f2ea6bb99fd8b92522d304f0bcc8d7db5034edcf79bc8862ca9dbc67d188920
5
5
  SHA512:
6
- metadata.gz: ea881a871e778781d39573ced02fb2a03ba1bd4c207bddd01ec6e527d85c7efa5d7a1ef378a282216fe14f90831aa284237b2e3bc9bceb6b28f2fb1dc0aa1db5
7
- data.tar.gz: c82d8dabb76c54a73b0e0f444a367001a631bd8f2e28d0108fa17e918827e6a8d83463e1170e72c5b6100acc6ea87fa9fc4d4ab44b98842d810c78cc3bac4fab
6
+ metadata.gz: c2f3c2f34b45368047be1397af798d77e1f0e8b6f58cc6121e4c250576b6be12d4166750ce8c08538d869576c142cd97eb99d2af9b185b21826065a0bc57a1e4
7
+ data.tar.gz: 519455de670f654930edafd819cc628f0de5ca069c97b8fe5dd750b50d9a3d771dd2db2f0260f1dc1e2e29e7e4fd307d802f71f2c28276a5d7bcc314da1c5cc3
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # kitchen-azurerm
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/kitchen-azurerm.svg)](http://badge.fury.io/rb/kitchen-azurerm) ![CI](https://github.com/test-kitchen/kitchen-azurerm/workflows/CI/badge.svg?branch=master)
3
+ [![Gem Version](https://badge.fury.io/rb/kitchen-azurerm.svg)](https://badge.fury.io/rb/kitchen-azurerm)
4
+ ![CI](https://github.com/test-kitchen/kitchen-azurerm/workflows/CI/badge.svg?branch=master)
4
5
 
5
6
  **kitchen-azurerm** is a driver for the popular test harness [Test Kitchen](http://kitchen.ci) that allows Microsoft Azure resources to be provisioned before testing. This driver uses the new Microsoft Azure Resource Management REST API via the [azure-sdk-for-ruby](https://github.com/azure/azure-sdk-for-ruby).
6
7
 
@@ -76,9 +77,276 @@ wsus-windows-2019 Azurerm ChefZero Inspec Winrm <Not Created> <N
76
77
  wsus-windows-2016 Azurerm ChefZero Inspec Winrm <Not Created> <None>
77
78
  ```
78
79
 
79
- ### .kitchen.yml example 1 - Linux/Ubuntu
80
+ ### Driver Properties
80
81
 
81
- Here's an example ```.kitchen.yml``` file that provisions an Ubuntu Server, using Chef Zero as the provisioner and SSH as the transport. Note that if the key does not exist at the specified location, it will be created. Also note that if ```ssh_key``` is supplied, Test Kitchen will use this in preference to any default/configured passwords that are supplied.
82
+ The following properties are able to be specified in the `driver` section of the Test Kitchen configuration:
83
+
84
+ #### subscription_id (required)
85
+
86
+ * _string_ : Reads string from `ENV["AZURE_SUBSCRIPTION_ID"]` or must be specified if not present in `ENV`.
87
+ * Default Value: `ENV["AZURE_SUBSCRIPTION_ID"]`
88
+
89
+ #### azure_environment
90
+
91
+ * _string_ : Name of Azure environment to use.
92
+
93
+ #### machine_size (required)
94
+
95
+ * _string_ : Machine size to use for instances created.
96
+
97
+ #### location (required)
98
+
99
+ * _string_ : Azure location to use, example `"Central US"`
100
+
101
+ #### azure_resource_group_prefix
102
+
103
+ * _string_ : Prefix to use for the resource group configuration which will be created.
104
+ * Default Value: `"kitchen-"`
105
+
106
+ #### azure_resource_group_suffix
107
+
108
+ * _string_ : Optional suffix to append to resource group name.
109
+ * Default Value: `""`
110
+
111
+ #### azure_resource_group_name
112
+
113
+ * _string_ : Optional override for base name of the Azure Resource group which is created, uses prefix and suffix.
114
+ * Default Value: `""`
115
+
116
+ #### explicit_resource_group_name
117
+
118
+ * _string_ : Optional explicit resource group name, does not use `azure_resource_group_prefix`/`azure_resource_group_suffix`
119
+ * Default Value: `""`
120
+
121
+ #### destroy_explicit_resource_group
122
+
123
+ * _boolean_ : Used for cleanup with `explicit_resource_group_name`
124
+ * Default Value: `true`
125
+
126
+ #### destroy_explicit_resource_group_tags
127
+
128
+ * _boolean_ : Used for cleanup with `explicit_resource_group_name`
129
+ * Default Value: `true`
130
+
131
+ #### destroy_resource_group_contents
132
+
133
+ * _boolean_ : Can be used when you want to destroy the resources within a resource group without destroying the resource group itself. For example, the following configuration options used in combination would use an existing resource group (or create one if it doesn't exist) and will destroy the contents of the resource group in the ```kitchen destroy``` phase. If you wish to destroy the empty resource group created after you empty the resource group with this flag you can now set the ```destroy_explicit_resource_group``` to "true" to destroy the empty resource group.
134
+ * Default Value: `false`
135
+
136
+ #### resource_group_tags
137
+
138
+ * _hash_ : Optional hash of tags to pass to resource group
139
+
140
+ ```yaml
141
+ driver:
142
+ name: azurerm
143
+ resource_group_tags:
144
+ tag1: tag1value
145
+ ```
146
+
147
+ #### image_urn
148
+
149
+ * _string_ : Image URN to use for vm creation. List can be found using `az` cli - [https://docs.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage#list-popular-images]
150
+ * Default Value: `"Canonical:UbuntuServer:14.04.3-LTS:latest"`
151
+
152
+ #### image_url
153
+
154
+ * _string_ : (unmanaged disks only) can be used to specify a custom vhd
155
+ * This VHD must be in the same storage account as the disks of the VM, therefore ```existing_storage_account_blob_url``` must also be set and ```use_managed_disks``` must be set to false.
156
+
157
+ #### image_id
158
+
159
+ * _string_ : (managed disks only) can be used to specify an image by id (managed disk). This works only with managed disks.
160
+
161
+ #### use_ephemeral_osdisk
162
+
163
+ * _boolean_ : Optional flag to use ephermeal disk for instances.
164
+ * Default Value: `false`
165
+
166
+ #### os_disk_size_gb
167
+
168
+ * _string_ : Optional override of os disk size for instances.
169
+
170
+ #### os_type
171
+
172
+ * _string_ : Should be specified when os type is not `linux`
173
+ * Default Value: `"linux"`
174
+
175
+ #### custom_data
176
+
177
+ * _string_ : Optional custom data which may be specified for instances [https://docs.microsoft.com/en-us/azure/virtual-machines/custom-data].
178
+ * Value can be a file or the data itself, this module handles base64 encoding for you.
179
+
180
+ #### username
181
+
182
+ * _string_ : Username to use for connecting to instances.
183
+ * Default Value: `"azure"`
184
+
185
+ #### password
186
+
187
+ * _string_ : Optional password to use for connecting to instances.
188
+ * Default Value: `SecureRandom.base64(25)` (Randomly generated 24 digit password)
189
+
190
+ #### vm_name
191
+
192
+ * _string_ : Optional name for vm instances to create.
193
+ * Default Value: `"vm"`
194
+
195
+ #### nic_name
196
+
197
+ * _string_ : Optional name to provide for nic, if not specified then nic name will be `"nic-#{config[:vm_name]}"`.
198
+
199
+ #### vnet_id
200
+
201
+ * _string_ : Optional `vnet` to provide. If no `vnet` is chosen then public IP will be assigned using default values.
202
+
203
+ #### subnet_id
204
+
205
+ * _string_ : Optional subnet to provide, should be used with `vnet_id`.
206
+
207
+ #### public_ip
208
+
209
+ * _boolean_ : Option to specify if a public IP should be assigned. In default configuration if all other options are left at default then a public IP _will_ be assigned, due to `vnet_id` having no value.
210
+ * Default Value: `false`
211
+
212
+ #### public_ip_sku
213
+
214
+ * _string_ : Optional string to change the SKU of allocated public IP address. Defaults to `Basic`.
215
+ * Default Value: `"Basic"`
216
+
217
+ #### storage_account_type
218
+
219
+ * _string_ : Optional storage account type.
220
+ * Default Value: `"Standard_LRS"`
221
+
222
+ #### existing_storage_account_blob_url
223
+
224
+ * _string_ : Used with private image specification, the URL of the existing storage account (blob) (without container)
225
+
226
+ #### existing_storage_account_container
227
+
228
+ * _string_ : Used with private image specification, the Container Name for OS Images (blob)
229
+
230
+ #### boot_diagnostics_enabled
231
+
232
+ * _boolean_ : Whether to enable (true) or disable (false) boot diagnostics. Default: true (requires Standard storage).
233
+ * Default Value: `true`
234
+
235
+ #### winrm_powershell_script
236
+
237
+ * _string_ : By default on Windows machines, a PowerShell script runs that enables WinRM over the SSL transport, for Basic, Negotiate and CredSSP connections. To supply your own PowerShell script (e.g. to enable HTTP), use the `winrm_powershell_script` parameter. Windows 2008 R2 example:
238
+
239
+ ```yaml
240
+ platforms:
241
+ - name: windows2008-r2
242
+ driver_config:
243
+ image_urn: MicrosoftWindowsServer:WindowsServer:2008-R2-SP1:latest
244
+ winrm_powershell_script: |-
245
+ winrm quickconfig -q
246
+ winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="512"}'
247
+ winrm set winrm/config '@{MaxTimeoutms="1800000"}'
248
+ winrm set winrm/config/service '@{AllowUnencrypted="true"}'
249
+ winrm set winrm/config/service/auth '@{Basic="true"}'
250
+
251
+ ```
252
+
253
+ #### pre_deployment_template
254
+
255
+ * _string_ : Optional path to name of pre-deployment template to use.
256
+
257
+ #### pre_deployment_parameters
258
+
259
+ * _hash_ : Optional parameters to pass to pre-deployment template.
260
+
261
+ #### post_deployment_template
262
+
263
+ * _string_ : Optional path to name of post-deployment template to use.
264
+
265
+ #### post_deployment_parameters
266
+
267
+ * _hash_ : Optional parameters to pass to post-deployment template.
268
+
269
+ #### plan
270
+
271
+ * _hash_ : Optional JSON object which allows you to define plan information when creating VMs from Marketplace images. Please refer to [Deploy an image with Marketplace terms](https://aka.ms/azuremarketplaceapideployment) for more details. Not all Marketplace images support programmatic deployment, and support is controlled by the image publisher.
272
+
273
+ #### vm_tags
274
+
275
+ * _hash_ : Optional hash of vm tags to populate.
276
+
277
+ #### use_managed_disks
278
+
279
+ * _boolean_ : Must be set to `true` to use `data_disks` property.
280
+ * Default Value: `true`
281
+
282
+ #### data_disks
283
+
284
+ * _array_ : Additional disks to configure for instances.
285
+
286
+ ```yaml
287
+ platforms:
288
+ - name: windows2016-noformat
289
+ driver:
290
+ image_urn: MicrosoftWindowsServer:WindowsServer:2016-Datacenter:latest
291
+ data_disks:
292
+ - lun: 0
293
+ disk_size_gb: 128
294
+ - lun: 1
295
+ disk_size_gb: 128
296
+ - lun: 2
297
+ disk_size_gb: 128
298
+ ```
299
+
300
+ #### format_data_disks
301
+
302
+ * _boolean_ : Run format operations on attached data disks
303
+ * Default Value: `false`
304
+
305
+ #### format_data_disks_powershell_script
306
+
307
+ * _boolean_ : Customize the content of format operations for attached `data_disks`
308
+ * Default Value: `false`
309
+
310
+ #### system_assigned_identity
311
+
312
+ * _boolean_ : Whether to enable system assigned identity for the vm.
313
+ * Default Value: `false`
314
+
315
+ #### user_assigned_identities
316
+
317
+ * _hash_ : An object whose keys are resource IDs for user identities to associate with the Virtual Machine and whose values are empty objects, or empty to disable user assigned
318
+ identities.
319
+
320
+ #### deployment_sleep
321
+
322
+ * _string_ : Time in seconds to sleep at the end of deployment before fetching details.
323
+ * Default Value: `10`
324
+
325
+ #### secret_url
326
+
327
+ * _string_ : used with connecting to Azure Key Vault
328
+
329
+ #### vault_name
330
+
331
+ * _string_ : used with connecting to Azure Key Vault
332
+
333
+ #### vault_resource_group
334
+
335
+ * _string_ : used with connecting to Azure Key Vault
336
+
337
+ #### azure_api_retries
338
+
339
+ * _string_ : Number of times to retry connections to Azure API.
340
+ * Default Value: `5`
341
+
342
+ #### use_fqdn_hostname
343
+
344
+ * _boolean_ : When true, Kitchen will use the FQDN that is assigned to the Virtual Machine. When false, kitchen will use the public IP address of the machine. This may overcome issues with Corporate firewalls or VPNs blocking Public IP addresses.
345
+ * Default Value: `false`
346
+
347
+ ### kitchen.yml example 1 - Linux/Ubuntu
348
+
349
+ Here's an example ```kitchen.yml``` file that provisions an Ubuntu Server, using Chef Zero as the provisioner and SSH as the transport. Note that if the key does not exist at the specified location, it will be created. Also note that if ```ssh_key``` is supplied, Test Kitchen will use this in preference to any default/configured passwords that are supplied.
82
350
 
83
351
  ```yaml
84
352
  ---
@@ -102,8 +370,6 @@ platforms:
102
370
 
103
371
  suites:
104
372
  - name: default
105
- run_list:
106
- - recipe[kitchentesting::default]
107
373
  attributes:
108
374
  ```
109
375
 
@@ -115,9 +381,9 @@ Concurrent execution of create/converge/destroy is supported via the --concurren
115
381
 
116
382
  Where n is the number of threads to create. Note that any failure (e.g. an AzureOperationError) will cause the whole test to fail, though resources already in creation will continue to be created.
117
383
 
118
- ### .kitchen.yml example 2 - Windows
384
+ ### kitchen.yml example 2 - Windows
119
385
 
120
- Here's a further example ```.kitchen.yml``` file that will provision a Windows Server 2019 [smalldisk] instance, using WinRM as the transport. An [ephemeral os disk](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/ephemeral-os-disks) is used. 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:
386
+ Here's a further example ```kitchen.yml``` file that will provision a Windows Server 2019 [smalldisk] instance, using WinRM as the transport. An [ephemeral os disk](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/ephemeral-os-disks) is used. 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:
121
387
 
122
388
  ```yaml
123
389
  ---
@@ -145,12 +411,10 @@ platforms:
145
411
  name: winrm
146
412
  suites:
147
413
  - name: default
148
- run_list:
149
- - recipe[kitchentesting::default]
150
414
  attributes:
151
415
  ```
152
416
 
153
- ### .kitchen.yml example 3 - "pre-deployment" ARM template
417
+ ### kitchen.yml example 3 - "pre-deployment" ARM template
154
418
 
155
419
  The following example introduces the ```pre_deployment_template``` and ```pre_deployment_parameters``` properties in the configuration file.
156
420
  You can use this capability to execute an ARM template containing Azure resources to provision before the system under test is created.
@@ -224,7 +488,7 @@ Example predeploy.json:
224
488
  }
225
489
  ```
226
490
 
227
- ### .kitchen.yml example 4 - deploy VM to existing virtual network/subnet (use for ExpressRoute/VPN scenarios)
491
+ ### kitchen.yml example 4 - deploy VM to existing virtual network/subnet (use for ExpressRoute/VPN scenarios)
228
492
 
229
493
  The following example introduces the ```vnet_id``` and ```subnet_id``` properties under "driver" in the configuration file. This can be applied at the top level, or per platform.
230
494
  You can use this capability to create the VM on an existing virtual network and subnet created in a different resource group.
@@ -254,12 +518,46 @@ platforms:
254
518
 
255
519
  suites:
256
520
  - name: default
257
- run_list:
258
- - recipe[kitchen-azurerm-demo::default]
259
521
  attributes:
260
522
  ```
261
523
 
262
- ### .kitchen.yml example 5 - deploy VM to existing virtual network/subnet (use for ExpressRoute/VPN scenarios) with Private Managed Image
524
+ ### kitchen.yml example 5 - deploy VM to existing virtual network/subnet with a Standard SKU public IP (use for ExpressRoute/VPN scenarios)
525
+
526
+ The following example introduces the ```vnet_id``` and ```subnet_id``` properties under "driver" in the configuration file. This can be applied at the top level, or per platform.
527
+ You can use this capability to create the VM on an existing virtual network and subnet created in a different resource group.
528
+
529
+ This enables scenarios that require a Standard SKU public IP resource, for example when a NAT gateway is present on the target subnet.
530
+
531
+
532
+ ```yaml
533
+ ---
534
+ driver:
535
+ name: azurerm
536
+ subscription_id: 'your-azure-subscription-id-here'
537
+ location: 'West Europe'
538
+ machine_size: 'Standard_D1'
539
+
540
+ transport:
541
+ ssh_key: ~/.ssh/id_kitchen-azurerm
542
+
543
+ provisioner:
544
+ name: chef_zero
545
+
546
+ platforms:
547
+ - name: ubuntu-1404
548
+ driver:
549
+ image_urn: Canonical:UbuntuServer:14.04.4-LTS:latest
550
+ vnet_id: /subscriptions/b6e7eee9-YOUR-GUID-HERE-03ab624df016/resourceGroups/pendrica-infrastructure/providers/Microsoft.Network/virtualNetworks/pendrica-arm-vnet
551
+ subnet_id: subnet-10.1.0
552
+ public_ip: true
553
+ public_ip_sku: Standard
554
+
555
+ suites:
556
+ - name: default
557
+ attributes:
558
+ ```
559
+
560
+ ### kitchen.yml example 6 - deploy VM to existing virtual network/subnet (use for ExpressRoute/VPN scenarios) with Private Managed Image
263
561
 
264
562
  This example is the same as above, but uses a private managed image to provision the vm.
265
563
 
@@ -289,12 +587,10 @@ platforms:
289
587
 
290
588
  suites:
291
589
  - name: default
292
- run_list:
293
- - recipe[kitchen-azurerm-demo::default]
294
590
  attributes:
295
591
  ```
296
592
 
297
- ### .kitchen.yml example 6 - deploy VM to existing virtual network/subnet (use for ExpressRoute/VPN scenarios) with Private Classic OS Image
593
+ ### kitchen.yml example 7 - deploy VM to existing virtual network/subnet (use for ExpressRoute/VPN scenarios) with Private Classic OS Image
298
594
 
299
595
  This example a classic Custom VM Image (aka a VHD file) is used. As the Image VHD must be in the same storage account then the disk of the instance, the os disk is created in an existing image account.
300
596
 
@@ -332,12 +628,10 @@ platforms:
332
628
 
333
629
  suites:
334
630
  - name: default
335
- run_list:
336
- - recipe[kitchen-azurerm-demo::default]
337
631
  attributes:
338
632
  ```
339
633
 
340
- ### .kitchen.yml example 7 - deploy VM to existing virtual network/subnet (use for ExpressRoute/VPN scenarios) with Private Classic OS Image and providing custom data and extra large os disk
634
+ ### kitchen.yml example 8 - deploy VM to existing virtual network/subnet (use for ExpressRoute/VPN scenarios) with Private Classic OS Image and providing custom data and extra large os disk
341
635
 
342
636
  This is the same as above, but uses custom data to customize the instance.
343
637
 
@@ -377,12 +671,10 @@ platforms:
377
671
 
378
672
  suites:
379
673
  - name: default
380
- run_list:
381
- - recipe[kitchen-azurerm-demo::default]
382
674
  attributes:
383
675
  ```
384
676
 
385
- ### .kitchen.yml example 8 - Windows 2016 VM with additional data disks
677
+ ### kitchen.yml example 9 - Windows 2016 VM with additional data disks
386
678
 
387
679
  This example demonstrates how to add 3 additional Managed data disks to a Windows Server 2016 VM. Not supported with legacy (pre-managed disk) storage accounts.
388
680
 
@@ -414,12 +706,10 @@ platforms:
414
706
 
415
707
  suites:
416
708
  - name: default
417
- run_list:
418
- - recipe[kitchentesting::default]
419
709
  attributes:
420
710
  ```
421
711
 
422
- ### .kitchen.yml example 9 - "post-deployment" ARM template with MSI authentication
712
+ ### kitchen.yml example 10 - "post-deployment" ARM template with MSI authentication
423
713
 
424
714
  The following example introduces the ```post_deployment_template``` and ```post_deployment_parameters``` properties in the configuration file.
425
715
  You can use this capability to execute an ARM template containing Azure resources to provision after the system under test is created.
@@ -451,8 +741,6 @@ platforms:
451
741
 
452
742
  suites:
453
743
  - name: default
454
- run_list:
455
- - recipe[kitchen-azurerm-demo::default]
456
744
  attributes:
457
745
  ```
458
746
 
@@ -505,7 +793,7 @@ Example postdeploy.json to enable MSI extention on VM:
505
793
  }
506
794
  ```
507
795
 
508
- ### .kitchen.yml example 10 - Enabling Managed Service Identities
796
+ ### kitchen.yml example 11 - Enabling Managed Service Identities
509
797
 
510
798
  This example demonstrates how to enable a System Assigned Identity and User Assigned Identities on a Kitchen VM.
511
799
  Any combination of System and User assigned identities may be enabled, and multiple User Assigned Identities can be supplied.
@@ -536,12 +824,10 @@ platforms:
536
824
 
537
825
  suites:
538
826
  - name: default
539
- run_list:
540
- - recipe[kitchentesting::default]
541
827
  attributes:
542
828
  ```
543
829
 
544
- ### .kitchen.yml example 11 - deploy VM with key vault certificate
830
+ ### kitchen.yml example 12 - deploy VM with key vault certificate
545
831
 
546
832
  This following example introduces ```secret_url```, ```vault_name```, and ```vault_resource_group``` properties under "driver" in the configuration file. You can use this capability to create a VM with a specified key vault certificate.
547
833
 
@@ -567,8 +853,6 @@ platforms:
567
853
 
568
854
  suites:
569
855
  - name: default
570
- run_list:
571
- - recipe[kitchentesting::default]
572
856
  attributes:
573
857
  ```
574
858
 
@@ -578,7 +862,7 @@ Starting with v0.9.0 this driver has support for Azure Government and Sovereign
578
862
 
579
863
  Note that the ```use_managed_disks``` option should be set to false until supported by AzureUSGovernment.
580
864
 
581
- ### Example .kitchen.yml for Azure US Government cloud
865
+ ### Example kitchen.yml for Azure US Government cloud
582
866
 
583
867
  ```yaml
584
868
  ---
@@ -605,8 +889,6 @@ platforms:
605
889
 
606
890
  suites:
607
891
  - name: default
608
- run_list:
609
- - recipe[vmtesting::default]
610
892
  ```
611
893
 
612
894
  ### How to retrieve the image_urn
@@ -644,68 +926,6 @@ data: Canonical UbuntuServer 15.10-DAILY 15.10.201509220 westeurope
644
926
  info: vm image list command OK
645
927
  ```
646
928
 
647
- ### Additional parameters that can be specified in your `kitchen.yml` or added to your personal `kitchen.local.yml`
648
-
649
- * Note that the ```driver``` section can also take explicit values for ```username``` and ```password```. Otherwise, the default username is "azure" and the password is a randomly generated 24 character password that can be found in your local kitchen state file (typically `.kitchen/<instance-name>.yml`) if you require it for any reason.
650
-
651
- * The ```storage_account_type``` parameter defaults to 'Standard_LRS' and allows you to switch to premium storage (e.g. 'Premium_LRS')
652
-
653
- * The ```enable_boot_diagnostics``` parameter defaults to 'true' and allows you to switch off boot diagnostics in case you are using premium storage.
654
-
655
- * The optional ```vm_tags``` parameter allows you to define key:value pairs to tag VMs with on creation.
656
-
657
- * The optional ```plan``` parameter allows you to define plan information when creating VMs from Marketplace images. Please refer to [Deploy an image with Marketplace terms](https://aka.ms/azuremarketplaceapideployment) for more details. Not all Marketplace images support programmatic deployment, and support is controlled by the image publisher.
658
-
659
- * Managed disks are now enabled by default, to use the Storage account set ```use_managed_disks``` (default: true).
660
-
661
- * The ```image_url``` (unmanaged disks only) parameter can be used to specify a custom vhd (This VHD must be in the same storage account as the disks of the VM, therefore ```existing_storage_account_blob_url``` must also be set and ```use_managed_disks``` must be set to false)
662
-
663
- * The ```image_id``` (managed disks only) parameter can be used to specify an image by id (managed disk). This works only with managed disks.
664
-
665
- * The ```existing_storage_account_blob_url``` can be specified to specify an url to an existing storage account (needed for ```image_url```)
666
-
667
- * The ```custom_data``` parameter can be used to specify custom data to provide to the instance. This can be a file or the data itself. This module handles base64 encoding for you.
668
-
669
- * The ```os_disk_size_gb``` parameter can be used to specify a custom os disk size.
670
-
671
- * The ```azure_resource_group_prefix``` and ```azure_resource_group_suffix``` can be used to further disambiguate Azure resource group names created by the driver.
672
-
673
- * The ```explicit_resource_group_name``` and ```destroy_explicit_resource_group``` (default: "true") parameters can be used in scenarios where you are provided a pre-created Resource Group. Example usage: ```explicit_resource_group_name: kitchen-<%= ENV["USERNAME"] %>```
674
-
675
- * The ```destroy_resource_group_contents``` (default: "false") parameter can be used when you want to destroy the resources within a resource group without destroying the resource group itself. For example, the following configuration options used in combination would use an existing resource group (or create one if it doesn't exist) and will destroy the contents of the resource group in the ```kitchen destroy``` phase.
676
-
677
- * The ```destroy_explicit_resource_group_tags``` (default: "true") parameter can be used when you want to remove tags associated with an explicit resource group. The default setting is set to `true` to remain consistent with previous behavior. This should be used in combination with an explicitly named resource group and will be honored during the ```kitchen destroy``` phase.
678
-
679
- ```yaml
680
- ---
681
- driver:
682
- explicit_resource_group_name: stuart-rg-demo-001
683
- destroy_explicit_resource_group: false
684
- destroy_resource_group_contents: true
685
- ```
686
-
687
- * The ```use_ephemeral_osdisk``` (default: false) parameter can be used if you wish to use [ephemeral OS disk functionality](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/ephemeral-os-disks).
688
-
689
- * The ```secret_url```, ```vault_name```, and ```vault_resource_group``` parameters can be used to deploy VM with specified key vault certificate.
690
-
691
- ## Enabling alternative WinRM configurations
692
-
693
- * By default on Windows machines, a PowerShell script runs that enables WinRM over the SSL transport, for Basic, Negotiate and CredSSP connections. To supply your own PowerShell script (e.g. to enable HTTP), use the `winrm_powershell_script` parameter. Windows 2008 R2 example:
694
-
695
- ```yaml
696
- platforms:
697
- - name: windows2008-r2
698
- driver_config:
699
- image_urn: MicrosoftWindowsServer:WindowsServer:2008-R2-SP1:latest
700
- winrm_powershell_script: |-
701
- winrm quickconfig -q
702
- winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="512"}'
703
- winrm set winrm/config '@{MaxTimeoutms="1800000"}'
704
- winrm set winrm/config/service '@{AllowUnencrypted="true"}'
705
- winrm set winrm/config/service/auth '@{Basic="true"}'
706
-
707
- ```
708
-
709
929
  ## Contributing
710
930
 
711
931
  Contributions to the project are welcome via submitting Pull Requests.
@@ -722,7 +942,7 @@ Stuart Preston
722
942
 
723
943
  ## License and Copyright
724
944
 
725
- Copyright 2015-2020, Chef Software, Inc.
945
+ Copyright 2015-2021, Chef Software, Inc.
726
946
 
727
947
  ```
728
948
  Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,5 +1,6 @@
1
1
  require "inifile"
2
2
  require "kitchen/logging"
3
+ autoload :MsRest, "ms_rest"
3
4
 
4
5
  module Kitchen
5
6
  module Driver
@@ -60,7 +61,7 @@ module Kitchen
60
61
  if File.file?(config_path)
61
62
  IniFile.load(config_path)
62
63
  else
63
- warn "#{config_path} was not found or not accessible. Will attempt to use Managed Identity."
64
+ warn "#{config_path} was not found or not accessible."
64
65
  {}
65
66
  end
66
67
  end
@@ -71,7 +72,7 @@ module Kitchen
71
72
  end
72
73
 
73
74
  def tenant_id!
74
- tenant_id || raise("Must provide tenant id. Use AZURE_TENANT_ID environment variable or set it in credentials file (#{config_path})")
75
+ tenant_id || warn("(#{config_path}) does not contain tenant_id neither is the AZURE_TENANT_ID environment variable set.")
75
76
  end
76
77
 
77
78
  def tenant_id
@@ -86,13 +87,37 @@ module Kitchen
86
87
  ENV["AZURE_CLIENT_SECRET"] || credentials_property("client_secret")
87
88
  end
88
89
 
90
+ # Retrieve a token based upon the preferred authentication method.
91
+ #
92
+ # @return [::MsRest::TokenProvider] A new token provider object.
89
93
  def token_provider
90
- if client_id && client_secret
94
+ # Login with a credentials file or setting the environment variables
95
+ #
96
+ # Typically used with a service principal.
97
+ #
98
+ # SPN with client_id, client_secret and tenant_id
99
+ if client_id && client_secret && tenant_id
91
100
  ::MsRestAzure::ApplicationTokenProvider.new(tenant_id, client_id, client_secret, ad_settings)
92
- elsif client_id
101
+ # Login with a Managed Service Identity.
102
+ #
103
+ # Typically used with a Managed Service Identity when you have a particular object registered in a tenant.
104
+ #
105
+ # MSI with client_id and tenant_id (aka User Assigned Identity).
106
+ elsif client_id && tenant_id
93
107
  ::MsRestAzure::MSITokenProvider.new(50342, ad_settings, { client_id: client_id })
94
- else
108
+ # Default approach to inheriting existing object permissions (application or device this code is running on).
109
+ #
110
+ # Typically used when you want to inherit the permissions of the system you're running on that are in a tenant.
111
+ #
112
+ # MSI with just tenant_id (aka System Assigned Identity).
113
+ elsif tenant_id
95
114
  ::MsRestAzure::MSITokenProvider.new(50342, ad_settings)
115
+ # Login using the Azure CLI
116
+ #
117
+ # Typically used when you want to rely upon `az login` as your preferred authentication method.
118
+ else
119
+ warn("Using tenant id set through `az login`.")
120
+ ::MsRestAzure::AzureCliTokenProvider.new(ad_settings)
96
121
  end
97
122
  end
98
123
 
@@ -1,4 +1,6 @@
1
1
  require "kitchen"
2
+
3
+ autoload :MsRestAzure, "ms_rest_azure"
2
4
  require_relative "azure_credentials"
3
5
  require "securerandom" unless defined?(SecureRandom)
4
6
  module Azure
@@ -17,7 +19,9 @@ module Kitchen
17
19
  module Driver
18
20
  #
19
21
  # Azurerm
22
+ # Create a new resource group object and set the location and tags attributes then return it.
20
23
  #
24
+ # @return [::Azure::Resources::Profiles::Latest::Mgmt::Models::ResourceGroup] A new resource group object.
21
25
  class Azurerm < Kitchen::Driver::Base
22
26
  attr_accessor :resource_management_client
23
27
  attr_accessor :network_management_client
@@ -204,10 +208,18 @@ module Kitchen
204
208
  ENV["AZURE_SUBSCRIPTION_ID"]
205
209
  end
206
210
 
211
+ default_config(:public_ip_sku) do |_config|
212
+ "Basic"
213
+ end
214
+
207
215
  default_config(:azure_api_retries) do |_config|
208
216
  5
209
217
  end
210
218
 
219
+ default_config(:use_fqdn_hostname) do |_config|
220
+ false
221
+ end
222
+
211
223
  def create(state)
212
224
  state = validate_state(state)
213
225
  deployment_parameters = {
@@ -216,7 +228,7 @@ module Kitchen
216
228
  storageAccountType: config[:storage_account_type],
217
229
  bootDiagnosticsEnabled: config[:boot_diagnostics_enabled],
218
230
  newStorageAccountName: "storage#{state[:uuid]}",
219
- adminUsername: state[:username],
231
+ adminUsername: config[:username],
220
232
  dnsNameForPublicIP: "kitchen-#{state[:uuid]}",
221
233
  vmName: state[:vm_name],
222
234
  systemAssignedIdentity: config[:system_assigned_identity],
@@ -227,7 +239,13 @@ module Kitchen
227
239
  }
228
240
 
229
241
  if instance.transport[:ssh_key].nil?
230
- deployment_parameters["adminPassword"] = state[:password]
242
+ deployment_parameters[:adminPassword] = config[:password]
243
+ end
244
+
245
+ deployment_parameters[:publicIPSKU] = config[:public_ip_sku]
246
+
247
+ if config[:public_ip_sku] == "Standard"
248
+ deployment_parameters[:publicIPAddressType] = "Static"
231
249
  end
232
250
 
233
251
  if config[:subscription_id].to_s == ""
@@ -303,6 +321,9 @@ module Kitchen
303
321
  info "Creating deployment: #{deployment_name}"
304
322
  create_deployment_async(state[:azure_resource_group_name], deployment_name, deployment(deployment_parameters)).value!
305
323
  follow_deployment_until_end_state(state[:azure_resource_group_name], deployment_name)
324
+ state[:username] = deployment_parameters[:adminUsername] unless existing_state_value?(state, :username)
325
+ state[:password] = deployment_parameters[:adminPassword] unless existing_state_value?(state, :password) && instance.transport[:ssh_key].nil?
326
+
306
327
  if File.file?(config[:post_deployment_template])
307
328
  post_deployment_name = "post-deploy-#{state[:uuid]}"
308
329
  info "Creating deployment: #{post_deployment_name}"
@@ -328,6 +349,10 @@ module Kitchen
328
349
  result = get_public_ip(state[:azure_resource_group_name], "publicip")
329
350
  info "IP Address is: #{result.ip_address} [#{result.dns_settings.fqdn}]"
330
351
  state[:hostname] = result.ip_address
352
+ if config[:use_fqdn_hostname]
353
+ info "Using FQDN to communicate instead of IP"
354
+ state[:hostname] = result.dns_settings.fqdn
355
+ end
331
356
  else
332
357
  # Retrieve the internal IP from the resource group:
333
358
  result = get_network_interface(state[:azure_resource_group_name], vmnic.to_s)
@@ -336,15 +361,24 @@ module Kitchen
336
361
  end
337
362
  end
338
363
 
364
+ # Return a True of False if the state is already stored for a particular property.
365
+ #
366
+ # @param [Hash] Hash of existing state values.
367
+ # @param [String] A property to check
368
+ # @return [Boolean]
339
369
  def existing_state_value?(state, property)
340
370
  state.key?(property) && !state[property].nil?
341
371
  end
342
372
 
373
+ # Leverage existing state values or bring state into existence from a configuration file.
374
+ #
375
+ # @param [Hash] Existing Hash of state values.
376
+ # @return [Hash] Updated Hash of state values.
343
377
  def validate_state(state = {})
344
378
  state[:uuid] = SecureRandom.hex(8) unless existing_state_value?(state, :uuid)
345
379
  state[:server_id] = "vm#{state[:uuid]}" unless existing_state_value?(state, :server_id)
346
380
  state[:azure_resource_group_name] = azure_resource_group_name unless existing_state_value?(state, :azure_resource_group_name)
347
- %i{subscription_id username password vm_name azure_environment use_managed_disks}.each do |config_element|
381
+ %i{subscription_id vm_name azure_environment use_managed_disks}.each do |config_element|
348
382
  state[config_element] = config[config_element] unless existing_state_value?(state, config_element)
349
383
  end
350
384
  state.delete(:password) unless instance.transport[:ssh_key].nil?
@@ -525,11 +559,38 @@ module Kitchen
525
559
  end
526
560
 
527
561
  def destroy(state)
528
- return if state[:server_id].nil?
562
+ # TODO: We have some not so fun state issues we need to clean up
563
+ state[:azure_environment] = config[:azure_environment] unless state[:azure_environment]
564
+ state[:subscription_id] = config[:subscription_id] unless state[:subscription_id]
529
565
 
566
+ # Setup our authentication components for the SDK
530
567
  options = Kitchen::Driver::AzureCredentials.new(subscription_id: state[:subscription_id],
531
- environment: state[:azure_environment]).azure_options
568
+ environment: state[:azure_environment]).azure_options
532
569
  @resource_management_client = ::Azure::Resources::Profiles::Latest::Mgmt::Client.new(options)
570
+
571
+ # If we don't have any instances, let's check to see if the user wants to delete a resource group and if so let's delete!
572
+ if state[:server_id].nil? && state[:azure_resource_group_name].nil? && !config[:explicit_resource_group_name].nil? && config[:destroy_explicit_resource_group]
573
+ if resource_group_exists?(config[:explicit_resource_group_name])
574
+ info "This instance doesn't exist but you asked to delete the resource group."
575
+ begin
576
+ info "Destroying Resource Group: #{config[:explicit_resource_group_name]}"
577
+ delete_resource_group_async(config[:explicit_resource_group_name])
578
+ info "Destroy operation accepted and will continue in the background."
579
+ return
580
+ rescue ::MsRestAzure::AzureOperationError => operation_error
581
+ error operation_error.body
582
+ raise operation_error
583
+ end
584
+ end
585
+ end
586
+
587
+ # Our working environment
588
+ info "Azure environment: #{state[:azure_environment]}"
589
+
590
+ # Skip if we don't have any instances
591
+ return if state[:server_id].nil?
592
+
593
+ # Destroy resource group contents
533
594
  if config[:destroy_resource_group_contents] == true
534
595
  info "Destroying individual resources within the Resource Group."
535
596
  empty_deployment_name = "empty-deploy-#{state[:uuid]}"
@@ -538,32 +599,20 @@ module Kitchen
538
599
  create_deployment_async(state[:azure_resource_group_name], empty_deployment_name, empty_deployment).value!
539
600
  follow_deployment_until_end_state(state[:azure_resource_group_name], empty_deployment_name)
540
601
 
541
- # Maintain tags on the resource group
542
- if config[:destroy_explicit_resource_group_tags] == false
543
- warn 'The "destroy_explicit_resource_group_tags" setting value is set to "false". The tags on the resource group will NOT be removed.'
544
- # NOTE: We are using the internal wrapper function create_resource_group() which wraps the API
545
- # method of create_or_update().
546
- begin
547
- create_resource_group(state[:azure_resource_group_name], get_resource_group)
548
- rescue ::MsRestAzure::AzureOperationError => operation_error
549
- error operation_error.body
550
- raise operation_error
551
- end
552
- end
553
-
554
- # Corner case where we want to use kitchen to remove the tags
555
- if config[:destroy_explicit_resource_group_tags] == true
556
- warn 'The "destroy_explicit_resource_group_tags" setting value is set to "true". The tags on the resource group will be removed.'
557
- # NOTE: We are using the internal wrapper function create_resource_group() which wraps the API
558
- # method of create_or_update().
602
+ # NOTE: We are using the internal wrapper function create_resource_group() which wraps the API
603
+ # method of create_or_update()
604
+ begin
605
+ # Maintain tags on the resource group
606
+ create_resource_group(state[:azure_resource_group_name], get_resource_group) unless config[:destroy_explicit_resource_group_tags] == true
607
+ warn 'The "destroy_explicit_resource_group_tags" setting value is set to "false". The tags on the resource group will NOT be removed.' unless config[:destroy_explicit_resource_group_tags] == true
608
+ # Corner case where we want to use kitchen to remove the tags
559
609
  resource_group = get_resource_group
560
610
  resource_group.tags = {}
561
- begin
562
- create_resource_group(state[:azure_resource_group_name], resource_group)
563
- rescue ::MsRestAzure::AzureOperationError => operation_error
564
- error operation_error.body
565
- raise operation_error
566
- end
611
+ create_resource_group(state[:azure_resource_group_name], resource_group) unless config[:destroy_explicit_resource_group_tags] == false
612
+ warn 'The "destroy_explicit_resource_group_tags" setting value is set to "true". The tags on the resource group will be removed.' unless config[:destroy_explicit_resource_group_tags] == false
613
+ rescue ::MsRestAzure::AzureOperationError => operation_error
614
+ error operation_error.body
615
+ raise operation_error
567
616
  end
568
617
 
569
618
  rescue ::MsRestAzure::AzureOperationError => operation_error
@@ -571,20 +620,27 @@ module Kitchen
571
620
  raise operation_error
572
621
  end
573
622
  end
623
+
624
+ # Do not remove the explicitly named resource group
574
625
  if config[:destroy_explicit_resource_group] == false && !config[:explicit_resource_group_name].nil?
575
626
  warn 'The "destroy_explicit_resource_group" setting value is set to "false". The resource group will not be deleted.'
576
627
  warn 'Remember to manually destroy resources, or set "destroy_resource_group_contents: true" to save costs!' unless config[:destroy_resource_group_contents] == true
577
- return
628
+ return state
578
629
  end
579
- info "Azure environment: #{state[:azure_environment]}"
630
+
631
+ # Destroy the world
580
632
  begin
581
633
  info "Destroying Resource Group: #{state[:azure_resource_group_name]}"
582
634
  delete_resource_group_async(state[:azure_resource_group_name])
583
635
  info "Destroy operation accepted and will continue in the background."
636
+ # Remove resource group name from driver state
637
+ state.delete(:azure_resource_group_name)
584
638
  rescue ::MsRestAzure::AzureOperationError => operation_error
585
639
  error operation_error.body
586
640
  raise operation_error
587
641
  end
642
+
643
+ # Clear state of components
588
644
  state.delete(:server_id)
589
645
  state.delete(:hostname)
590
646
  state.delete(:username)
@@ -681,10 +737,10 @@ module Kitchen
681
737
 
682
738
  def virtual_machine_deployment_template
683
739
  if config[:vnet_id] == ""
684
- 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, use_ephemeral_osdisk: config[:use_ephemeral_osdisk], ssh_key: instance.transport[:ssh_key], plan_json: plan_json)
740
+ 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], storage_account_type: config[:storage_account_type], 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, use_ephemeral_osdisk: config[:use_ephemeral_osdisk], ssh_key: instance.transport[:ssh_key], plan_json: plan_json)
685
741
  else
686
742
  info "Using custom vnet: #{config[:vnet_id]}"
687
- 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, use_ephemeral_osdisk: config[:use_ephemeral_osdisk], ssh_key: instance.transport[:ssh_key], plan_json: plan_json)
743
+ 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], storage_account_type: config[:storage_account_type], 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, use_ephemeral_osdisk: config[:use_ephemeral_osdisk], ssh_key: instance.transport[:ssh_key], public_ip_sku: config[:public_ip_sku], plan_json: plan_json)
688
744
  end
689
745
  end
690
746
 
@@ -748,6 +804,26 @@ module Kitchen
748
804
  resource_group
749
805
  end
750
806
 
807
+ # Checks whether a resource group exists.
808
+ #
809
+ # @param resource_group_name [String] The name of the resource group to check.
810
+ # The name is case insensitive.
811
+ #
812
+ # @return [Boolean] operation results.
813
+ #
814
+ def resource_group_exists?(resource_group_name)
815
+ retries = config[:azure_api_retries]
816
+ begin
817
+ resource_management_client.resource_groups.check_existence(resource_group_name)
818
+ rescue Faraday::TimeoutError, Faraday::ClientError => exception
819
+ send_exception_message(exception, "while checking if resource group '#{resource_group_name}' exists. #{retries} retries left.")
820
+ raise if retries == 0
821
+
822
+ retries -= 1
823
+ retry
824
+ end
825
+ end
826
+
751
827
  def create_resource_group(resource_group_name, resource_group)
752
828
  retries = config[:azure_api_retries]
753
829
  begin
@@ -40,6 +40,20 @@
40
40
  "description": "Unique DNS Name for the Public IP used to access the Virtual Machine."
41
41
  }
42
42
  },
43
+ "publicIPSKU": {
44
+ "type": "string",
45
+ "defaultValue": "Basic",
46
+ "metadata": {
47
+ "description": "SKU name for the Public IP used to access the Virtual Machine."
48
+ }
49
+ },
50
+ "publicIPAddressType": {
51
+ "type": "string",
52
+ "defaultValue": "Dynamic",
53
+ "metadata": {
54
+ "description": "SKU name for the Public IP used to access the Virtual Machine."
55
+ }
56
+ },
43
57
  <%- unless os_disk_size_gb.to_s.empty? -%>
44
58
  "osDiskSizeGb": {
45
59
  "type": "int",
@@ -165,7 +179,7 @@
165
179
  },
166
180
  "storageAccountType": {
167
181
  "type": "string",
168
- "defaultValue": "Standard_LRS",
182
+ "defaultValue": "<%= storage_account_type %>",
169
183
  "metadata": {
170
184
  "description": "The type of storage to use (e.g. Standard_LRS or Premium_LRS)."
171
185
  }
@@ -201,7 +215,6 @@
201
215
  "subnetPrefix": "10.0.0.0/24",
202
216
  "storageAccountType": "[parameters('storageAccountType')]",
203
217
  "publicIPAddressName": "publicip",
204
- "publicIPAddressType": "Dynamic",
205
218
  "vmStorageAccountContainerName": "vhds",
206
219
  "vmName": "[parameters('vmName')]",
207
220
  "vmSize": "[parameters('vmSize')]",
@@ -242,12 +255,15 @@
242
255
  <%- end -%>
243
256
  <%- if public_ip -%>
244
257
  {
245
- "apiVersion": "2015-05-01-preview",
258
+ "apiVersion": "2017-08-01",
246
259
  "type": "Microsoft.Network/publicIPAddresses",
247
260
  "name": "[variables('publicIPAddressName')]",
248
261
  "location": "[variables('location')]",
262
+ "sku": {
263
+ "name": "[parameters('publicIPSKU')]"
264
+ },
249
265
  "properties": {
250
- "publicIPAllocationMethod": "[variables('publicIPAddressType')]",
266
+ "publicIPAllocationMethod": "[parameters('publicIPAddressType')]",
251
267
  "dnsSettings": {
252
268
  "domainNameLabel": "[parameters('dnsNameForPublicIP')]"
253
269
  }
@@ -343,12 +359,12 @@
343
359
  },
344
360
  <%- end -%>
345
361
  <%- if use_ephemeral_osdisk -%>
346
- "osDisk": {
347
- "diffDiskSettings": {
348
- "option": "Local"
349
- },
350
- "caching": "ReadOnly",
351
- "createOption": "FromImage"
362
+ "osDisk": {
363
+ "diffDiskSettings": {
364
+ "option": "Local"
365
+ },
366
+ "caching": "ReadOnly",
367
+ "createOption": "FromImage"
352
368
  }
353
369
  <%- elsif use_managed_disks -%>
354
370
  "osDisk": {
@@ -356,6 +372,9 @@
356
372
  <%- unless os_disk_size_gb.to_s.empty? -%>
357
373
  "diskSizeGB": "[parameters('osDiskSizeGB')]",
358
374
  <%- end -%>
375
+ "managedDisk": {
376
+ "storageAccountType": "[parameters('storageAccountType')]"
377
+ },
359
378
  "createOption": "FromImage"
360
379
  }
361
380
  <%- else -%>
data/templates/public.erb CHANGED
@@ -163,9 +163,23 @@
163
163
  "description": "The nic name created inside of the resource group."
164
164
  }
165
165
  },
166
+ "publicIPSKU": {
167
+ "type": "string",
168
+ "defaultValue": "Basic",
169
+ "metadata": {
170
+ "description": "SKU name for the Public IP used to access the Virtual Machine."
171
+ }
172
+ },
173
+ "publicIPAddressType": {
174
+ "type": "string",
175
+ "defaultValue": "Dynamic",
176
+ "metadata": {
177
+ "description": "SKU name for the Public IP used to access the Virtual Machine."
178
+ }
179
+ },
166
180
  "storageAccountType": {
167
181
  "type": "string",
168
- "defaultValue": "Standard_LRS",
182
+ "defaultValue": "<%= storage_account_type %>",
169
183
  "metadata": {
170
184
  "description": "The type of storage to use (e.g. Standard_LRS or Premium_LRS)."
171
185
  }
@@ -201,7 +215,6 @@
201
215
  "subnetPrefix": "10.0.0.0/24",
202
216
  "storageAccountType": "[parameters('storageAccountType')]",
203
217
  "publicIPAddressName": "publicip",
204
- "publicIPAddressType": "Dynamic",
205
218
  "vmStorageAccountContainerName": "vhds",
206
219
  "vmName": "[parameters('vmName')]",
207
220
  "vmSize": "[parameters('vmSize')]",
@@ -213,7 +226,7 @@
213
226
  "resources": [
214
227
  {
215
228
  "apiVersion": "2017-05-10",
216
- "name": "pid-18d63047-6cdf-4f34-beed-62f01fc73fc2",
229
+ "name": "pid-18d63047-6cdf-4f34-beed-62f01fc73fc2",
217
230
  "type": "Microsoft.Resources/deployments",
218
231
  "properties": {
219
232
  "mode": "Incremental",
@@ -241,16 +254,19 @@
241
254
  <%- end -%>
242
255
  <%- end -%>
243
256
  {
244
- "apiVersion": "2015-05-01-preview",
257
+ "apiVersion": "2017-08-01",
245
258
  "type": "Microsoft.Network/publicIPAddresses",
246
259
  "name": "[variables('publicIPAddressName')]",
247
260
  "location": "[variables('location')]",
248
261
  "properties": {
249
- "publicIPAllocationMethod": "[variables('publicIPAddressType')]",
262
+ "publicIPAllocationMethod": "[parameters('publicIPAddressType')]",
250
263
  "dnsSettings": {
251
264
  "domainNameLabel": "[parameters('dnsNameForPublicIP')]"
252
265
  }
253
266
  },
267
+ "sku": {
268
+ "name": "[parameters('publicIPSKU')]"
269
+ },
254
270
  "tags": {
255
271
  <%= vm_tags unless vm_tags.empty? %>
256
272
  }
@@ -362,12 +378,12 @@
362
378
  },
363
379
  <%- end -%>
364
380
  <%- if use_ephemeral_osdisk -%>
365
- "osDisk": {
366
- "diffDiskSettings": {
367
- "option": "Local"
368
- },
369
- "caching": "ReadOnly",
370
- "createOption": "FromImage"
381
+ "osDisk": {
382
+ "diffDiskSettings": {
383
+ "option": "Local"
384
+ },
385
+ "caching": "ReadOnly",
386
+ "createOption": "FromImage"
371
387
  }
372
388
  <%- elsif use_managed_disks -%>
373
389
  "osDisk": {
@@ -375,6 +391,9 @@
375
391
  <%- unless os_disk_size_gb.to_s.empty? -%>
376
392
  "diskSizeGB": "[parameters('osDiskSizeGB')]",
377
393
  <%- end -%>
394
+ "managedDisk": {
395
+ "storageAccountType": "[parameters('storageAccountType')]"
396
+ },
378
397
  "createOption": "FromImage"
379
398
  }
380
399
  <%- else -%>
@@ -405,7 +424,7 @@
405
424
  }
406
425
  <%- end -%>
407
426
  <%- unless data_disks_for_vm_json.nil? -%>
408
- ,"dataDisks":
427
+ ,"dataDisks":
409
428
  <%= data_disks_for_vm_json %>
410
429
  <%- end -%>
411
430
  },
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: 1.3.0
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Preston
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-09 00:00:00.000000000 Z
11
+ date: 2021-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: azure_mgmt_network
@@ -110,90 +110,6 @@ dependencies:
110
110
  - - "<"
111
111
  - !ruby/object:Gem::Version
112
112
  version: '3.0'
113
- - !ruby/object:Gem::Dependency
114
- name: rake
115
- requirement: !ruby/object:Gem::Requirement
116
- requirements:
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- version: '11.0'
120
- type: :development
121
- prerelease: false
122
- version_requirements: !ruby/object:Gem::Requirement
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- version: '11.0'
127
- - !ruby/object:Gem::Dependency
128
- name: chefstyle
129
- requirement: !ruby/object:Gem::Requirement
130
- requirements:
131
- - - '='
132
- - !ruby/object:Gem::Version
133
- version: 1.2.1
134
- type: :development
135
- prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- requirements:
138
- - - '='
139
- - !ruby/object:Gem::Version
140
- version: 1.2.1
141
- - !ruby/object:Gem::Dependency
142
- name: rspec
143
- requirement: !ruby/object:Gem::Requirement
144
- requirements:
145
- - - "~>"
146
- - !ruby/object:Gem::Version
147
- version: '3.5'
148
- type: :development
149
- prerelease: false
150
- version_requirements: !ruby/object:Gem::Requirement
151
- requirements:
152
- - - "~>"
153
- - !ruby/object:Gem::Version
154
- version: '3.5'
155
- - !ruby/object:Gem::Dependency
156
- name: rspec-mocks
157
- requirement: !ruby/object:Gem::Requirement
158
- requirements:
159
- - - "~>"
160
- - !ruby/object:Gem::Version
161
- version: '3.5'
162
- type: :development
163
- prerelease: false
164
- version_requirements: !ruby/object:Gem::Requirement
165
- requirements:
166
- - - "~>"
167
- - !ruby/object:Gem::Version
168
- version: '3.5'
169
- - !ruby/object:Gem::Dependency
170
- name: rspec-expectations
171
- requirement: !ruby/object:Gem::Requirement
172
- requirements:
173
- - - "~>"
174
- - !ruby/object:Gem::Version
175
- version: '3.5'
176
- type: :development
177
- prerelease: false
178
- version_requirements: !ruby/object:Gem::Requirement
179
- requirements:
180
- - - "~>"
181
- - !ruby/object:Gem::Version
182
- version: '3.5'
183
- - !ruby/object:Gem::Dependency
184
- name: rspec-its
185
- requirement: !ruby/object:Gem::Requirement
186
- requirements:
187
- - - "~>"
188
- - !ruby/object:Gem::Version
189
- version: 1.3.0
190
- type: :development
191
- prerelease: false
192
- version_requirements: !ruby/object:Gem::Requirement
193
- requirements:
194
- - - "~>"
195
- - !ruby/object:Gem::Version
196
- version: 1.3.0
197
113
  description: Test Kitchen driver for the Microsoft Azure Resource Manager (ARM) API
198
114
  email:
199
115
  - stuart@chef.io
@@ -220,14 +136,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
220
136
  requirements:
221
137
  - - ">="
222
138
  - !ruby/object:Gem::Version
223
- version: '0'
139
+ version: '2.5'
224
140
  required_rubygems_version: !ruby/object:Gem::Requirement
225
141
  requirements:
226
142
  - - ">="
227
143
  - !ruby/object:Gem::Version
228
144
  version: '0'
229
145
  requirements: []
230
- rubygems_version: 3.1.2
146
+ rubygems_version: 3.1.4
231
147
  signing_key:
232
148
  specification_version: 4
233
149
  summary: Test Kitchen driver for Azure Resource Manager.