kitchen-azurerm 0.4.1 → 0.5.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 +6 -0
- data/README.md +38 -0
- data/lib/kitchen/driver/azurerm.rb +225 -6
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d41d3dc84115d01efb811a9b47efadad76b3dbf
|
4
|
+
data.tar.gz: 0caf860272a7d70f7356889b2b1b013123541a53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48b2098a84cf1a4c68e6289578cfa94c2d9e7fc769ce7ff77691d0df6f86a4f642594497be6569a120afa3107ad747cef38a4ad8b808c9ddc70ad63065e485e1
|
7
|
+
data.tar.gz: 536e2e842cee0d13ec3b06819256608bb0f0c879e9417ce0ca66a6ed66b771061dcc8ad808facd85fc20210288eb6da866ba7ed1f0c6fe04a89c1b8866404870
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# kitchen-azurerm Changelog
|
2
2
|
|
3
|
+
## [0.5.0] - 2016-08-07
|
4
|
+
- Adding support for internal (e.g. ExpressRoute/VPN) access to created VM (@stuartpreston)
|
5
|
+
|
6
|
+
## [0.4.1] - 2016-07-01
|
7
|
+
- Adding explicit depdendency on concurrent-ruby gem (@stuartpreston)
|
8
|
+
|
3
9
|
## [0.4.0] - 2016-06-26
|
4
10
|
- Adding capability to execute ARM template prior to VM deployment, ```pre_deployment_template``` and ```pre_deployment_parameters``` added (@stuartpreston)
|
5
11
|
|
data/README.md
CHANGED
@@ -205,6 +205,44 @@ Example predeploy.json:
|
|
205
205
|
}
|
206
206
|
```
|
207
207
|
|
208
|
+
### .kitchen.yml example 4 - deploy VM to existing virtual network/subnet (use for ExpressRoute/VPN scenarios)
|
209
|
+
|
210
|
+
The following example introduces the ```vnet_id``` and ```subnet_id``` properties under driver_config in the configuration file. This can be applied at the top level, or per platform.
|
211
|
+
You can use this capability to create the VM on an existing virtual network and subnet created in a different resource group.
|
212
|
+
|
213
|
+
In this case, the public IP address is not used.
|
214
|
+
|
215
|
+
|
216
|
+
```yaml
|
217
|
+
---
|
218
|
+
driver:
|
219
|
+
name: azurerm
|
220
|
+
|
221
|
+
driver_config:
|
222
|
+
subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
|
223
|
+
location: 'West Europe'
|
224
|
+
machine_size: 'Standard_D1'
|
225
|
+
|
226
|
+
transport:
|
227
|
+
ssh_key: ~/.ssh/id_kitchen-azurerm
|
228
|
+
|
229
|
+
provisioner:
|
230
|
+
name: chef_zero
|
231
|
+
|
232
|
+
platforms:
|
233
|
+
- name: ubuntu-1404
|
234
|
+
driver_config:
|
235
|
+
image_urn: Canonical:UbuntuServer:14.04.4-LTS:latest
|
236
|
+
vnet_id: /subscriptions/b6e7eee9-YOUR-GUID-HERE-03ab624df016/resourceGroups/pendrica-infrastructure/providers/Microsoft.Network/virtualNetworks/pendrica-arm-vnet
|
237
|
+
subnet_id: subnet-10.1.0
|
238
|
+
|
239
|
+
suites:
|
240
|
+
- name: default
|
241
|
+
run_list:
|
242
|
+
- recipe[kitchen-azurerm-demo::default]
|
243
|
+
attributes:
|
244
|
+
```
|
245
|
+
|
208
246
|
### How to retrieve the image_urn
|
209
247
|
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.
|
210
248
|
|
@@ -35,6 +35,14 @@ module Kitchen
|
|
35
35
|
'vm'
|
36
36
|
end
|
37
37
|
|
38
|
+
default_config(:vnet_id) do |_config|
|
39
|
+
''
|
40
|
+
end
|
41
|
+
|
42
|
+
default_config(:subnet_id) do |_config|
|
43
|
+
''
|
44
|
+
end
|
45
|
+
|
38
46
|
default_config(:storage_account_type) do |_config|
|
39
47
|
'Standard_LRS'
|
40
48
|
end
|
@@ -124,12 +132,22 @@ module Kitchen
|
|
124
132
|
# Monitor all operations until completion
|
125
133
|
follow_deployment_until_end_state(state[:azure_resource_group_name], deployment_name)
|
126
134
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
135
|
+
if config[:vnet_id] == ''
|
136
|
+
# Retrieve the public IP from the resource group:
|
137
|
+
network_management_client = ::Azure::ARM::Network::NetworkResourceProviderClient.new(credentials)
|
138
|
+
network_management_client.subscription_id = config[:subscription_id]
|
139
|
+
result = network_management_client.public_ip_addresses.get(state[:azure_resource_group_name], 'publicip').value!
|
140
|
+
info "IP Address is: #{result.body.properties.ip_address} [#{result.body.properties.dns_settings.fqdn}]"
|
141
|
+
state[:hostname] = result.body.properties.ip_address
|
142
|
+
else
|
143
|
+
# Retrieve the internal IP from the resource group:
|
144
|
+
network_management_client = ::Azure::ARM::Network::NetworkResourceProviderClient.new(credentials)
|
145
|
+
network_management_client.subscription_id = config[:subscription_id]
|
146
|
+
network_interfaces = ::Azure::ARM::Network::NetworkInterfaces.new(network_management_client)
|
147
|
+
result = network_interfaces.get(state[:azure_resource_group_name], 'nic').value!
|
148
|
+
info "IP Address is: #{result.body.properties.ip_configurations[0].properties.private_ipaddress}"
|
149
|
+
state[:hostname] = result.body.properties.ip_configurations[0].properties.private_ipaddress
|
150
|
+
end
|
133
151
|
end
|
134
152
|
|
135
153
|
def existing_state_value?(state, property)
|
@@ -339,6 +357,207 @@ New-NetFirewallRule -DisplayName "Windows Remote Management (HTTP-In)" -Name "Wi
|
|
339
357
|
end
|
340
358
|
|
341
359
|
def virtual_machine_deployment_template
|
360
|
+
if config[:vnet_id] == ''
|
361
|
+
return virtual_machine_deployment_template_public
|
362
|
+
else
|
363
|
+
info "Using custom vnet: #{config[:vnet_id]}"
|
364
|
+
return virtual_machine_deployment_template_internal(config[:vnet_id], config[:subnet_id])
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
def virtual_machine_deployment_template_internal(vnet_id, subnet_id)
|
369
|
+
<<-EOH
|
370
|
+
{
|
371
|
+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
372
|
+
"contentVersion": "1.0.0.0",
|
373
|
+
"parameters": {
|
374
|
+
"location": {
|
375
|
+
"type": "string",
|
376
|
+
"metadata": {
|
377
|
+
"description": "The location where the resources will be created."
|
378
|
+
}
|
379
|
+
},
|
380
|
+
"vmSize": {
|
381
|
+
"type": "string",
|
382
|
+
"metadata": {
|
383
|
+
"description": "The size of the VM to be created"
|
384
|
+
}
|
385
|
+
},
|
386
|
+
"newStorageAccountName": {
|
387
|
+
"type": "string",
|
388
|
+
"metadata": {
|
389
|
+
"description": "Unique DNS Name for the Storage Account where the Virtual Machine's disks will be placed."
|
390
|
+
}
|
391
|
+
},
|
392
|
+
"adminUsername": {
|
393
|
+
"type": "string",
|
394
|
+
"metadata": {
|
395
|
+
"description": "User name for the Virtual Machine."
|
396
|
+
}
|
397
|
+
},
|
398
|
+
"adminPassword": {
|
399
|
+
"type": "securestring",
|
400
|
+
"metadata": {
|
401
|
+
"description": "Password for the Virtual Machine."
|
402
|
+
}
|
403
|
+
},
|
404
|
+
"dnsNameForPublicIP": {
|
405
|
+
"type": "string",
|
406
|
+
"metadata": {
|
407
|
+
"description": "Unique DNS Name for the Public IP used to access the Virtual Machine."
|
408
|
+
}
|
409
|
+
},
|
410
|
+
"imagePublisher": {
|
411
|
+
"type": "string",
|
412
|
+
"defaultValue": "Canonical",
|
413
|
+
"metadata": {
|
414
|
+
"description": "Publisher for the VM, e.g. Canonical, MicrosoftWindowsServer"
|
415
|
+
}
|
416
|
+
},
|
417
|
+
"imageOffer": {
|
418
|
+
"type": "string",
|
419
|
+
"defaultValue": "UbuntuServer",
|
420
|
+
"metadata": {
|
421
|
+
"description": "Offer for the VM, e.g. UbuntuServer, WindowsServer."
|
422
|
+
}
|
423
|
+
},
|
424
|
+
"imageSku": {
|
425
|
+
"type": "string",
|
426
|
+
"defaultValue": "14.04.3-LTS",
|
427
|
+
"metadata": {
|
428
|
+
"description": "Sku for the VM, e.g. 14.04.3-LTS"
|
429
|
+
}
|
430
|
+
},
|
431
|
+
"imageVersion": {
|
432
|
+
"type": "string",
|
433
|
+
"defaultValue": "latest",
|
434
|
+
"metadata": {
|
435
|
+
"description": "Either a date or latest."
|
436
|
+
}
|
437
|
+
},
|
438
|
+
"vmName": {
|
439
|
+
"type": "string",
|
440
|
+
"defaultValue": "vm",
|
441
|
+
"metadata": {
|
442
|
+
"description": "The vm name created inside of the resource group."
|
443
|
+
}
|
444
|
+
},
|
445
|
+
"storageAccountType": {
|
446
|
+
"type": "string",
|
447
|
+
"defaultValue": "Standard_LRS",
|
448
|
+
"metadata": {
|
449
|
+
"description": "The type of storage to use (e.g. Standard_LRS or Premium_LRS)."
|
450
|
+
}
|
451
|
+
},
|
452
|
+
"bootDiagnosticsEnabled": {
|
453
|
+
"type": "string",
|
454
|
+
"defaultValue": "true",
|
455
|
+
"metadata": {
|
456
|
+
"description": "Whether to enable (true) or disable (false) boot diagnostics. Default: true (requires Standard storage)."
|
457
|
+
}
|
458
|
+
}
|
459
|
+
},
|
460
|
+
"variables": {
|
461
|
+
"location": "[parameters('location')]",
|
462
|
+
"OSDiskName": "osdisk",
|
463
|
+
"nicName": "nic",
|
464
|
+
"addressPrefix": "10.0.0.0/16",
|
465
|
+
"subnetName": "#{subnet_id}",
|
466
|
+
"subnetPrefix": "10.0.0.0/24",
|
467
|
+
"storageAccountType": "[parameters('storageAccountType')]",
|
468
|
+
"publicIPAddressName": "publicip",
|
469
|
+
"publicIPAddressType": "Dynamic",
|
470
|
+
"vmStorageAccountContainerName": "vhds",
|
471
|
+
"vmName": "[parameters('vmName')]",
|
472
|
+
"vmSize": "[parameters('vmSize')]",
|
473
|
+
"virtualNetworkName": "vnet",
|
474
|
+
"vnetID": "#{vnet_id}",
|
475
|
+
"subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]"
|
476
|
+
},
|
477
|
+
"resources": [
|
478
|
+
{
|
479
|
+
"type": "Microsoft.Storage/storageAccounts",
|
480
|
+
"name": "[parameters('newStorageAccountName')]",
|
481
|
+
"apiVersion": "2015-05-01-preview",
|
482
|
+
"location": "[variables('location')]",
|
483
|
+
"properties": {
|
484
|
+
"accountType": "[variables('storageAccountType')]"
|
485
|
+
}
|
486
|
+
},
|
487
|
+
{
|
488
|
+
"apiVersion": "2015-05-01-preview",
|
489
|
+
"type": "Microsoft.Network/networkInterfaces",
|
490
|
+
"name": "[variables('nicName')]",
|
491
|
+
"location": "[variables('location')]",
|
492
|
+
"properties": {
|
493
|
+
"ipConfigurations": [
|
494
|
+
{
|
495
|
+
"name": "ipconfig1",
|
496
|
+
"properties": {
|
497
|
+
"privateIPAllocationMethod": "Dynamic",
|
498
|
+
"subnet": {
|
499
|
+
"id": "[variables('subnetRef')]"
|
500
|
+
}
|
501
|
+
}
|
502
|
+
}
|
503
|
+
]
|
504
|
+
}
|
505
|
+
},
|
506
|
+
{
|
507
|
+
"apiVersion": "2015-06-15",
|
508
|
+
"type": "Microsoft.Compute/virtualMachines",
|
509
|
+
"name": "[variables('vmName')]",
|
510
|
+
"location": "[variables('location')]",
|
511
|
+
"dependsOn": [
|
512
|
+
"[concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName'))]",
|
513
|
+
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
|
514
|
+
],
|
515
|
+
"properties": {
|
516
|
+
"hardwareProfile": {
|
517
|
+
"vmSize": "[variables('vmSize')]"
|
518
|
+
},
|
519
|
+
"osProfile": {
|
520
|
+
"computername": "[variables('vmName')]",
|
521
|
+
"adminUsername": "[parameters('adminUsername')]",
|
522
|
+
"adminPassword": "[parameters('adminPassword')]"
|
523
|
+
},
|
524
|
+
"storageProfile": {
|
525
|
+
"imageReference": {
|
526
|
+
"publisher": "[parameters('imagePublisher')]",
|
527
|
+
"offer": "[parameters('imageOffer')]",
|
528
|
+
"sku": "[parameters('imageSku')]",
|
529
|
+
"version": "[parameters('imageVersion')]"
|
530
|
+
},
|
531
|
+
"osDisk": {
|
532
|
+
"name": "osdisk",
|
533
|
+
"vhd": {
|
534
|
+
"uri": "[concat('http://',parameters('newStorageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('OSDiskName'),'.vhd')]"
|
535
|
+
},
|
536
|
+
"caching": "ReadWrite",
|
537
|
+
"createOption": "FromImage"
|
538
|
+
}
|
539
|
+
},
|
540
|
+
"networkProfile": {
|
541
|
+
"networkInterfaces": [
|
542
|
+
{
|
543
|
+
"id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
|
544
|
+
}
|
545
|
+
]
|
546
|
+
},
|
547
|
+
"diagnosticsProfile": {
|
548
|
+
"bootDiagnostics": {
|
549
|
+
"enabled": "[parameters('bootDiagnosticsEnabled')]",
|
550
|
+
"storageUri": "[concat('http://',parameters('newStorageAccountName'),'.blob.core.windows.net')]"
|
551
|
+
}
|
552
|
+
}
|
553
|
+
}
|
554
|
+
}
|
555
|
+
]
|
556
|
+
}
|
557
|
+
EOH
|
558
|
+
end
|
559
|
+
|
560
|
+
def virtual_machine_deployment_template_public
|
342
561
|
<<-EOH
|
343
562
|
{
|
344
563
|
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-azurerm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Preston
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07
|
11
|
+
date: 2016-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inifile
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: concurrent-ruby
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 1.0.2
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 1.0.2
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: bundler
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
196
|
version: '0'
|
197
197
|
requirements: []
|
198
198
|
rubyforge_project:
|
199
|
-
rubygems_version: 2.6.
|
199
|
+
rubygems_version: 2.6.6
|
200
200
|
signing_key:
|
201
201
|
specification_version: 4
|
202
202
|
summary: Test Kitchen driver for Azure Resource Manager.
|