kitchen-azurerm 1.4.0 → 1.6.0

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: 51b127c1a7e5d1c197dde573ce77d5e9900fe2297d12e5d8cbcd4d6d1e328ccc
4
- data.tar.gz: d59c1a55f910f415a271a4818a8879a16e06dff3192d3d3a64d5ce1c32313e6c
3
+ metadata.gz: a47e2282b156031bc220f784b2fc11d9e689450a1681bcab96e00edf4c40d075
4
+ data.tar.gz: 69d729b824fdb55d6849dcd602be3729079bb12db1f51b729d9f1b4635df5c73
5
5
  SHA512:
6
- metadata.gz: 1e21e9a0cce3a113f9d6fd9206a9272282eb1d54c637e2c9f5b629a42ccbf144889355d18db7127a7693e088d8056005139cdf142e3232ed70870c72b23db3f0
7
- data.tar.gz: '0690d8abddf2c745c7631e463e7479299a0e1e8a83af57caca797e8555a840bc0559c383d7d703b35c7bb7ec4c65b7556a15e95cf2b4582c153f8e45d0dd97e9'
6
+ metadata.gz: f18774a15ca7ee6b741ebb1a07f8e0e9d684a1253424c3a8d5589f029eacab23bf6e647264e05bbcebaf1401b3182a3c20cf1ce74ef80c4b349880971efa1ee1
7
+ data.tar.gz: '059138541c0d19ffc591fad58292eececc2f70e1b4dfca5a3a5352c7a612b240505e28e34966132b413fdb74331dfd4fd0b607716c8fec0630157fb4bb69ca84'
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: `"tk-#{SecureRandom.hex(6)[0..11]}"` (Randomly generated 12 character name prefixed with `tk-`)
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,70 +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"] %>```. The ```destroy_explicit_resource_group``` option can now be used after using the ```destroy_resource_group_contents``` option creates an empty resource group to destroy the resource group previously created.
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. 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.
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 ```explicit_resource_group_name``` 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
- * The ```use_fqdn_hostname``` (default: "false") parameter can be used to determine how kitchen communicates with the Virtual Machine. 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.
692
-
693
- ## Enabling alternative WinRM configurations
694
-
695
- * 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:
696
-
697
- ```yaml
698
- platforms:
699
- - name: windows2008-r2
700
- driver_config:
701
- image_urn: MicrosoftWindowsServer:WindowsServer:2008-R2-SP1:latest
702
- winrm_powershell_script: |-
703
- winrm quickconfig -q
704
- winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="512"}'
705
- winrm set winrm/config '@{MaxTimeoutms="1800000"}'
706
- winrm set winrm/config/service '@{AllowUnencrypted="true"}'
707
- winrm set winrm/config/service/auth '@{Basic="true"}'
708
-
709
- ```
710
-
711
929
  ## Contributing
712
930
 
713
931
  Contributions to the project are welcome via submitting Pull Requests.
@@ -724,7 +942,7 @@ Stuart Preston
724
942
 
725
943
  ## License and Copyright
726
944
 
727
- Copyright 2015-2020, Chef Software, Inc.
945
+ Copyright 2015-2021, Chef Software, Inc.
728
946
 
729
947
  ```
730
948
  Licensed under the Apache License, Version 2.0 (the "License");
@@ -84,9 +84,7 @@ module Kitchen
84
84
  SecureRandom.base64(25)
85
85
  end
86
86
 
87
- default_config(:vm_name) do |_config|
88
- "vm"
89
- end
87
+ default_config :vm_name, nil
90
88
 
91
89
  default_config(:nic_name) do |_config|
92
90
  ""
@@ -208,6 +206,10 @@ module Kitchen
208
206
  ENV["AZURE_SUBSCRIPTION_ID"]
209
207
  end
210
208
 
209
+ default_config(:public_ip_sku) do |_config|
210
+ "Basic"
211
+ end
212
+
211
213
  default_config(:azure_api_retries) do |_config|
212
214
  5
213
215
  end
@@ -238,12 +240,18 @@ module Kitchen
238
240
  deployment_parameters[:adminPassword] = config[:password]
239
241
  end
240
242
 
243
+ deployment_parameters[:publicIPSKU] = config[:public_ip_sku]
244
+
245
+ if config[:public_ip_sku] == "Standard"
246
+ deployment_parameters[:publicIPAddressType] = "Static"
247
+ end
248
+
241
249
  if config[:subscription_id].to_s == ""
242
250
  raise "A subscription_id config value was not detected and kitchen-azurerm cannot continue. Please check your kitchen.yml configuration. Exiting."
243
251
  end
244
252
 
245
253
  if config[:nic_name].to_s == ""
246
- vmnic = "nic-#{config[:vm_name]}"
254
+ vmnic = "nic-#{state[:vm_name]}"
247
255
  else
248
256
  vmnic = config[:nic_name]
249
257
  end
@@ -366,9 +374,10 @@ module Kitchen
366
374
  # @return [Hash] Updated Hash of state values.
367
375
  def validate_state(state = {})
368
376
  state[:uuid] = SecureRandom.hex(8) unless existing_state_value?(state, :uuid)
377
+ state[:vm_name] = config[:vm_name] || "tk-#{state[:uuid][0..11]}" unless existing_state_value?(state, :vm_name)
369
378
  state[:server_id] = "vm#{state[:uuid]}" unless existing_state_value?(state, :server_id)
370
379
  state[:azure_resource_group_name] = azure_resource_group_name unless existing_state_value?(state, :azure_resource_group_name)
371
- %i{subscription_id vm_name azure_environment use_managed_disks}.each do |config_element|
380
+ %i{subscription_id azure_environment use_managed_disks}.each do |config_element|
372
381
  state[config_element] = config[config_element] unless existing_state_value?(state, config_element)
373
382
  end
374
383
  state.delete(:password) unless instance.transport[:ssh_key].nil?
@@ -727,10 +736,10 @@ module Kitchen
727
736
 
728
737
  def virtual_machine_deployment_template
729
738
  if config[:vnet_id] == ""
730
- 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)
739
+ 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)
731
740
  else
732
741
  info "Using custom vnet: #{config[:vnet_id]}"
733
- 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)
742
+ 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)
734
743
  end
735
744
  end
736
745
 
@@ -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.4.0
4
+ version: 1.6.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: 2020-09-29 00:00:00.000000000 Z
11
+ date: 2021-03-19 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.4.2
134
- type: :development
135
- prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- requirements:
138
- - - '='
139
- - !ruby/object:Gem::Version
140
- version: 1.4.2
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.