kitchen-azurerm 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +113 -110
- data/LICENSE +202 -202
- data/README.md +504 -504
- data/lib/kitchen/driver/azurerm.rb +552 -556
- data/lib/kitchen/driver/credentials.rb +69 -61
- data/templates/internal.erb +350 -350
- data/templates/public.erb +368 -368
- metadata +29 -29
data/README.md
CHANGED
@@ -1,504 +1,504 @@
|
|
1
|
-
# kitchen-azurerm
|
2
|
-
|
3
|
-
**kitchen-azurerm** is a driver for the popular test harness [Test Kitchen](http://kitchen.ci) that allows Microsoft Azure resources to be provisioned prior to 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).
|
4
|
-
|
5
|
-
[![Gem Version](https://badge.fury.io/rb/kitchen-azurerm.svg)](http://badge.fury.io/rb/kitchen-azurerm) [![Build Status](https://travis-ci.org/test-kitchen/kitchen-azurerm.svg)](https://travis-ci.org/test-kitchen/kitchen-azurerm)
|
6
|
-
|
7
|
-
This version has been tested on Windows, OS/X and Ubuntu. If you encounter a problem on your platform, please raise an issue.
|
8
|
-
|
9
|
-
## Quick-start
|
10
|
-
|
11
|
-
### Installation
|
12
|
-
|
13
|
-
This plugin is distributed as a [Ruby Gem](https://rubygems.org/gems/kitchen-azurerm). To install it, run:
|
14
|
-
|
15
|
-
```$ gem install kitchen-azurerm```
|
16
|
-
|
17
|
-
Note if you are running the ChefDK you may need to prefix the command with chef, i.e. ```$ chef gem install kitchen-azurerm```
|
18
|
-
|
19
|
-
### Configuration
|
20
|
-
|
21
|
-
For the driver to interact with the Microsoft Azure Resource management REST API, a Service Principal needs to be configured with Contributor rights against the specific subscription being targeted. Using an Organizational (AAD) account and related password is no longer supported. To create a Service Principal and apply the correct permissions, you will need to [create and authenticate a service principal](https://azure.microsoft.com/en-us/documentation/articles/resource-group-authenticate-service-principal/#authenticate-service-principal-with-password---azure-cli) using the [Azure CLI](https://azure.microsoft.com/en-us/documentation/articles/xplat-cli-install/). Make sure you stay within the section titled 'Authenticate service principal with password - Azure CLI'.
|
22
|
-
|
23
|
-
You will also need to ensure you have an active Azure subscription (you can get started [for free](https://azure.microsoft.com/en-us/free/) or use your [MSDN Subscription](https://azure.microsoft.com/en-us/pricing/member-offers/msdn-benefits/)).
|
24
|
-
|
25
|
-
You are now ready to configure kitchen-azurerm to use the credentials from the service principal you created above. You will use four elements from the steps in that article:
|
26
|
-
|
27
|
-
1. **Subscription ID**: available from the Azure portal
|
28
|
-
2. **Client ID**: this will be the Application Id from the application in step 2.
|
29
|
-
3. **Client Secret/Password**: this will be the password you supplied in the command in step 2.
|
30
|
-
4. **Tenant ID**: use the command detailed in "Manually provide credentials through Azure CLI" step 1 to get the TenantId.
|
31
|
-
|
32
|
-
Using a text editor, open or create the file ```~/.azure/credentials``` and add the following section, noting there is one section per Subscription ID. **Make sure you save the file with UTF-8 encoding**
|
33
|
-
|
34
|
-
```ruby
|
35
|
-
[abcd1234-YOUR-SUBSCRIPTION-ID-HERE-abcdef123456]
|
36
|
-
client_id = "48b9bba3-YOUR-GUID-HERE-90f0b68ce8ba"
|
37
|
-
client_secret = "your-client-secret-here"
|
38
|
-
tenant_id = "9c117323-YOUR-GUID-HERE-9ee430723ba3"
|
39
|
-
```
|
40
|
-
|
41
|
-
If preferred, you may also set the following environment variables, however this would be incompatible with supporting multiple Azure subscriptions.
|
42
|
-
|
43
|
-
```ruby
|
44
|
-
AZURE_CLIENT_ID="48b9bba3-YOUR-GUID-HERE-90f0b68ce8ba"
|
45
|
-
AZURE_CLIENT_SECRET="your-client-secret-here"
|
46
|
-
AZURE_TENANT_ID="9c117323-YOUR-GUID-HERE-9ee430723ba3"
|
47
|
-
```
|
48
|
-
|
49
|
-
Note that the environment variables, if set, take preference over the values in a configuration file.
|
50
|
-
|
51
|
-
### .kitchen.yml example 1 - Linux/Ubuntu
|
52
|
-
|
53
|
-
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.
|
54
|
-
|
55
|
-
```yaml
|
56
|
-
---
|
57
|
-
driver:
|
58
|
-
name: azurerm
|
59
|
-
|
60
|
-
driver_config:
|
61
|
-
subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
|
62
|
-
location: 'West Europe'
|
63
|
-
machine_size: 'Standard_D1'
|
64
|
-
|
65
|
-
transport:
|
66
|
-
ssh_key: ~/.ssh/id_kitchen-azurerm
|
67
|
-
|
68
|
-
provisioner:
|
69
|
-
name: chef_zero
|
70
|
-
|
71
|
-
platforms:
|
72
|
-
- name: ubuntu-14.04
|
73
|
-
driver_config:
|
74
|
-
image_urn: Canonical:UbuntuServer:14.04.4-LTS:latest
|
75
|
-
vm_name: trusty-vm
|
76
|
-
vm_tags:
|
77
|
-
ostype: linux
|
78
|
-
distro: ubuntu
|
79
|
-
|
80
|
-
suites:
|
81
|
-
- name: default
|
82
|
-
run_list:
|
83
|
-
- recipe[kitchentesting::default]
|
84
|
-
attributes:
|
85
|
-
```
|
86
|
-
|
87
|
-
### Concurrent execution
|
88
|
-
Concurrent execution of create/converge/destroy is supported via the --concurrency parameter. Each machine is created in it's own Azure Resource Group so has no shared lifecycle with the other machines in the test run. To take advantage of parallel execution use the following command:
|
89
|
-
|
90
|
-
```kitchen test --concurrency <n>```
|
91
|
-
|
92
|
-
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.
|
93
|
-
|
94
|
-
### .kitchen.yml example 2 - Windows
|
95
|
-
|
96
|
-
Here's a further example ```.kitchen.yml``` file that will provision a Windows Server 2012 R2 instance, using WinRM as the transport. The resource created in Azure will enable itself for remote access at deployment time (it does this by customizing the machine at provisioning time):
|
97
|
-
|
98
|
-
```yaml
|
99
|
-
---
|
100
|
-
driver:
|
101
|
-
name: azurerm
|
102
|
-
|
103
|
-
driver_config:
|
104
|
-
subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
|
105
|
-
location: 'West Europe'
|
106
|
-
machine_size: 'Standard_D1'
|
107
|
-
|
108
|
-
provisioner:
|
109
|
-
name: chef_zero
|
110
|
-
|
111
|
-
platforms:
|
112
|
-
- name: windows2012-r2
|
113
|
-
driver_config:
|
114
|
-
image_urn: MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:latest
|
115
|
-
transport:
|
116
|
-
name: winrm
|
117
|
-
suites:
|
118
|
-
- name: default
|
119
|
-
run_list:
|
120
|
-
- recipe[kitchentesting::default]
|
121
|
-
attributes:
|
122
|
-
```
|
123
|
-
|
124
|
-
### .kitchen.yml example 3 - "pre-deployment" ARM template
|
125
|
-
|
126
|
-
The following example introduces the ```pre_deployment_template``` and ```pre_deployment_parameters``` properties in the configuration file.
|
127
|
-
You can use this capability to execute an ARM template containing Azure resources to provision before the system under test is created.
|
128
|
-
|
129
|
-
In the example the ARM template in the file ```predeploy.json``` would be executed with the parameters that are specified under ```pre_deployment_parameters```.
|
130
|
-
These resources will be created in the same Azure Resource Group as the VM under test, and therefore will be destroyed when you type ```kitchen destroy```.
|
131
|
-
|
132
|
-
```yaml
|
133
|
-
---
|
134
|
-
driver:
|
135
|
-
name: azurerm
|
136
|
-
|
137
|
-
driver_config:
|
138
|
-
subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
|
139
|
-
location: 'West Europe'
|
140
|
-
machine_size: 'Standard_D1'
|
141
|
-
pre_deployment_template: predeploy.json
|
142
|
-
pre_deployment_parameters:
|
143
|
-
test_parameter: 'This is a test.'
|
144
|
-
|
145
|
-
transport:
|
146
|
-
ssh_key: ~/.ssh/id_kitchen-azurerm
|
147
|
-
|
148
|
-
provisioner:
|
149
|
-
name: chef_zero
|
150
|
-
|
151
|
-
platforms:
|
152
|
-
- name: ubuntu-1404
|
153
|
-
driver_config:
|
154
|
-
image_urn: Canonical:UbuntuServer:14.04.4-LTS:latest
|
155
|
-
|
156
|
-
suites:
|
157
|
-
- name: default
|
158
|
-
run_list:
|
159
|
-
- recipe[kitchen-azurerm-demo::default]
|
160
|
-
attributes:
|
161
|
-
```
|
162
|
-
|
163
|
-
Example predeploy.json:
|
164
|
-
|
165
|
-
```json
|
166
|
-
{
|
167
|
-
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
168
|
-
"contentVersion": "1.0.0.0",
|
169
|
-
"parameters": {
|
170
|
-
"test_parameter": {
|
171
|
-
"type": "string",
|
172
|
-
"defaultValue": ""
|
173
|
-
}
|
174
|
-
},
|
175
|
-
"variables": {
|
176
|
-
|
177
|
-
},
|
178
|
-
"resources": [
|
179
|
-
{
|
180
|
-
"name": "uniqueinstancenamehere01",
|
181
|
-
"type": "Microsoft.Sql/servers",
|
182
|
-
"location": "[resourceGroup().location]",
|
183
|
-
"apiVersion": "2014-04-01-preview",
|
184
|
-
"properties": {
|
185
|
-
"version": "12.0",
|
186
|
-
"administratorLogin": "azure",
|
187
|
-
"administratorLoginPassword": "P2ssw0rd"
|
188
|
-
}
|
189
|
-
}
|
190
|
-
],
|
191
|
-
"outputs": {
|
192
|
-
"parameter testing": {
|
193
|
-
"type": "string",
|
194
|
-
"value": "[parameters('test_parameter')]"
|
195
|
-
}
|
196
|
-
}
|
197
|
-
}
|
198
|
-
```
|
199
|
-
|
200
|
-
### .kitchen.yml example 4 - deploy VM to existing virtual network/subnet (use for ExpressRoute/VPN scenarios)
|
201
|
-
|
202
|
-
The following example introduces the ```vnet_id``` and ```subnet_id``` properties under driver_config in the configuration file. This can be applied at the top level, or per platform.
|
203
|
-
You can use this capability to create the VM on an existing virtual network and subnet created in a different resource group.
|
204
|
-
|
205
|
-
In this case, the public IP address is not used unless ```public_ip``` is set to ```true```
|
206
|
-
|
207
|
-
|
208
|
-
```yaml
|
209
|
-
---
|
210
|
-
driver:
|
211
|
-
name: azurerm
|
212
|
-
|
213
|
-
driver_config:
|
214
|
-
subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
|
215
|
-
location: 'West Europe'
|
216
|
-
machine_size: 'Standard_D1'
|
217
|
-
|
218
|
-
transport:
|
219
|
-
ssh_key: ~/.ssh/id_kitchen-azurerm
|
220
|
-
|
221
|
-
provisioner:
|
222
|
-
name: chef_zero
|
223
|
-
|
224
|
-
platforms:
|
225
|
-
- name: ubuntu-1404
|
226
|
-
driver_config:
|
227
|
-
image_urn: Canonical:UbuntuServer:14.04.4-LTS:latest
|
228
|
-
vnet_id: /subscriptions/b6e7eee9-YOUR-GUID-HERE-03ab624df016/resourceGroups/pendrica-infrastructure/providers/Microsoft.Network/virtualNetworks/pendrica-arm-vnet
|
229
|
-
subnet_id: subnet-10.1.0
|
230
|
-
|
231
|
-
suites:
|
232
|
-
- name: default
|
233
|
-
run_list:
|
234
|
-
- recipe[kitchen-azurerm-demo::default]
|
235
|
-
attributes:
|
236
|
-
```
|
237
|
-
|
238
|
-
### .kitchen.yml example 5 - deploy VM to existing virtual network/subnet (use for ExpressRoute/VPN scenarios) with Private Managed Image
|
239
|
-
|
240
|
-
This example is the same as above, but uses a private managed image to provision the vm.
|
241
|
-
|
242
|
-
Note: The image must be available first. On deletion the disk and everything is removed.
|
243
|
-
|
244
|
-
```yaml
|
245
|
-
---
|
246
|
-
driver:
|
247
|
-
name: azurerm
|
248
|
-
|
249
|
-
driver_config:
|
250
|
-
subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
|
251
|
-
location: 'West Europe'
|
252
|
-
machine_size: 'Standard_D1'
|
253
|
-
|
254
|
-
transport:
|
255
|
-
ssh_key: ~/.ssh/id_kitchen-azurerm
|
256
|
-
|
257
|
-
provisioner:
|
258
|
-
name: chef_zero
|
259
|
-
|
260
|
-
platforms:
|
261
|
-
- name: ubuntu-1404
|
262
|
-
driver_config:
|
263
|
-
image_id: /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/RESGROUP/providers/Microsoft.Compute/images/IMAGENAME
|
264
|
-
vnet_id: /subscriptions/b6e7eee9-YOUR-GUID-HERE-03ab624df016/resourceGroups/pendrica-infrastructure/providers/Microsoft.Network/virtualNetworks/pendrica-arm-vnet
|
265
|
-
subnet_id: subnet-10.1.0
|
266
|
-
use_managed_disk: true
|
267
|
-
|
268
|
-
|
269
|
-
suites:
|
270
|
-
- name: default
|
271
|
-
run_list:
|
272
|
-
- recipe[kitchen-azurerm-demo::default]
|
273
|
-
attributes:
|
274
|
-
```
|
275
|
-
|
276
|
-
### .kitchen.yml example 6 - deploy VM to existing virtual network/subnet (use for ExpressRoute/VPN scenarios) with Private Classic OS Image
|
277
|
-
|
278
|
-
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.
|
279
|
-
|
280
|
-
Note: When the resource group ís deleted, the os disk is left in the extsing storage account blob. You must cleanup manually.
|
281
|
-
|
282
|
-
This example will:
|
283
|
-
|
284
|
-
* use the customized image https://yourstorageaccount.blob.core.windows.net/system/Microsoft.Compute/Images/images/Cent7_P4-osDisk.170dd1b7-7dc3-4496-b248-f47c49f63965.vhd (can be built with packer)
|
285
|
-
* set the disk url of the vm to https://yourstorageaccount.blob.core.windows.net/vhds/osdisk-kitchen-XXXXX.vhd
|
286
|
-
* set the os type to linux
|
287
|
-
|
288
|
-
|
289
|
-
```yaml
|
290
|
-
---
|
291
|
-
driver:
|
292
|
-
name: azurerm
|
293
|
-
|
294
|
-
driver_config:
|
295
|
-
subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
|
296
|
-
location: 'West Europe'
|
297
|
-
machine_size: 'Standard_D1'
|
298
|
-
|
299
|
-
transport:
|
300
|
-
ssh_key: ~/.ssh/id_kitchen-azurerm
|
301
|
-
|
302
|
-
provisioner:
|
303
|
-
name: chef_zero
|
304
|
-
|
305
|
-
platforms:
|
306
|
-
- name: ubuntu-1404
|
307
|
-
driver_config:
|
308
|
-
image_url: https://yourstorageaccount.blob.core.windows.net/system/Microsoft.Compute/Images/images/Cent7_P4-osDisk.170dd1b7-7dc3-4496-b248-f47c49f63965.vhd
|
309
|
-
existing_storage_account_blob_url: https://yourstorageaccount.blob.core.windows.net
|
310
|
-
os_type: linux
|
311
|
-
use_managed_disk: false
|
312
|
-
vnet_id: /subscriptions/b6e7eee9-YOUR-GUID-HERE-03ab624df016/resourceGroups/pendrica-infrastructure/providers/Microsoft.Network/virtualNetworks/pendrica-arm-vnet
|
313
|
-
subnet_id: subnet-10.1.0
|
314
|
-
|
315
|
-
suites:
|
316
|
-
- name: default
|
317
|
-
run_list:
|
318
|
-
- recipe[kitchen-azurerm-demo::default]
|
319
|
-
attributes:
|
320
|
-
```
|
321
|
-
|
322
|
-
### .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
|
323
|
-
|
324
|
-
This is the same as above, but uses custom data to customize the instance.
|
325
|
-
|
326
|
-
Note: Custom data can be custom data or a file to custom data. Please also note that if you use winrm communication to non-nano windows servers custom data is not supported, as winrm is enabled via custom data.
|
327
|
-
|
328
|
-
|
329
|
-
```yaml
|
330
|
-
---
|
331
|
-
driver:
|
332
|
-
name: azurerm
|
333
|
-
|
334
|
-
driver_config:
|
335
|
-
subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
|
336
|
-
location: 'West Europe'
|
337
|
-
machine_size: 'Standard_D1'
|
338
|
-
|
339
|
-
transport:
|
340
|
-
ssh_key: ~/.ssh/id_kitchen-azurerm
|
341
|
-
|
342
|
-
provisioner:
|
343
|
-
name: chef_zero
|
344
|
-
|
345
|
-
platforms:
|
346
|
-
- name: ubuntu-1404
|
347
|
-
driver_config:
|
348
|
-
image_url: https://yourstorageaccount.blob.core.windows.net/system/Microsoft.Compute/Images/images/Cent7_P4-osDisk.170dd1b7-7dc3-4496-b248-f47c49f63965.vhd
|
349
|
-
existing_storage_account_blob_url: https://yourstorageaccount.blob.core.windows.net
|
350
|
-
os_type: linux
|
351
|
-
use_managed_disk: false
|
352
|
-
vnet_id: /subscriptions/b6e7eee9-YOUR-GUID-HERE-03ab624df016/resourceGroups/pendrica-infrastructure/providers/Microsoft.Network/virtualNetworks/pendrica-arm-vnet
|
353
|
-
subnet_id: subnet-10.1.0
|
354
|
-
os_disk_size_gb: 100
|
355
|
-
#custom_data: /tmp/customdata.txt
|
356
|
-
custom_data: |
|
357
|
-
#cloud-config
|
358
|
-
fqdn: myhostname
|
359
|
-
preserve_hostname: false
|
360
|
-
runcmd:
|
361
|
-
- yum install -y telnet
|
362
|
-
|
363
|
-
suites:
|
364
|
-
- name: default
|
365
|
-
run_list:
|
366
|
-
- recipe[kitchen-azurerm-demo::default]
|
367
|
-
attributes:
|
368
|
-
```
|
369
|
-
|
370
|
-
### .kitchen.yml example 8 - Windows 2016 VM with additional data disks:
|
371
|
-
|
372
|
-
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.
|
373
|
-
|
374
|
-
Note the availability of a `format_data_disks` option (default: `false`). When set to true, a PowerShell script will execute at first boot to initialize and format the disks with an NTFS filesystem. This option has no effect on Linux machines.
|
375
|
-
|
376
|
-
```yaml
|
377
|
-
---
|
378
|
-
driver:
|
379
|
-
name: azurerm
|
380
|
-
|
381
|
-
driver_config:
|
382
|
-
subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
|
383
|
-
location: 'West Europe'
|
384
|
-
machine_size: 'Standard_F2s'
|
385
|
-
|
386
|
-
provisioner:
|
387
|
-
name: chef_zero
|
388
|
-
|
389
|
-
platforms:
|
390
|
-
- name: windows2016-noformat
|
391
|
-
driver_config:
|
392
|
-
image_urn: MicrosoftWindowsServer:WindowsServer:2016-Datacenter:latest
|
393
|
-
data_disks:
|
394
|
-
- lun: 0
|
395
|
-
disk_size_gb: 128
|
396
|
-
- lun: 1
|
397
|
-
disk_size_gb: 128
|
398
|
-
- lun: 2
|
399
|
-
disk_size_gb: 128
|
400
|
-
# format_data_disks: false
|
401
|
-
|
402
|
-
suites:
|
403
|
-
- name: default
|
404
|
-
run_list:
|
405
|
-
- recipe[kitchentesting::default]
|
406
|
-
attributes:
|
407
|
-
```
|
408
|
-
|
409
|
-
## Support for Government and Sovereign Clouds (China and Germany)
|
410
|
-
|
411
|
-
Starting with v0.9.0 this driver has support for Azure Government and Sovereign Clouds via the use of the ```azure_environment``` setting. Valid Azure environments are ```Azure```, ```AzureUSGovernment```, ```AzureChina``` and ```AzureGermanCloud```
|
412
|
-
|
413
|
-
Note that the ```use_managed_disks``` option should be set to false until supported by AzureUSGovernment.
|
414
|
-
|
415
|
-
### Example .kitchen.yml for Azure US Government cloud
|
416
|
-
|
417
|
-
```yaml
|
418
|
-
---
|
419
|
-
driver:
|
420
|
-
name: azurerm
|
421
|
-
|
422
|
-
driver_config:
|
423
|
-
subscription_id: 'abcdabcd-YOUR-GUID-HERE-abcdabcdabcd'
|
424
|
-
azure_environment: 'AzureUSGovernment'
|
425
|
-
location: 'US Gov Iowa'
|
426
|
-
machine_size: 'Standard_D2_v2_Promo'
|
427
|
-
use_managed_disks: false
|
428
|
-
|
429
|
-
provisioner:
|
430
|
-
name: chef_zero
|
431
|
-
|
432
|
-
verifier:
|
433
|
-
name: inspec
|
434
|
-
|
435
|
-
platforms:
|
436
|
-
- name: ubuntu1604
|
437
|
-
driver_config:
|
438
|
-
image_urn: Canonical:UbuntuServer:16.04-LTS:latest
|
439
|
-
transport:
|
440
|
-
ssh_key: ~/.ssh/id_kitchen-azurerm
|
441
|
-
|
442
|
-
suites:
|
443
|
-
- name: default
|
444
|
-
run_list:
|
445
|
-
- recipe[vmtesting::default]
|
446
|
-
```
|
447
|
-
|
448
|
-
### How to retrieve the image_urn
|
449
|
-
You can use the azure (azure-cli) command line tools to interrogate for the Urn. All 4 parts of the Urn must be specified, though the last part can be changed to "latest" to indicate you always wish to provision the latest operating system and patches.
|
450
|
-
|
451
|
-
```$ azure vm image list "West Europe" Canonical UbuntuServer```
|
452
|
-
|
453
|
-
This will return a list like the following, from which you can derive the Urn.
|
454
|
-
*this list has been shortened for readability*
|
455
|
-
|
456
|
-
```
|
457
|
-
data: Publisher Offer Sku Version Location Urn
|
458
|
-
data: --------- ------------ ----------------- --------------- ---------- --------------------------------------------------------
|
459
|
-
data: Canonical UbuntuServer 12.04.5-LTS 12.04.201507301 westeurope Canonical:UbuntuServer:12.04.5-LTS:12.04.201507301
|
460
|
-
data: Canonical UbuntuServer 12.04.5-LTS 12.04.201507311 westeurope Canonical:UbuntuServer:12.04.5-LTS:12.04.201507311
|
461
|
-
data: Canonical UbuntuServer 12.04.5-LTS 12.04.201508190 westeurope Canonical:UbuntuServer:12.04.5-LTS:12.04.201508190
|
462
|
-
data: Canonical UbuntuServer 12.04.5-LTS 12.04.201509060 westeurope Canonical:UbuntuServer:12.04.5-LTS:12.04.201509060
|
463
|
-
data: Canonical UbuntuServer 12.04.5-LTS 12.04.201509090 westeurope Canonical:UbuntuServer:12.04.5-LTS:12.04.201509090
|
464
|
-
data: Canonical UbuntuServer 12.10 12.10.201212180 westeurope Canonical:UbuntuServer:12.10:12.10.201212180
|
465
|
-
data: Canonical UbuntuServer 14.04.3-DAILY-LTS 14.04.201509110 westeurope Canonical:UbuntuServer:14.04.3-DAILY-LTS:14.04.201509110
|
466
|
-
data: Canonical UbuntuServer 14.04.3-DAILY-LTS 14.04.201509160 westeurope Canonical:UbuntuServer:14.04.3-DAILY-LTS:14.04.201509160
|
467
|
-
data: Canonical UbuntuServer 14.04.3-DAILY-LTS 14.04.201509220 westeurope Canonical:UbuntuServer:14.04.3-DAILY-LTS:14.04.201509220
|
468
|
-
data: Canonical UbuntuServer 14.04.3-LTS 14.04.201508050 westeurope Canonical:UbuntuServer:14.04.3-LTS:14.04.201508050
|
469
|
-
data: Canonical UbuntuServer 14.04.3-LTS 14.04.201509080 westeurope Canonical:UbuntuServer:14.04.3-LTS:14.04.201509080
|
470
|
-
data: Canonical UbuntuServer 15.04 15.04.201506161 westeurope Canonical:UbuntuServer:15.04:15.04.201506161
|
471
|
-
data: Canonical UbuntuServer 15.04 15.04.201507070 westeurope Canonical:UbuntuServer:15.04:15.04.201507070
|
472
|
-
data: Canonical UbuntuServer 15.04 15.04.201507220 westeurope Canonical:UbuntuServer:15.04:15.04.201507220
|
473
|
-
data: Canonical UbuntuServer 15.04 15.04.201507280 westeurope Canonical:UbuntuServer:15.04:15.04.201507280
|
474
|
-
data: Canonical UbuntuServer 15.10-DAILY 15.10.201509170 westeurope Canonical:UbuntuServer:15.10-DAILY:15.10.201509170
|
475
|
-
data: Canonical UbuntuServer 15.10-DAILY 15.10.201509180 westeurope Canonical:UbuntuServer:15.10-DAILY:15.10.201509180
|
476
|
-
data: Canonical UbuntuServer 15.10-DAILY 15.10.201509190 westeurope Canonical:UbuntuServer:15.10-DAILY:15.10.201509190
|
477
|
-
data: Canonical UbuntuServer 15.10-DAILY 15.10.201509210 westeurope Canonical:UbuntuServer:15.10-DAILY:15.10.201509210
|
478
|
-
data: Canonical UbuntuServer 15.10-DAILY 15.10.201509220 westeurope Canonical:UbuntuServer:15.10-DAILY:15.10.201509220
|
479
|
-
info: vm image list command OK
|
480
|
-
```
|
481
|
-
|
482
|
-
### Additional parameters:
|
483
|
-
- Note that the ```driver_config``` section also takes a ```username``` and ```password``` parameter, the defaults if these are not specified are "azure" and "P2ssw0rd" respectively.
|
484
|
-
- The ```storage_account_type``` parameter defaults to 'Standard_LRS' and allows you to switch to premium storage (e.g. 'Premium_LRS')
|
485
|
-
- The ```enable_boot_diagnostics``` parameter defaults to 'true' and allows you to switch off boot diagnostics in case you are using premium storage.
|
486
|
-
- The optional ```vm_tags``` parameter allows you to define key:value pairs to tag VMs with on creation.
|
487
|
-
- Managed disks are now enabled by default, to use the Storage account set ```use_managed_disks``` (default: true).
|
488
|
-
- 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)
|
489
|
-
- The ```image_id``` (managed disks only) parameter can be used to specify an image by id (managed disk). This works only with managed disks.
|
490
|
-
- The ```existing_storage_account_blob_url``` can be specified to specify an url to an existing storage account (needed for ```image_url```)
|
491
|
-
- 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.
|
492
|
-
- The ```os_disk_size_gb``` parameter can be used to specify a custom os disk size.
|
493
|
-
- The ```azure_resource_group_prefix``` and ```azure_resource_group_suffix``` can be used to further disambiguate Azure resource group names created by the driver.
|
494
|
-
- The ```explicit_resource_group_name``` parameters can be used in scenarios where you are provided a pre-created Resource Group. Example usage: ```explicit_resource_group_name: kitchen-<%= ENV["USERNAME"] %>```
|
495
|
-
|
496
|
-
## Contributing
|
497
|
-
|
498
|
-
Contributions to the project are welcome via submitting Pull Requests.
|
499
|
-
|
500
|
-
1. Fork it ( https://github.com/test-kitchen/kitchen-azurerm/fork )
|
501
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
502
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
503
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
504
|
-
5. Create a new Pull Request
|
1
|
+
# kitchen-azurerm
|
2
|
+
|
3
|
+
**kitchen-azurerm** is a driver for the popular test harness [Test Kitchen](http://kitchen.ci) that allows Microsoft Azure resources to be provisioned prior to 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).
|
4
|
+
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/kitchen-azurerm.svg)](http://badge.fury.io/rb/kitchen-azurerm) [![Build Status](https://travis-ci.org/test-kitchen/kitchen-azurerm.svg)](https://travis-ci.org/test-kitchen/kitchen-azurerm)
|
6
|
+
|
7
|
+
This version has been tested on Windows, OS/X and Ubuntu. If you encounter a problem on your platform, please raise an issue.
|
8
|
+
|
9
|
+
## Quick-start
|
10
|
+
|
11
|
+
### Installation
|
12
|
+
|
13
|
+
This plugin is distributed as a [Ruby Gem](https://rubygems.org/gems/kitchen-azurerm). To install it, run:
|
14
|
+
|
15
|
+
```$ gem install kitchen-azurerm```
|
16
|
+
|
17
|
+
Note if you are running the ChefDK you may need to prefix the command with chef, i.e. ```$ chef gem install kitchen-azurerm```
|
18
|
+
|
19
|
+
### Configuration
|
20
|
+
|
21
|
+
For the driver to interact with the Microsoft Azure Resource management REST API, a Service Principal needs to be configured with Contributor rights against the specific subscription being targeted. Using an Organizational (AAD) account and related password is no longer supported. To create a Service Principal and apply the correct permissions, you will need to [create and authenticate a service principal](https://azure.microsoft.com/en-us/documentation/articles/resource-group-authenticate-service-principal/#authenticate-service-principal-with-password---azure-cli) using the [Azure CLI](https://azure.microsoft.com/en-us/documentation/articles/xplat-cli-install/). Make sure you stay within the section titled 'Authenticate service principal with password - Azure CLI'.
|
22
|
+
|
23
|
+
You will also need to ensure you have an active Azure subscription (you can get started [for free](https://azure.microsoft.com/en-us/free/) or use your [MSDN Subscription](https://azure.microsoft.com/en-us/pricing/member-offers/msdn-benefits/)).
|
24
|
+
|
25
|
+
You are now ready to configure kitchen-azurerm to use the credentials from the service principal you created above. You will use four elements from the steps in that article:
|
26
|
+
|
27
|
+
1. **Subscription ID**: available from the Azure portal
|
28
|
+
2. **Client ID**: this will be the Application Id from the application in step 2.
|
29
|
+
3. **Client Secret/Password**: this will be the password you supplied in the command in step 2.
|
30
|
+
4. **Tenant ID**: use the command detailed in "Manually provide credentials through Azure CLI" step 1 to get the TenantId.
|
31
|
+
|
32
|
+
Using a text editor, open or create the file ```~/.azure/credentials``` and add the following section, noting there is one section per Subscription ID. **Make sure you save the file with UTF-8 encoding**
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
[abcd1234-YOUR-SUBSCRIPTION-ID-HERE-abcdef123456]
|
36
|
+
client_id = "48b9bba3-YOUR-GUID-HERE-90f0b68ce8ba"
|
37
|
+
client_secret = "your-client-secret-here"
|
38
|
+
tenant_id = "9c117323-YOUR-GUID-HERE-9ee430723ba3"
|
39
|
+
```
|
40
|
+
|
41
|
+
If preferred, you may also set the following environment variables, however this would be incompatible with supporting multiple Azure subscriptions.
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
AZURE_CLIENT_ID="48b9bba3-YOUR-GUID-HERE-90f0b68ce8ba"
|
45
|
+
AZURE_CLIENT_SECRET="your-client-secret-here"
|
46
|
+
AZURE_TENANT_ID="9c117323-YOUR-GUID-HERE-9ee430723ba3"
|
47
|
+
```
|
48
|
+
|
49
|
+
Note that the environment variables, if set, take preference over the values in a configuration file.
|
50
|
+
|
51
|
+
### .kitchen.yml example 1 - Linux/Ubuntu
|
52
|
+
|
53
|
+
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.
|
54
|
+
|
55
|
+
```yaml
|
56
|
+
---
|
57
|
+
driver:
|
58
|
+
name: azurerm
|
59
|
+
|
60
|
+
driver_config:
|
61
|
+
subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
|
62
|
+
location: 'West Europe'
|
63
|
+
machine_size: 'Standard_D1'
|
64
|
+
|
65
|
+
transport:
|
66
|
+
ssh_key: ~/.ssh/id_kitchen-azurerm
|
67
|
+
|
68
|
+
provisioner:
|
69
|
+
name: chef_zero
|
70
|
+
|
71
|
+
platforms:
|
72
|
+
- name: ubuntu-14.04
|
73
|
+
driver_config:
|
74
|
+
image_urn: Canonical:UbuntuServer:14.04.4-LTS:latest
|
75
|
+
vm_name: trusty-vm
|
76
|
+
vm_tags:
|
77
|
+
ostype: linux
|
78
|
+
distro: ubuntu
|
79
|
+
|
80
|
+
suites:
|
81
|
+
- name: default
|
82
|
+
run_list:
|
83
|
+
- recipe[kitchentesting::default]
|
84
|
+
attributes:
|
85
|
+
```
|
86
|
+
|
87
|
+
### Concurrent execution
|
88
|
+
Concurrent execution of create/converge/destroy is supported via the --concurrency parameter. Each machine is created in it's own Azure Resource Group so has no shared lifecycle with the other machines in the test run. To take advantage of parallel execution use the following command:
|
89
|
+
|
90
|
+
```kitchen test --concurrency <n>```
|
91
|
+
|
92
|
+
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.
|
93
|
+
|
94
|
+
### .kitchen.yml example 2 - Windows
|
95
|
+
|
96
|
+
Here's a further example ```.kitchen.yml``` file that will provision a Windows Server 2012 R2 instance, using WinRM as the transport. The resource created in Azure will enable itself for remote access at deployment time (it does this by customizing the machine at provisioning time):
|
97
|
+
|
98
|
+
```yaml
|
99
|
+
---
|
100
|
+
driver:
|
101
|
+
name: azurerm
|
102
|
+
|
103
|
+
driver_config:
|
104
|
+
subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
|
105
|
+
location: 'West Europe'
|
106
|
+
machine_size: 'Standard_D1'
|
107
|
+
|
108
|
+
provisioner:
|
109
|
+
name: chef_zero
|
110
|
+
|
111
|
+
platforms:
|
112
|
+
- name: windows2012-r2
|
113
|
+
driver_config:
|
114
|
+
image_urn: MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:latest
|
115
|
+
transport:
|
116
|
+
name: winrm
|
117
|
+
suites:
|
118
|
+
- name: default
|
119
|
+
run_list:
|
120
|
+
- recipe[kitchentesting::default]
|
121
|
+
attributes:
|
122
|
+
```
|
123
|
+
|
124
|
+
### .kitchen.yml example 3 - "pre-deployment" ARM template
|
125
|
+
|
126
|
+
The following example introduces the ```pre_deployment_template``` and ```pre_deployment_parameters``` properties in the configuration file.
|
127
|
+
You can use this capability to execute an ARM template containing Azure resources to provision before the system under test is created.
|
128
|
+
|
129
|
+
In the example the ARM template in the file ```predeploy.json``` would be executed with the parameters that are specified under ```pre_deployment_parameters```.
|
130
|
+
These resources will be created in the same Azure Resource Group as the VM under test, and therefore will be destroyed when you type ```kitchen destroy```.
|
131
|
+
|
132
|
+
```yaml
|
133
|
+
---
|
134
|
+
driver:
|
135
|
+
name: azurerm
|
136
|
+
|
137
|
+
driver_config:
|
138
|
+
subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
|
139
|
+
location: 'West Europe'
|
140
|
+
machine_size: 'Standard_D1'
|
141
|
+
pre_deployment_template: predeploy.json
|
142
|
+
pre_deployment_parameters:
|
143
|
+
test_parameter: 'This is a test.'
|
144
|
+
|
145
|
+
transport:
|
146
|
+
ssh_key: ~/.ssh/id_kitchen-azurerm
|
147
|
+
|
148
|
+
provisioner:
|
149
|
+
name: chef_zero
|
150
|
+
|
151
|
+
platforms:
|
152
|
+
- name: ubuntu-1404
|
153
|
+
driver_config:
|
154
|
+
image_urn: Canonical:UbuntuServer:14.04.4-LTS:latest
|
155
|
+
|
156
|
+
suites:
|
157
|
+
- name: default
|
158
|
+
run_list:
|
159
|
+
- recipe[kitchen-azurerm-demo::default]
|
160
|
+
attributes:
|
161
|
+
```
|
162
|
+
|
163
|
+
Example predeploy.json:
|
164
|
+
|
165
|
+
```json
|
166
|
+
{
|
167
|
+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
168
|
+
"contentVersion": "1.0.0.0",
|
169
|
+
"parameters": {
|
170
|
+
"test_parameter": {
|
171
|
+
"type": "string",
|
172
|
+
"defaultValue": ""
|
173
|
+
}
|
174
|
+
},
|
175
|
+
"variables": {
|
176
|
+
|
177
|
+
},
|
178
|
+
"resources": [
|
179
|
+
{
|
180
|
+
"name": "uniqueinstancenamehere01",
|
181
|
+
"type": "Microsoft.Sql/servers",
|
182
|
+
"location": "[resourceGroup().location]",
|
183
|
+
"apiVersion": "2014-04-01-preview",
|
184
|
+
"properties": {
|
185
|
+
"version": "12.0",
|
186
|
+
"administratorLogin": "azure",
|
187
|
+
"administratorLoginPassword": "P2ssw0rd"
|
188
|
+
}
|
189
|
+
}
|
190
|
+
],
|
191
|
+
"outputs": {
|
192
|
+
"parameter testing": {
|
193
|
+
"type": "string",
|
194
|
+
"value": "[parameters('test_parameter')]"
|
195
|
+
}
|
196
|
+
}
|
197
|
+
}
|
198
|
+
```
|
199
|
+
|
200
|
+
### .kitchen.yml example 4 - deploy VM to existing virtual network/subnet (use for ExpressRoute/VPN scenarios)
|
201
|
+
|
202
|
+
The following example introduces the ```vnet_id``` and ```subnet_id``` properties under driver_config in the configuration file. This can be applied at the top level, or per platform.
|
203
|
+
You can use this capability to create the VM on an existing virtual network and subnet created in a different resource group.
|
204
|
+
|
205
|
+
In this case, the public IP address is not used unless ```public_ip``` is set to ```true```
|
206
|
+
|
207
|
+
|
208
|
+
```yaml
|
209
|
+
---
|
210
|
+
driver:
|
211
|
+
name: azurerm
|
212
|
+
|
213
|
+
driver_config:
|
214
|
+
subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
|
215
|
+
location: 'West Europe'
|
216
|
+
machine_size: 'Standard_D1'
|
217
|
+
|
218
|
+
transport:
|
219
|
+
ssh_key: ~/.ssh/id_kitchen-azurerm
|
220
|
+
|
221
|
+
provisioner:
|
222
|
+
name: chef_zero
|
223
|
+
|
224
|
+
platforms:
|
225
|
+
- name: ubuntu-1404
|
226
|
+
driver_config:
|
227
|
+
image_urn: Canonical:UbuntuServer:14.04.4-LTS:latest
|
228
|
+
vnet_id: /subscriptions/b6e7eee9-YOUR-GUID-HERE-03ab624df016/resourceGroups/pendrica-infrastructure/providers/Microsoft.Network/virtualNetworks/pendrica-arm-vnet
|
229
|
+
subnet_id: subnet-10.1.0
|
230
|
+
|
231
|
+
suites:
|
232
|
+
- name: default
|
233
|
+
run_list:
|
234
|
+
- recipe[kitchen-azurerm-demo::default]
|
235
|
+
attributes:
|
236
|
+
```
|
237
|
+
|
238
|
+
### .kitchen.yml example 5 - deploy VM to existing virtual network/subnet (use for ExpressRoute/VPN scenarios) with Private Managed Image
|
239
|
+
|
240
|
+
This example is the same as above, but uses a private managed image to provision the vm.
|
241
|
+
|
242
|
+
Note: The image must be available first. On deletion the disk and everything is removed.
|
243
|
+
|
244
|
+
```yaml
|
245
|
+
---
|
246
|
+
driver:
|
247
|
+
name: azurerm
|
248
|
+
|
249
|
+
driver_config:
|
250
|
+
subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
|
251
|
+
location: 'West Europe'
|
252
|
+
machine_size: 'Standard_D1'
|
253
|
+
|
254
|
+
transport:
|
255
|
+
ssh_key: ~/.ssh/id_kitchen-azurerm
|
256
|
+
|
257
|
+
provisioner:
|
258
|
+
name: chef_zero
|
259
|
+
|
260
|
+
platforms:
|
261
|
+
- name: ubuntu-1404
|
262
|
+
driver_config:
|
263
|
+
image_id: /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/RESGROUP/providers/Microsoft.Compute/images/IMAGENAME
|
264
|
+
vnet_id: /subscriptions/b6e7eee9-YOUR-GUID-HERE-03ab624df016/resourceGroups/pendrica-infrastructure/providers/Microsoft.Network/virtualNetworks/pendrica-arm-vnet
|
265
|
+
subnet_id: subnet-10.1.0
|
266
|
+
use_managed_disk: true
|
267
|
+
|
268
|
+
|
269
|
+
suites:
|
270
|
+
- name: default
|
271
|
+
run_list:
|
272
|
+
- recipe[kitchen-azurerm-demo::default]
|
273
|
+
attributes:
|
274
|
+
```
|
275
|
+
|
276
|
+
### .kitchen.yml example 6 - deploy VM to existing virtual network/subnet (use for ExpressRoute/VPN scenarios) with Private Classic OS Image
|
277
|
+
|
278
|
+
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.
|
279
|
+
|
280
|
+
Note: When the resource group ís deleted, the os disk is left in the extsing storage account blob. You must cleanup manually.
|
281
|
+
|
282
|
+
This example will:
|
283
|
+
|
284
|
+
* use the customized image https://yourstorageaccount.blob.core.windows.net/system/Microsoft.Compute/Images/images/Cent7_P4-osDisk.170dd1b7-7dc3-4496-b248-f47c49f63965.vhd (can be built with packer)
|
285
|
+
* set the disk url of the vm to https://yourstorageaccount.blob.core.windows.net/vhds/osdisk-kitchen-XXXXX.vhd
|
286
|
+
* set the os type to linux
|
287
|
+
|
288
|
+
|
289
|
+
```yaml
|
290
|
+
---
|
291
|
+
driver:
|
292
|
+
name: azurerm
|
293
|
+
|
294
|
+
driver_config:
|
295
|
+
subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
|
296
|
+
location: 'West Europe'
|
297
|
+
machine_size: 'Standard_D1'
|
298
|
+
|
299
|
+
transport:
|
300
|
+
ssh_key: ~/.ssh/id_kitchen-azurerm
|
301
|
+
|
302
|
+
provisioner:
|
303
|
+
name: chef_zero
|
304
|
+
|
305
|
+
platforms:
|
306
|
+
- name: ubuntu-1404
|
307
|
+
driver_config:
|
308
|
+
image_url: https://yourstorageaccount.blob.core.windows.net/system/Microsoft.Compute/Images/images/Cent7_P4-osDisk.170dd1b7-7dc3-4496-b248-f47c49f63965.vhd
|
309
|
+
existing_storage_account_blob_url: https://yourstorageaccount.blob.core.windows.net
|
310
|
+
os_type: linux
|
311
|
+
use_managed_disk: false
|
312
|
+
vnet_id: /subscriptions/b6e7eee9-YOUR-GUID-HERE-03ab624df016/resourceGroups/pendrica-infrastructure/providers/Microsoft.Network/virtualNetworks/pendrica-arm-vnet
|
313
|
+
subnet_id: subnet-10.1.0
|
314
|
+
|
315
|
+
suites:
|
316
|
+
- name: default
|
317
|
+
run_list:
|
318
|
+
- recipe[kitchen-azurerm-demo::default]
|
319
|
+
attributes:
|
320
|
+
```
|
321
|
+
|
322
|
+
### .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
|
323
|
+
|
324
|
+
This is the same as above, but uses custom data to customize the instance.
|
325
|
+
|
326
|
+
Note: Custom data can be custom data or a file to custom data. Please also note that if you use winrm communication to non-nano windows servers custom data is not supported, as winrm is enabled via custom data.
|
327
|
+
|
328
|
+
|
329
|
+
```yaml
|
330
|
+
---
|
331
|
+
driver:
|
332
|
+
name: azurerm
|
333
|
+
|
334
|
+
driver_config:
|
335
|
+
subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
|
336
|
+
location: 'West Europe'
|
337
|
+
machine_size: 'Standard_D1'
|
338
|
+
|
339
|
+
transport:
|
340
|
+
ssh_key: ~/.ssh/id_kitchen-azurerm
|
341
|
+
|
342
|
+
provisioner:
|
343
|
+
name: chef_zero
|
344
|
+
|
345
|
+
platforms:
|
346
|
+
- name: ubuntu-1404
|
347
|
+
driver_config:
|
348
|
+
image_url: https://yourstorageaccount.blob.core.windows.net/system/Microsoft.Compute/Images/images/Cent7_P4-osDisk.170dd1b7-7dc3-4496-b248-f47c49f63965.vhd
|
349
|
+
existing_storage_account_blob_url: https://yourstorageaccount.blob.core.windows.net
|
350
|
+
os_type: linux
|
351
|
+
use_managed_disk: false
|
352
|
+
vnet_id: /subscriptions/b6e7eee9-YOUR-GUID-HERE-03ab624df016/resourceGroups/pendrica-infrastructure/providers/Microsoft.Network/virtualNetworks/pendrica-arm-vnet
|
353
|
+
subnet_id: subnet-10.1.0
|
354
|
+
os_disk_size_gb: 100
|
355
|
+
#custom_data: /tmp/customdata.txt
|
356
|
+
custom_data: |
|
357
|
+
#cloud-config
|
358
|
+
fqdn: myhostname
|
359
|
+
preserve_hostname: false
|
360
|
+
runcmd:
|
361
|
+
- yum install -y telnet
|
362
|
+
|
363
|
+
suites:
|
364
|
+
- name: default
|
365
|
+
run_list:
|
366
|
+
- recipe[kitchen-azurerm-demo::default]
|
367
|
+
attributes:
|
368
|
+
```
|
369
|
+
|
370
|
+
### .kitchen.yml example 8 - Windows 2016 VM with additional data disks:
|
371
|
+
|
372
|
+
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.
|
373
|
+
|
374
|
+
Note the availability of a `format_data_disks` option (default: `false`). When set to true, a PowerShell script will execute at first boot to initialize and format the disks with an NTFS filesystem. This option has no effect on Linux machines.
|
375
|
+
|
376
|
+
```yaml
|
377
|
+
---
|
378
|
+
driver:
|
379
|
+
name: azurerm
|
380
|
+
|
381
|
+
driver_config:
|
382
|
+
subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
|
383
|
+
location: 'West Europe'
|
384
|
+
machine_size: 'Standard_F2s'
|
385
|
+
|
386
|
+
provisioner:
|
387
|
+
name: chef_zero
|
388
|
+
|
389
|
+
platforms:
|
390
|
+
- name: windows2016-noformat
|
391
|
+
driver_config:
|
392
|
+
image_urn: MicrosoftWindowsServer:WindowsServer:2016-Datacenter:latest
|
393
|
+
data_disks:
|
394
|
+
- lun: 0
|
395
|
+
disk_size_gb: 128
|
396
|
+
- lun: 1
|
397
|
+
disk_size_gb: 128
|
398
|
+
- lun: 2
|
399
|
+
disk_size_gb: 128
|
400
|
+
# format_data_disks: false
|
401
|
+
|
402
|
+
suites:
|
403
|
+
- name: default
|
404
|
+
run_list:
|
405
|
+
- recipe[kitchentesting::default]
|
406
|
+
attributes:
|
407
|
+
```
|
408
|
+
|
409
|
+
## Support for Government and Sovereign Clouds (China and Germany)
|
410
|
+
|
411
|
+
Starting with v0.9.0 this driver has support for Azure Government and Sovereign Clouds via the use of the ```azure_environment``` setting. Valid Azure environments are ```Azure```, ```AzureUSGovernment```, ```AzureChina``` and ```AzureGermanCloud```
|
412
|
+
|
413
|
+
Note that the ```use_managed_disks``` option should be set to false until supported by AzureUSGovernment.
|
414
|
+
|
415
|
+
### Example .kitchen.yml for Azure US Government cloud
|
416
|
+
|
417
|
+
```yaml
|
418
|
+
---
|
419
|
+
driver:
|
420
|
+
name: azurerm
|
421
|
+
|
422
|
+
driver_config:
|
423
|
+
subscription_id: 'abcdabcd-YOUR-GUID-HERE-abcdabcdabcd'
|
424
|
+
azure_environment: 'AzureUSGovernment'
|
425
|
+
location: 'US Gov Iowa'
|
426
|
+
machine_size: 'Standard_D2_v2_Promo'
|
427
|
+
use_managed_disks: false
|
428
|
+
|
429
|
+
provisioner:
|
430
|
+
name: chef_zero
|
431
|
+
|
432
|
+
verifier:
|
433
|
+
name: inspec
|
434
|
+
|
435
|
+
platforms:
|
436
|
+
- name: ubuntu1604
|
437
|
+
driver_config:
|
438
|
+
image_urn: Canonical:UbuntuServer:16.04-LTS:latest
|
439
|
+
transport:
|
440
|
+
ssh_key: ~/.ssh/id_kitchen-azurerm
|
441
|
+
|
442
|
+
suites:
|
443
|
+
- name: default
|
444
|
+
run_list:
|
445
|
+
- recipe[vmtesting::default]
|
446
|
+
```
|
447
|
+
|
448
|
+
### How to retrieve the image_urn
|
449
|
+
You can use the azure (azure-cli) command line tools to interrogate for the Urn. All 4 parts of the Urn must be specified, though the last part can be changed to "latest" to indicate you always wish to provision the latest operating system and patches.
|
450
|
+
|
451
|
+
```$ azure vm image list "West Europe" Canonical UbuntuServer```
|
452
|
+
|
453
|
+
This will return a list like the following, from which you can derive the Urn.
|
454
|
+
*this list has been shortened for readability*
|
455
|
+
|
456
|
+
```
|
457
|
+
data: Publisher Offer Sku Version Location Urn
|
458
|
+
data: --------- ------------ ----------------- --------------- ---------- --------------------------------------------------------
|
459
|
+
data: Canonical UbuntuServer 12.04.5-LTS 12.04.201507301 westeurope Canonical:UbuntuServer:12.04.5-LTS:12.04.201507301
|
460
|
+
data: Canonical UbuntuServer 12.04.5-LTS 12.04.201507311 westeurope Canonical:UbuntuServer:12.04.5-LTS:12.04.201507311
|
461
|
+
data: Canonical UbuntuServer 12.04.5-LTS 12.04.201508190 westeurope Canonical:UbuntuServer:12.04.5-LTS:12.04.201508190
|
462
|
+
data: Canonical UbuntuServer 12.04.5-LTS 12.04.201509060 westeurope Canonical:UbuntuServer:12.04.5-LTS:12.04.201509060
|
463
|
+
data: Canonical UbuntuServer 12.04.5-LTS 12.04.201509090 westeurope Canonical:UbuntuServer:12.04.5-LTS:12.04.201509090
|
464
|
+
data: Canonical UbuntuServer 12.10 12.10.201212180 westeurope Canonical:UbuntuServer:12.10:12.10.201212180
|
465
|
+
data: Canonical UbuntuServer 14.04.3-DAILY-LTS 14.04.201509110 westeurope Canonical:UbuntuServer:14.04.3-DAILY-LTS:14.04.201509110
|
466
|
+
data: Canonical UbuntuServer 14.04.3-DAILY-LTS 14.04.201509160 westeurope Canonical:UbuntuServer:14.04.3-DAILY-LTS:14.04.201509160
|
467
|
+
data: Canonical UbuntuServer 14.04.3-DAILY-LTS 14.04.201509220 westeurope Canonical:UbuntuServer:14.04.3-DAILY-LTS:14.04.201509220
|
468
|
+
data: Canonical UbuntuServer 14.04.3-LTS 14.04.201508050 westeurope Canonical:UbuntuServer:14.04.3-LTS:14.04.201508050
|
469
|
+
data: Canonical UbuntuServer 14.04.3-LTS 14.04.201509080 westeurope Canonical:UbuntuServer:14.04.3-LTS:14.04.201509080
|
470
|
+
data: Canonical UbuntuServer 15.04 15.04.201506161 westeurope Canonical:UbuntuServer:15.04:15.04.201506161
|
471
|
+
data: Canonical UbuntuServer 15.04 15.04.201507070 westeurope Canonical:UbuntuServer:15.04:15.04.201507070
|
472
|
+
data: Canonical UbuntuServer 15.04 15.04.201507220 westeurope Canonical:UbuntuServer:15.04:15.04.201507220
|
473
|
+
data: Canonical UbuntuServer 15.04 15.04.201507280 westeurope Canonical:UbuntuServer:15.04:15.04.201507280
|
474
|
+
data: Canonical UbuntuServer 15.10-DAILY 15.10.201509170 westeurope Canonical:UbuntuServer:15.10-DAILY:15.10.201509170
|
475
|
+
data: Canonical UbuntuServer 15.10-DAILY 15.10.201509180 westeurope Canonical:UbuntuServer:15.10-DAILY:15.10.201509180
|
476
|
+
data: Canonical UbuntuServer 15.10-DAILY 15.10.201509190 westeurope Canonical:UbuntuServer:15.10-DAILY:15.10.201509190
|
477
|
+
data: Canonical UbuntuServer 15.10-DAILY 15.10.201509210 westeurope Canonical:UbuntuServer:15.10-DAILY:15.10.201509210
|
478
|
+
data: Canonical UbuntuServer 15.10-DAILY 15.10.201509220 westeurope Canonical:UbuntuServer:15.10-DAILY:15.10.201509220
|
479
|
+
info: vm image list command OK
|
480
|
+
```
|
481
|
+
|
482
|
+
### Additional parameters:
|
483
|
+
- Note that the ```driver_config``` section also takes a ```username``` and ```password``` parameter, the defaults if these are not specified are "azure" and "P2ssw0rd" respectively.
|
484
|
+
- The ```storage_account_type``` parameter defaults to 'Standard_LRS' and allows you to switch to premium storage (e.g. 'Premium_LRS')
|
485
|
+
- The ```enable_boot_diagnostics``` parameter defaults to 'true' and allows you to switch off boot diagnostics in case you are using premium storage.
|
486
|
+
- The optional ```vm_tags``` parameter allows you to define key:value pairs to tag VMs with on creation.
|
487
|
+
- Managed disks are now enabled by default, to use the Storage account set ```use_managed_disks``` (default: true).
|
488
|
+
- 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)
|
489
|
+
- The ```image_id``` (managed disks only) parameter can be used to specify an image by id (managed disk). This works only with managed disks.
|
490
|
+
- The ```existing_storage_account_blob_url``` can be specified to specify an url to an existing storage account (needed for ```image_url```)
|
491
|
+
- 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.
|
492
|
+
- The ```os_disk_size_gb``` parameter can be used to specify a custom os disk size.
|
493
|
+
- The ```azure_resource_group_prefix``` and ```azure_resource_group_suffix``` can be used to further disambiguate Azure resource group names created by the driver.
|
494
|
+
- The ```explicit_resource_group_name``` parameters can be used in scenarios where you are provided a pre-created Resource Group. Example usage: ```explicit_resource_group_name: kitchen-<%= ENV["USERNAME"] %>```
|
495
|
+
|
496
|
+
## Contributing
|
497
|
+
|
498
|
+
Contributions to the project are welcome via submitting Pull Requests.
|
499
|
+
|
500
|
+
1. Fork it ( https://github.com/test-kitchen/kitchen-azurerm/fork )
|
501
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
502
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
503
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
504
|
+
5. Create a new Pull Request
|