kitchen-azurerm 0.9.1 → 0.10.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 +5 -0
- data/README.md +137 -0
- data/lib/kitchen/driver/azurerm.rb +82 -11
- data/lib/kitchen/driver/credentials.rb +1 -1
- data/templates/internal.erb +107 -8
- data/templates/public.erb +108 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7e6e0ca8bce2a4cf7a5caf2d2cc72e68265ca20
|
4
|
+
data.tar.gz: 2668997b038ca7f8867aede1bbc24026d93fc651
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 444bdbc590bff6e80f040328ecb1e7c52e5754ef3d5d6b4a07878a64fdae27a3132df59f71c826f75449f10d77dce826b5dc0dec078a2132eeebaf255834366e
|
7
|
+
data.tar.gz: cc903b216802ebcae4661737e3d3d2e968d6803256eaaa1947b743648500030d6685701f705bb7eb597c32c9a2f35579b75639a80ef124f05d1031474a4ebcbe
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# kitchen-azurerm Changelog
|
2
2
|
|
3
|
+
## [0.10.0] - 2017-07-03
|
4
|
+
- Support for custom images (@elconas)
|
5
|
+
- Support for custom-data (Linux only) (@elconas)
|
6
|
+
- Support for custom OS sizes (@elconas)
|
7
|
+
|
3
8
|
## [0.9.1] - 2017-05-25
|
4
9
|
- Support for Managed Disks enabled by default (@stuartpreston)
|
5
10
|
- Add ```use_managed_disks``` driver_config parameter (@stuartpreston)
|
data/README.md
CHANGED
@@ -235,6 +235,138 @@ suites:
|
|
235
235
|
attributes:
|
236
236
|
```
|
237
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
|
+
|
238
370
|
## Support for Government and Sovereign Clouds (China and Germany)
|
239
371
|
|
240
372
|
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```
|
@@ -314,6 +446,11 @@ info: vm image list command OK
|
|
314
446
|
- The ```enable_boot_diagnostics``` parameter defaults to 'true' and allows you to switch off boot diagnostics in case you are using premium storage.
|
315
447
|
- The optional ```vm_tags``` parameter allows you to define key:value pairs to tag VMs with on creation.
|
316
448
|
- Managed disks are now enabled by default, to use the Storage account set ```use_managed_disks``` (default: true).
|
449
|
+
- 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)
|
450
|
+
- The ```image_id``` (managed disks only) parameter can be used to specify an image by id (managed disk). This works only with managed disks.
|
451
|
+
- The ```existing_storage_account_blob_url``` can be specified to specify an url to an existing storage account (needed for ```image_url```)
|
452
|
+
- 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.
|
453
|
+
- The ```os_disk_size_gb``` parameter can be used to specify a custom os disk size.
|
317
454
|
|
318
455
|
## Contributing
|
319
456
|
|
@@ -7,6 +7,8 @@ require 'base64'
|
|
7
7
|
require 'sshkey'
|
8
8
|
require 'fileutils'
|
9
9
|
require 'erb'
|
10
|
+
require 'ostruct'
|
11
|
+
require 'json'
|
10
12
|
|
11
13
|
module Kitchen
|
12
14
|
module Driver
|
@@ -24,6 +26,26 @@ module Kitchen
|
|
24
26
|
'Canonical:UbuntuServer:14.04.3-LTS:latest'
|
25
27
|
end
|
26
28
|
|
29
|
+
default_config(:image_url) do |_config|
|
30
|
+
''
|
31
|
+
end
|
32
|
+
|
33
|
+
default_config(:image_id) do |_config|
|
34
|
+
''
|
35
|
+
end
|
36
|
+
|
37
|
+
default_config(:os_disk_size_gb) do |_config|
|
38
|
+
''
|
39
|
+
end
|
40
|
+
|
41
|
+
default_config(:os_type) do |_config|
|
42
|
+
'linux'
|
43
|
+
end
|
44
|
+
|
45
|
+
default_config(:custom_data) do |_config|
|
46
|
+
''
|
47
|
+
end
|
48
|
+
|
27
49
|
default_config(:username) do |_config|
|
28
50
|
'azure'
|
29
51
|
end
|
@@ -48,6 +70,14 @@ module Kitchen
|
|
48
70
|
'Standard_LRS'
|
49
71
|
end
|
50
72
|
|
73
|
+
default_config(:existing_storage_account_blob_url) do |_config|
|
74
|
+
''
|
75
|
+
end
|
76
|
+
|
77
|
+
default_config(:existing_storage_account_container) do |_config|
|
78
|
+
'vhds'
|
79
|
+
end
|
80
|
+
|
51
81
|
default_config(:boot_diagnostics_enabled) do |_config|
|
52
82
|
'true'
|
53
83
|
end
|
@@ -82,7 +112,6 @@ module Kitchen
|
|
82
112
|
|
83
113
|
def create(state)
|
84
114
|
state = validate_state(state)
|
85
|
-
image_publisher, image_offer, image_sku, image_version = config[:image_urn].split(':', 4)
|
86
115
|
deployment_parameters = {
|
87
116
|
location: config[:location],
|
88
117
|
vmSize: config[:machine_size],
|
@@ -92,13 +121,44 @@ module Kitchen
|
|
92
121
|
adminUsername: state[:username],
|
93
122
|
adminPassword: state[:password] || 'P2ssw0rd',
|
94
123
|
dnsNameForPublicIP: "kitchen-#{state[:uuid]}",
|
95
|
-
imagePublisher: image_publisher,
|
96
|
-
imageOffer: image_offer,
|
97
|
-
imageSku: image_sku,
|
98
|
-
imageVersion: image_version,
|
99
124
|
vmName: state[:vm_name]
|
100
125
|
}
|
101
126
|
|
127
|
+
if config[:custom_data].to_s != ''
|
128
|
+
deployment_parameters['customData'] = prepared_custom_data
|
129
|
+
end
|
130
|
+
# When deploying in a shared storage account, we needs to add
|
131
|
+
# a unique suffix to support multiple kitchen instances
|
132
|
+
if config[:existing_storage_account_blob_url].to_s != ''
|
133
|
+
deployment_parameters['osDiskNameSuffix'] = "-#{state[:azure_resource_group_name]}"
|
134
|
+
end
|
135
|
+
if config[:existing_storage_account_blob_url].to_s != ''
|
136
|
+
deployment_parameters['existingStorageAccountBlobURL'] = config[:existing_storage_account_blob_url]
|
137
|
+
end
|
138
|
+
if config[:existing_storage_account_container].to_s != ''
|
139
|
+
deployment_parameters['existingStorageAccountBlobContainer'] = config[:existing_storage_account_container]
|
140
|
+
end
|
141
|
+
if config[:os_disk_size_gb].to_s != ''
|
142
|
+
deployment_parameters['osDiskSizeGb'] = config[:os_disk_size_gb]
|
143
|
+
end
|
144
|
+
|
145
|
+
# The three deployment modes
|
146
|
+
# a) Private Image: Managed VM Image (by id)
|
147
|
+
# b) Private Image: Using a VHD URL (note: we must use existing_storage_account_blob_url due to azure limitations)
|
148
|
+
# c) Public Image: Using a marketplace image (urn)
|
149
|
+
if config[:image_id].to_s != ''
|
150
|
+
deployment_parameters['imageId'] = config[:image_id]
|
151
|
+
elsif config[:image_url].to_s != ''
|
152
|
+
deployment_parameters['imageUrl'] = config[:image_url]
|
153
|
+
deployment_parameters['osType'] = config[:os_type]
|
154
|
+
else
|
155
|
+
image_publisher, image_offer, image_sku, image_version = config[:image_urn].split(':', 4)
|
156
|
+
deployment_parameters['imagePublisher'] = image_publisher
|
157
|
+
deployment_parameters['imageOffer'] = image_offer
|
158
|
+
deployment_parameters['imageSku'] = image_sku
|
159
|
+
deployment_parameters['imageVersion'] = image_version
|
160
|
+
end
|
161
|
+
|
102
162
|
credentials = Kitchen::Driver::Credentials.new.azure_credentials_for_subscription(config[:subscription_id], config[:azure_environment])
|
103
163
|
management_endpoint = resource_manager_endpoint_url(config[:azure_environment])
|
104
164
|
info "Azure environment: #{config[:azure_environment]}"
|
@@ -243,7 +303,7 @@ module Kitchen
|
|
243
303
|
deployment.properties.mode = Azure::ARM::Resources::Models::DeploymentMode::Incremental
|
244
304
|
deployment.properties.template = JSON.parse(template)
|
245
305
|
deployment.properties.parameters = parameters_in_values_format(parameters)
|
246
|
-
debug(deployment.properties.template)
|
306
|
+
debug(JSON.pretty_generate(deployment.properties.template))
|
247
307
|
deployment
|
248
308
|
end
|
249
309
|
|
@@ -380,18 +440,17 @@ logoff
|
|
380
440
|
|
381
441
|
def virtual_machine_deployment_template
|
382
442
|
if config[:vnet_id] == ''
|
383
|
-
virtual_machine_deployment_template_file('public.erb', vm_tags: vm_tag_string(config[:vm_tags]), use_managed_disks: config[:use_managed_disks])
|
443
|
+
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])
|
384
444
|
else
|
385
445
|
info "Using custom vnet: #{config[:vnet_id]}"
|
386
|
-
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])
|
446
|
+
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])
|
387
447
|
end
|
388
448
|
end
|
389
449
|
|
390
450
|
def virtual_machine_deployment_template_file(template_file, data = {})
|
391
451
|
template = File.read(File.expand_path(File.join(__dir__, '../../../templates', template_file)))
|
392
|
-
render_binding =
|
393
|
-
|
394
|
-
ERB.new(template, nil, '-').result(render_binding)
|
452
|
+
render_binding = OpenStruct.new(data)
|
453
|
+
ERB.new(template, nil, '-').result(render_binding.instance_eval { binding })
|
395
454
|
end
|
396
455
|
|
397
456
|
def resource_manager_endpoint_url(azure_environment)
|
@@ -406,6 +465,18 @@ logoff
|
|
406
465
|
MsRestAzure::AzureEnvironments::Azure.resource_manager_endpoint_url
|
407
466
|
end
|
408
467
|
end
|
468
|
+
|
469
|
+
def prepared_custom_data
|
470
|
+
# If user_data is a file reference, lets read it as such
|
471
|
+
return nil if config[:custom_data].nil?
|
472
|
+
@custom_data ||= begin
|
473
|
+
if File.file?(config[:custom_data])
|
474
|
+
Base64.strict_encode64(File.read(config[:custom_data]))
|
475
|
+
else
|
476
|
+
Base64.strict_encode64(config[:custom_data])
|
477
|
+
end
|
478
|
+
end
|
479
|
+
end
|
409
480
|
end
|
410
481
|
end
|
411
482
|
end
|
@@ -47,7 +47,7 @@ module Kitchen
|
|
47
47
|
when 'azurechina'
|
48
48
|
::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_china_settings
|
49
49
|
when 'azuregermancloud'
|
50
|
-
::MsRestAzure::ActiveDirectoryServiceSettings.
|
50
|
+
::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_german_settings
|
51
51
|
when 'azure'
|
52
52
|
::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_settings
|
53
53
|
end
|
data/templates/internal.erb
CHANGED
@@ -38,6 +38,61 @@
|
|
38
38
|
"description": "Unique DNS Name for the Public IP used to access the Virtual Machine."
|
39
39
|
}
|
40
40
|
},
|
41
|
+
<%- unless os_disk_size_gb.to_s.empty? -%>
|
42
|
+
"osDiskSizeGb": {
|
43
|
+
"type": "int",
|
44
|
+
"minValue": 1,
|
45
|
+
"maxValue": 1023,
|
46
|
+
"metadata": {
|
47
|
+
"description": "Size of the OS disks in GB."
|
48
|
+
}
|
49
|
+
},
|
50
|
+
<%- end -%>
|
51
|
+
<%- unless custom_data.empty? -%>
|
52
|
+
"customData": {
|
53
|
+
"type": "string",
|
54
|
+
"metadata": {
|
55
|
+
"description": "Custom Data for the instance (e.g. cloud-init or script) - not compatible with winrm."
|
56
|
+
}
|
57
|
+
},
|
58
|
+
<%- end -%>
|
59
|
+
<%- if !existing_storage_account_blob_url.empty? -%>
|
60
|
+
"existingStorageAccountBlobURL": {
|
61
|
+
"type": "string",
|
62
|
+
"metadata": {
|
63
|
+
"description": "The URL of the existing storage account (blob) (without container)"
|
64
|
+
}
|
65
|
+
},
|
66
|
+
<%- end -%>
|
67
|
+
<%- if !existing_storage_account_container.empty? -%>
|
68
|
+
"existingStorageAccountBlobContainer": {
|
69
|
+
"type": "string",
|
70
|
+
"metadata": {
|
71
|
+
"description": "The Container Name for OS Images (blob)"
|
72
|
+
}
|
73
|
+
},
|
74
|
+
<%- end -%>
|
75
|
+
<%- if !image_url.empty? -%>
|
76
|
+
"imageUrl": {
|
77
|
+
"type": "string",
|
78
|
+
"metadata": {
|
79
|
+
"description": "An URL for a private Image (vhd)"
|
80
|
+
}
|
81
|
+
},
|
82
|
+
"osType": {
|
83
|
+
"type": "string",
|
84
|
+
"metadata": {
|
85
|
+
"description": "An OS Type (linux, windows)"
|
86
|
+
}
|
87
|
+
},
|
88
|
+
<%- elsif !image_id.empty? -%>
|
89
|
+
"imageId": {
|
90
|
+
"type": "string",
|
91
|
+
"metadata": {
|
92
|
+
"description": "The id of a managed image"
|
93
|
+
}
|
94
|
+
},
|
95
|
+
<%- else -%>
|
41
96
|
"imagePublisher": {
|
42
97
|
"type": "string",
|
43
98
|
"defaultValue": "Canonical",
|
@@ -66,6 +121,14 @@
|
|
66
121
|
"description": "Either a date or latest."
|
67
122
|
}
|
68
123
|
},
|
124
|
+
<%- end -%>
|
125
|
+
"osDiskNameSuffix": {
|
126
|
+
"type": "string",
|
127
|
+
"defaultValue": "",
|
128
|
+
"metadata": {
|
129
|
+
"description": "A disk Name Suffix to make the disk name unique in existing storage accounts."
|
130
|
+
}
|
131
|
+
},
|
69
132
|
"vmName": {
|
70
133
|
"type": "string",
|
71
134
|
"defaultValue": "vm",
|
@@ -108,6 +171,7 @@
|
|
108
171
|
},
|
109
172
|
"resources": [
|
110
173
|
<%- unless use_managed_disks -%>
|
174
|
+
<%- if existing_storage_account_blob_url.empty? -%>
|
111
175
|
{
|
112
176
|
"type": "Microsoft.Storage/storageAccounts",
|
113
177
|
"name": "[parameters('newStorageAccountName')]",
|
@@ -121,6 +185,7 @@
|
|
121
185
|
}
|
122
186
|
},
|
123
187
|
<%- end -%>
|
188
|
+
<%- end -%>
|
124
189
|
<%- if public_ip -%>
|
125
190
|
{
|
126
191
|
"apiVersion": "2015-05-01-preview",
|
@@ -177,8 +242,10 @@
|
|
177
242
|
"location": "[variables('location')]",
|
178
243
|
"dependsOn": [
|
179
244
|
<%- unless use_managed_disks -%>
|
245
|
+
<%- if existing_storage_account_blob_url.empty? -%>
|
180
246
|
"[concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName'))]",
|
181
247
|
<%- end -%>
|
248
|
+
<%- end -%>
|
182
249
|
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
|
183
250
|
],
|
184
251
|
"properties": {
|
@@ -187,29 +254,57 @@
|
|
187
254
|
},
|
188
255
|
"osProfile": {
|
189
256
|
"computername": "[variables('vmName')]",
|
257
|
+
<%- unless custom_data.empty? -%>
|
258
|
+
"customData": "[parameters('customData')]",
|
259
|
+
<%- end -%>
|
190
260
|
"adminUsername": "[parameters('adminUsername')]",
|
191
261
|
"adminPassword": "[parameters('adminPassword')]"
|
192
262
|
},
|
193
263
|
"storageProfile": {
|
264
|
+
<%- if image_url.empty? and image_id.empty? -%>
|
194
265
|
"imageReference": {
|
195
266
|
"publisher": "[parameters('imagePublisher')]",
|
196
267
|
"offer": "[parameters('imageOffer')]",
|
197
268
|
"sku": "[parameters('imageSku')]",
|
198
269
|
"version": "[parameters('imageVersion')]"
|
199
270
|
},
|
200
|
-
<%-
|
271
|
+
<%- elsif !image_id.empty? -%>
|
272
|
+
"imageReference": {
|
273
|
+
"id": "[parameters('imageId')]"
|
274
|
+
},
|
275
|
+
<%- end -%>
|
276
|
+
<%- if use_managed_disks -%>
|
201
277
|
"osDisk": {
|
202
278
|
"name": "osdisk",
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
"caching": "ReadWrite",
|
279
|
+
<%- unless os_disk_size_gb.to_s.empty? -%>
|
280
|
+
"diskSizeGB": "[parameters('osDiskSizeGB')]",
|
281
|
+
<%- end -%>
|
207
282
|
"createOption": "FromImage"
|
208
283
|
}
|
209
|
-
<%-
|
210
|
-
<%- if use_managed_disks -%>
|
284
|
+
<%- else -%>
|
211
285
|
"osDisk": {
|
212
286
|
"name": "osdisk",
|
287
|
+
<%- unless os_disk_size_gb.to_s.empty? -%>
|
288
|
+
"diskSizeGB": "[parameters('osDiskSizeGB')]",
|
289
|
+
<%- end -%>
|
290
|
+
<%- if !image_url.empty? -%>
|
291
|
+
"image": {
|
292
|
+
"uri": "[parameters('imageUrl')]"
|
293
|
+
},
|
294
|
+
"osType": "[parameters('osType')]",
|
295
|
+
<%- end -%>
|
296
|
+
"vhd": {
|
297
|
+
<%- if existing_storage_account_blob_url.empty? -%>
|
298
|
+
"uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName')), '2015-06-15').primaryEndpoints.blob, variables('vmStorageAccountContainerName'), '/',variables('OSDiskName'),parameters('osDiskNameSuffix'),'.vhd')]"
|
299
|
+
<%- else -%>
|
300
|
+
<%- if existing_storage_account_container.empty? -%>
|
301
|
+
"uri": "[concat(parameters('existingStorageAccountBlobURL'), '/', variables('vmStorageAccountContainerName'), '/', variables('OSDiskName'),parameters('osDiskNameSuffix'),'.vhd')]"
|
302
|
+
<%- else -%>
|
303
|
+
"uri": "[concat(parameters('existingStorageAccountBlobURL'), '/', parameters('existingStorageAccountBlobContainer'), '/', variables('OSDiskName'),parameters('osDiskNameSuffix'),'.vhd')]"
|
304
|
+
<%- end -%>
|
305
|
+
<%- end -%>
|
306
|
+
},
|
307
|
+
"caching": "ReadWrite",
|
213
308
|
"createOption": "FromImage"
|
214
309
|
}
|
215
310
|
<%- end -%>
|
@@ -225,7 +320,11 @@
|
|
225
320
|
<%- unless use_managed_disks -%>
|
226
321
|
"bootDiagnostics": {
|
227
322
|
"enabled": "[parameters('bootDiagnosticsEnabled')]",
|
323
|
+
<%- if existing_storage_account_blob_url.empty? -%>
|
228
324
|
"storageUri": "[reference(concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName')), '2015-06-15').primaryEndpoints.blob]"
|
325
|
+
<%- else -%>
|
326
|
+
"storageUri": "[parameters('existingStorageAccountBlobURL')]"
|
327
|
+
<%- end -%>
|
229
328
|
}
|
230
329
|
<%- end -%>
|
231
330
|
}
|
@@ -236,4 +335,4 @@
|
|
236
335
|
}
|
237
336
|
}
|
238
337
|
]
|
239
|
-
}
|
338
|
+
}
|
data/templates/public.erb
CHANGED
@@ -38,6 +38,61 @@
|
|
38
38
|
"description": "Unique DNS Name for the Public IP used to access the Virtual Machine."
|
39
39
|
}
|
40
40
|
},
|
41
|
+
<%- unless os_disk_size_gb.to_s.empty? -%>
|
42
|
+
"osDiskSizeGb": {
|
43
|
+
"type": "int",
|
44
|
+
"minValue": 1,
|
45
|
+
"maxValue": 1023,
|
46
|
+
"metadata": {
|
47
|
+
"description": "Size of the OS disks in GB."
|
48
|
+
}
|
49
|
+
},
|
50
|
+
<%- end -%>
|
51
|
+
<%- unless custom_data.empty? -%>
|
52
|
+
"customData": {
|
53
|
+
"type": "string",
|
54
|
+
"metadata": {
|
55
|
+
"description": "Custom Data for the instance (e.g. cloud-init or script) - not compatible with winrm."
|
56
|
+
}
|
57
|
+
},
|
58
|
+
<%- end -%>
|
59
|
+
<%- if !existing_storage_account_blob_url.empty? -%>
|
60
|
+
"existingStorageAccountBlobURL": {
|
61
|
+
"type": "string",
|
62
|
+
"metadata": {
|
63
|
+
"description": "The URL of the existing storage account (blob) (without container)"
|
64
|
+
}
|
65
|
+
},
|
66
|
+
<%- end -%>
|
67
|
+
<%- if !existing_storage_account_container.empty? -%>
|
68
|
+
"existingStorageAccountBlobContainer": {
|
69
|
+
"type": "string",
|
70
|
+
"metadata": {
|
71
|
+
"description": "The Container Name for OS Images (blob)"
|
72
|
+
}
|
73
|
+
},
|
74
|
+
<%- end -%>
|
75
|
+
<%- if !image_url.empty? -%>
|
76
|
+
"imageUrl": {
|
77
|
+
"type": "string",
|
78
|
+
"metadata": {
|
79
|
+
"description": "An URL for a private Image (vhd)"
|
80
|
+
}
|
81
|
+
},
|
82
|
+
"osType": {
|
83
|
+
"type": "string",
|
84
|
+
"metadata": {
|
85
|
+
"description": "An OS Type (linux, windows)"
|
86
|
+
}
|
87
|
+
},
|
88
|
+
<%- elsif !image_id.empty? -%>
|
89
|
+
"imageId": {
|
90
|
+
"type": "string",
|
91
|
+
"metadata": {
|
92
|
+
"description": "The id of a managed image"
|
93
|
+
}
|
94
|
+
},
|
95
|
+
<%- else -%>
|
41
96
|
"imagePublisher": {
|
42
97
|
"type": "string",
|
43
98
|
"defaultValue": "Canonical",
|
@@ -66,6 +121,14 @@
|
|
66
121
|
"description": "Either a date or latest."
|
67
122
|
}
|
68
123
|
},
|
124
|
+
<%- end -%>
|
125
|
+
"osDiskNameSuffix": {
|
126
|
+
"type": "string",
|
127
|
+
"defaultValue": "",
|
128
|
+
"metadata": {
|
129
|
+
"description": "A disk Name Suffix to make the disk name unique in existing storage accounts."
|
130
|
+
}
|
131
|
+
},
|
69
132
|
"vmName": {
|
70
133
|
"type": "string",
|
71
134
|
"defaultValue": "vm",
|
@@ -82,7 +145,7 @@
|
|
82
145
|
},
|
83
146
|
"bootDiagnosticsEnabled": {
|
84
147
|
"type": "string",
|
85
|
-
"defaultValue": "
|
148
|
+
"defaultValue": "true",
|
86
149
|
"metadata": {
|
87
150
|
"description": "Whether to enable (true) or disable (false) boot diagnostics. Default: false."
|
88
151
|
}
|
@@ -108,6 +171,7 @@
|
|
108
171
|
},
|
109
172
|
"resources": [
|
110
173
|
<%- unless use_managed_disks -%>
|
174
|
+
<%- if existing_storage_account_blob_url.empty? -%>
|
111
175
|
{
|
112
176
|
"type": "Microsoft.Storage/storageAccounts",
|
113
177
|
"name": "[parameters('newStorageAccountName')]",
|
@@ -121,6 +185,7 @@
|
|
121
185
|
}
|
122
186
|
},
|
123
187
|
<%- end -%>
|
188
|
+
<%- end -%>
|
124
189
|
{
|
125
190
|
"apiVersion": "2015-05-01-preview",
|
126
191
|
"type": "Microsoft.Network/publicIPAddresses",
|
@@ -196,8 +261,10 @@
|
|
196
261
|
"location": "[variables('location')]",
|
197
262
|
"dependsOn": [
|
198
263
|
<%- unless use_managed_disks -%>
|
264
|
+
<%- if existing_storage_account_blob_url.empty? -%>
|
199
265
|
"[concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName'))]",
|
200
266
|
<%- end -%>
|
267
|
+
<%- end -%>
|
201
268
|
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
|
202
269
|
],
|
203
270
|
"properties": {
|
@@ -206,29 +273,57 @@
|
|
206
273
|
},
|
207
274
|
"osProfile": {
|
208
275
|
"computername": "[variables('vmName')]",
|
276
|
+
<%- unless custom_data.empty? -%>
|
277
|
+
"customData": "[parameters('customData')]",
|
278
|
+
<%- end -%>
|
209
279
|
"adminUsername": "[parameters('adminUsername')]",
|
210
280
|
"adminPassword": "[parameters('adminPassword')]"
|
211
281
|
},
|
212
282
|
"storageProfile": {
|
283
|
+
<%- if image_url.empty? and image_id.empty? -%>
|
213
284
|
"imageReference": {
|
214
285
|
"publisher": "[parameters('imagePublisher')]",
|
215
286
|
"offer": "[parameters('imageOffer')]",
|
216
287
|
"sku": "[parameters('imageSku')]",
|
217
288
|
"version": "[parameters('imageVersion')]"
|
218
289
|
},
|
219
|
-
<%-
|
290
|
+
<%- elsif !image_id.empty? -%>
|
291
|
+
"imageReference": {
|
292
|
+
"id": "[parameters('imageId')]"
|
293
|
+
},
|
294
|
+
<%- end -%>
|
295
|
+
<%- if use_managed_disks -%>
|
220
296
|
"osDisk": {
|
221
297
|
"name": "osdisk",
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
"caching": "ReadWrite",
|
298
|
+
<%- unless os_disk_size_gb.to_s.empty? -%>
|
299
|
+
"diskSizeGB": "[parameters('osDiskSizeGB')]",
|
300
|
+
<%- end -%>
|
226
301
|
"createOption": "FromImage"
|
227
302
|
}
|
228
|
-
<%-
|
229
|
-
<%- if use_managed_disks -%>
|
303
|
+
<%- else -%>
|
230
304
|
"osDisk": {
|
231
305
|
"name": "osdisk",
|
306
|
+
<%- if !image_url.empty? -%>
|
307
|
+
<%- unless os_disk_size_gb.to_s.empty? -%>
|
308
|
+
"diskSizeGB": "[parameters('osDiskSizeGB')]",
|
309
|
+
<%- end -%>
|
310
|
+
"image": {
|
311
|
+
"uri": "[parameters('imageUrl')]"
|
312
|
+
},
|
313
|
+
"osType": "[parameters('osType')]",
|
314
|
+
<%- end -%>
|
315
|
+
"vhd": {
|
316
|
+
<%- if existing_storage_account_blob_url.empty? -%>
|
317
|
+
"uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName')), '2015-06-15').primaryEndpoints.blob, variables('vmStorageAccountContainerName'), '/',variables('OSDiskName'),parameters('osDiskNameSuffix'),'.vhd')]"
|
318
|
+
<%- else -%>
|
319
|
+
<%- if existing_storage_account_container.empty? -%>
|
320
|
+
"uri": "[concat(parameters('existingStorageAccountBlobURL'), '/', variables('vmStorageAccountContainerName'), '/', variables('OSDiskName'),parameters('osDiskNameSuffix'),'.vhd')]"
|
321
|
+
<%- else -%>
|
322
|
+
"uri": "[concat(parameters('existingStorageAccountBlobURL'), '/', parameters('existingStorageAccountBlobContainer'), '/', variables('OSDiskName'),parameters('osDiskNameSuffix'),'.vhd')]"
|
323
|
+
<%- end -%>
|
324
|
+
<%- end -%>
|
325
|
+
},
|
326
|
+
"caching": "ReadWrite",
|
232
327
|
"createOption": "FromImage"
|
233
328
|
}
|
234
329
|
<%- end -%>
|
@@ -244,7 +339,11 @@
|
|
244
339
|
<%- unless use_managed_disks -%>
|
245
340
|
"bootDiagnostics": {
|
246
341
|
"enabled": "[parameters('bootDiagnosticsEnabled')]",
|
342
|
+
<%- if existing_storage_account_blob_url.empty? -%>
|
247
343
|
"storageUri": "[reference(concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName')), '2015-06-15').primaryEndpoints.blob]"
|
344
|
+
<%- else -%>
|
345
|
+
"storageUri": "[parameters('existingStorageAccountBlobURL')]"
|
346
|
+
<%- end -%>
|
248
347
|
}
|
249
348
|
<%- end -%>
|
250
349
|
}
|
@@ -255,4 +354,4 @@
|
|
255
354
|
}
|
256
355
|
}
|
257
356
|
]
|
258
|
-
}
|
357
|
+
}
|
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.10.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: 2017-
|
11
|
+
date: 2017-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inifile
|
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
version: '0'
|
181
181
|
requirements: []
|
182
182
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.6.
|
183
|
+
rubygems_version: 2.6.11
|
184
184
|
signing_key:
|
185
185
|
specification_version: 4
|
186
186
|
summary: Test Kitchen driver for Azure Resource Manager.
|