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.
@@ -1,61 +1,69 @@
1
- require 'inifile'
2
-
3
- module Kitchen
4
- module Driver
5
- #
6
- # Credentials
7
- #
8
- class Credentials
9
- CONFIG_PATH = "#{ENV['HOME']}/.azure/credentials".freeze
10
-
11
- #
12
- # Creates and initializes a new instance of the Credentials class.
13
- #
14
- def initialize
15
- config_file = ENV['AZURE_CONFIG_FILE'] || File.expand_path(CONFIG_PATH)
16
- if File.file?(config_file)
17
- @credentials = IniFile.load(File.expand_path(config_file))
18
- else
19
- warn "#{CONFIG_PATH} was not found or not accessible."
20
- end
21
- end
22
-
23
- #
24
- # Retrieves a [MsRest::TokenCredentials] object representing a token for the given Service Principal.
25
- # @param subscription_id [String] The subscription_id to retrieve a token for
26
- #
27
- # @return [MsRest::TokenCredentials] TokenCredentials object to be passed in with each subsequent request.
28
- #
29
- def azure_credentials_for_subscription(subscription_id, azure_environment)
30
- tenant_id = ENV['AZURE_TENANT_ID'] || @credentials[subscription_id]['tenant_id']
31
- client_id = ENV['AZURE_CLIENT_ID'] || @credentials[subscription_id]['client_id']
32
- client_secret = ENV['AZURE_CLIENT_SECRET'] || @credentials[subscription_id]['client_secret']
33
- token_provider = ::MsRestAzure::ApplicationTokenProvider.new(tenant_id, client_id, client_secret, settings_for_azure_environment(azure_environment))
34
- ::MsRest::TokenCredentials.new(token_provider)
35
- end
36
-
37
- #
38
- # Retrieves a [MsRestAzure::ActiveDirectoryServiceSettings] object representing the settings for the given cloud.
39
- # @param azure_environment [String] The Azure environment to retrieve settings for.
40
- #
41
- # @return [MsRestAzure::ActiveDirectoryServiceSettings] Settings to be used for subsequent requests
42
- #
43
- def settings_for_azure_environment(azure_environment)
44
- case azure_environment.downcase
45
- when 'azureusgovernment'
46
- ::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_us_government_settings
47
- when 'azurechina'
48
- ::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_china_settings
49
- when 'azuregermancloud'
50
- ::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_german_settings
51
- when 'azure'
52
- ::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_settings
53
- end
54
- end
55
-
56
- def self.singleton
57
- @credentials ||= Credentials.new
58
- end
59
- end
60
- end
61
- end
1
+ require 'inifile'
2
+
3
+ module Kitchen
4
+ module Driver
5
+ #
6
+ # Credentials
7
+ #
8
+ class Credentials
9
+ CONFIG_PATH = "#{ENV['HOME']}/.azure/credentials".freeze
10
+
11
+ #
12
+ # Creates and initializes a new instance of the Credentials class.
13
+ #
14
+ def initialize
15
+ config_file = ENV['AZURE_CONFIG_FILE'] || File.expand_path(CONFIG_PATH)
16
+ if File.file?(config_file)
17
+ @credentials = IniFile.load(File.expand_path(config_file))
18
+ else
19
+ warn "#{CONFIG_PATH} was not found or not accessible."
20
+ end
21
+ end
22
+
23
+ #
24
+ # Retrieves an object containing options and credentials for the given
25
+ # subscription_id and azure_environment.
26
+ #
27
+ # @param subscription_id [String] The subscription_id to retrieve a token for
28
+ # @param azure_environment [String] The azure_environment to use
29
+ #
30
+ # @return [Object] Object that can be supplied along with all Azure client requests.
31
+ #
32
+ def azure_options_for_subscription(subscription_id, azure_environment = 'Azure')
33
+ tenant_id = ENV['AZURE_TENANT_ID'] || @credentials[subscription_id]['tenant_id']
34
+ client_id = ENV['AZURE_CLIENT_ID'] || @credentials[subscription_id]['client_id']
35
+ client_secret = ENV['AZURE_CLIENT_SECRET'] || @credentials[subscription_id]['client_secret']
36
+ token_provider = ::MsRestAzure::ApplicationTokenProvider.new(tenant_id, client_id, client_secret, settings_for_azure_environment(azure_environment))
37
+ options = { tenant_id: tenant_id,
38
+ client_id: client_id,
39
+ client_secret: client_secret,
40
+ subscription_id: subscription_id,
41
+ credentials: ::MsRest::TokenCredentials.new(token_provider) }
42
+ options
43
+ end
44
+
45
+ #
46
+ # Retrieves a [MsRestAzure::ActiveDirectoryServiceSettings] object representing the settings for the given cloud.
47
+ # @param azure_environment [String] The Azure environment to retrieve settings for.
48
+ #
49
+ # @return [MsRestAzure::ActiveDirectoryServiceSettings] Settings to be used for subsequent requests
50
+ #
51
+ def settings_for_azure_environment(azure_environment)
52
+ case azure_environment.downcase
53
+ when 'azureusgovernment'
54
+ ::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_us_government_settings
55
+ when 'azurechina'
56
+ ::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_china_settings
57
+ when 'azuregermancloud'
58
+ ::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_german_settings
59
+ when 'azure'
60
+ ::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_settings
61
+ end
62
+ end
63
+
64
+ def self.singleton
65
+ @credentials ||= Credentials.new
66
+ end
67
+ end
68
+ end
69
+ end
@@ -1,350 +1,350 @@
1
- {
2
- "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
3
- "contentVersion": "1.0.0.0",
4
- "parameters": {
5
- "location": {
6
- "type": "string",
7
- "metadata": {
8
- "description": "The location where the resources will be created."
9
- }
10
- },
11
- "vmSize": {
12
- "type": "string",
13
- "metadata": {
14
- "description": "The size of the VM to be created"
15
- }
16
- },
17
- "newStorageAccountName": {
18
- "type": "string",
19
- "metadata": {
20
- "description": "Unique DNS Name for the Storage Account where the Virtual Machine's disks will be placed."
21
- }
22
- },
23
- "adminUsername": {
24
- "type": "string",
25
- "metadata": {
26
- "description": "User name for the Virtual Machine."
27
- }
28
- },
29
- "adminPassword": {
30
- "type": "securestring",
31
- "metadata": {
32
- "description": "Password for the Virtual Machine."
33
- }
34
- },
35
- "dnsNameForPublicIP": {
36
- "type": "string",
37
- "metadata": {
38
- "description": "Unique DNS Name for the Public IP used to access the Virtual Machine."
39
- }
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 -%>
96
- "imagePublisher": {
97
- "type": "string",
98
- "defaultValue": "Canonical",
99
- "metadata": {
100
- "description": "Publisher for the VM, e.g. Canonical, MicrosoftWindowsServer"
101
- }
102
- },
103
- "imageOffer": {
104
- "type": "string",
105
- "defaultValue": "UbuntuServer",
106
- "metadata": {
107
- "description": "Offer for the VM, e.g. UbuntuServer, WindowsServer."
108
- }
109
- },
110
- "imageSku": {
111
- "type": "string",
112
- "defaultValue": "14.04.3-LTS",
113
- "metadata": {
114
- "description": "Sku for the VM, e.g. 14.04.3-LTS"
115
- }
116
- },
117
- "imageVersion": {
118
- "type": "string",
119
- "defaultValue": "latest",
120
- "metadata": {
121
- "description": "Either a date or latest."
122
- }
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
- },
132
- "vmName": {
133
- "type": "string",
134
- "defaultValue": "vm",
135
- "metadata": {
136
- "description": "The vm name created inside of the resource group."
137
- }
138
- },
139
- "storageAccountType": {
140
- "type": "string",
141
- "defaultValue": "Standard_LRS",
142
- "metadata": {
143
- "description": "The type of storage to use (e.g. Standard_LRS or Premium_LRS)."
144
- }
145
- },
146
- "bootDiagnosticsEnabled": {
147
- "type": "string",
148
- "defaultValue": "true",
149
- "metadata": {
150
- "description": "Whether to enable (true) or disable (false) boot diagnostics. Default: true (requires Standard storage)."
151
- }
152
- }
153
- },
154
- "variables": {
155
- "location": "[parameters('location')]",
156
- "OSDiskName": "osdisk",
157
- "nicName": "nic",
158
- "addressPrefix": "10.0.0.0/16",
159
- "subnetName": "<%= subnet_id %>",
160
- "subnetPrefix": "10.0.0.0/24",
161
- "storageAccountType": "[parameters('storageAccountType')]",
162
- "publicIPAddressName": "publicip",
163
- "publicIPAddressType": "Dynamic",
164
- "vmStorageAccountContainerName": "vhds",
165
- "vmName": "[parameters('vmName')]",
166
- "vmSize": "[parameters('vmSize')]",
167
- "virtualNetworkName": "vnet",
168
- "vnetID": "<%= vnet_id %>",
169
- "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]"
170
- },
171
- "resources": [
172
- {
173
- "apiVersion": "2017-05-10",
174
- "name": "pid-18d63047-6cdf-4f34-beed-62f01fc73fc2",
175
- "type": "Microsoft.Resources/deployments",
176
- "properties": {
177
- "mode": "Incremental",
178
- "template": {
179
- "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
180
- "contentVersion": "1.0.0.0",
181
- "resources": []
182
- }
183
- }
184
- },
185
- <%- unless use_managed_disks -%>
186
- <%- if existing_storage_account_blob_url.empty? -%>
187
- {
188
- "type": "Microsoft.Storage/storageAccounts",
189
- "name": "[parameters('newStorageAccountName')]",
190
- "apiVersion": "2015-05-01-preview",
191
- "location": "[variables('location')]",
192
- "properties": {
193
- "accountType": "[variables('storageAccountType')]"
194
- },
195
- "tags": {
196
- }
197
- },
198
- <%- end -%>
199
- <%- end -%>
200
- <%- if public_ip -%>
201
- {
202
- "apiVersion": "2015-05-01-preview",
203
- "type": "Microsoft.Network/publicIPAddresses",
204
- "name": "[variables('publicIPAddressName')]",
205
- "location": "[variables('location')]",
206
- "properties": {
207
- "publicIPAllocationMethod": "[variables('publicIPAddressType')]",
208
- "dnsSettings": {
209
- "domainNameLabel": "[parameters('dnsNameForPublicIP')]"
210
- }
211
- },
212
- "tags": {
213
- }
214
- },
215
- <%- end -%>
216
- {
217
- "apiVersion": "2015-05-01-preview",
218
- "type": "Microsoft.Network/networkInterfaces",
219
- "name": "[variables('nicName')]",
220
- "location": "[variables('location')]",
221
- <%- if public_ip -%>
222
- "dependsOn": [
223
- "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]"
224
- ],
225
- <%- end -%>
226
- "properties": {
227
- "ipConfigurations": [
228
- {
229
- "name": "ipconfig1",
230
- "properties": {
231
- "privateIPAllocationMethod": "Dynamic",
232
- <%- if public_ip -%>
233
- "publicIPAddress": {
234
- "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
235
- },
236
- <%- end -%>
237
- "subnet": {
238
- "id": "[variables('subnetRef')]"
239
- }
240
- }
241
- }
242
- ]
243
- },
244
- "tags": {
245
- }
246
- },
247
- {
248
- "apiVersion": "2017-03-30",
249
- "type": "Microsoft.Compute/virtualMachines",
250
- "name": "[variables('vmName')]",
251
- "location": "[variables('location')]",
252
- "dependsOn": [
253
- <%- unless use_managed_disks -%>
254
- <%- if existing_storage_account_blob_url.empty? -%>
255
- "[concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName'))]",
256
- <%- end -%>
257
- <%- end -%>
258
- "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
259
- ],
260
- "properties": {
261
- "hardwareProfile": {
262
- "vmSize": "[variables('vmSize')]"
263
- },
264
- "osProfile": {
265
- "computername": "[variables('vmName')]",
266
- <%- unless custom_data.empty? -%>
267
- "customData": "[parameters('customData')]",
268
- <%- end -%>
269
- "adminUsername": "[parameters('adminUsername')]",
270
- "adminPassword": "[parameters('adminPassword')]"
271
- },
272
- "storageProfile": {
273
- <%- if image_url.empty? and image_id.empty? -%>
274
- "imageReference": {
275
- "publisher": "[parameters('imagePublisher')]",
276
- "offer": "[parameters('imageOffer')]",
277
- "sku": "[parameters('imageSku')]",
278
- "version": "[parameters('imageVersion')]"
279
- },
280
- <%- elsif !image_id.empty? -%>
281
- "imageReference": {
282
- "id": "[parameters('imageId')]"
283
- },
284
- <%- end -%>
285
- <%- if use_managed_disks -%>
286
- "osDisk": {
287
- "name": "osdisk",
288
- <%- unless os_disk_size_gb.to_s.empty? -%>
289
- "diskSizeGB": "[parameters('osDiskSizeGB')]",
290
- <%- end -%>
291
- "createOption": "FromImage"
292
- }
293
- <%- else -%>
294
- "osDisk": {
295
- "name": "osdisk",
296
- <%- unless os_disk_size_gb.to_s.empty? -%>
297
- "diskSizeGB": "[parameters('osDiskSizeGB')]",
298
- <%- end -%>
299
- <%- if !image_url.empty? -%>
300
- "image": {
301
- "uri": "[parameters('imageUrl')]"
302
- },
303
- "osType": "[parameters('osType')]",
304
- <%- end -%>
305
- "vhd": {
306
- <%- if existing_storage_account_blob_url.empty? -%>
307
- "uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName')), '2015-06-15').primaryEndpoints.blob, variables('vmStorageAccountContainerName'), '/',variables('OSDiskName'),parameters('osDiskNameSuffix'),'.vhd')]"
308
- <%- else -%>
309
- <%- if existing_storage_account_container.empty? -%>
310
- "uri": "[concat(parameters('existingStorageAccountBlobURL'), '/', variables('vmStorageAccountContainerName'), '/', variables('OSDiskName'),parameters('osDiskNameSuffix'),'.vhd')]"
311
- <%- else -%>
312
- "uri": "[concat(parameters('existingStorageAccountBlobURL'), '/', parameters('existingStorageAccountBlobContainer'), '/', variables('OSDiskName'),parameters('osDiskNameSuffix'),'.vhd')]"
313
- <%- end -%>
314
- <%- end -%>
315
- },
316
- "caching": "ReadWrite",
317
- "createOption": "FromImage"
318
- }
319
- <%- end -%>
320
- <%- unless data_disks_for_vm_json.nil? -%>
321
- ,"dataDisks":
322
- <%= data_disks_for_vm_json %>
323
- <%- end -%>
324
- },
325
- "networkProfile": {
326
- "networkInterfaces": [
327
- {
328
- "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
329
- }
330
- ]
331
- },
332
- "diagnosticsProfile": {
333
- <%- unless use_managed_disks -%>
334
- "bootDiagnostics": {
335
- "enabled": "[parameters('bootDiagnosticsEnabled')]",
336
- <%- if existing_storage_account_blob_url.empty? -%>
337
- "storageUri": "[reference(concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName')), '2015-06-15').primaryEndpoints.blob]"
338
- <%- else -%>
339
- "storageUri": "[parameters('existingStorageAccountBlobURL')]"
340
- <%- end -%>
341
- }
342
- <%- end -%>
343
- }
344
- },
345
- "tags": {
346
- <%= vm_tags unless vm_tags.empty? %>
347
- }
348
- }
349
- ]
350
- }
1
+ {
2
+ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
3
+ "contentVersion": "1.0.0.0",
4
+ "parameters": {
5
+ "location": {
6
+ "type": "string",
7
+ "metadata": {
8
+ "description": "The location where the resources will be created."
9
+ }
10
+ },
11
+ "vmSize": {
12
+ "type": "string",
13
+ "metadata": {
14
+ "description": "The size of the VM to be created"
15
+ }
16
+ },
17
+ "newStorageAccountName": {
18
+ "type": "string",
19
+ "metadata": {
20
+ "description": "Unique DNS Name for the Storage Account where the Virtual Machine's disks will be placed."
21
+ }
22
+ },
23
+ "adminUsername": {
24
+ "type": "string",
25
+ "metadata": {
26
+ "description": "User name for the Virtual Machine."
27
+ }
28
+ },
29
+ "adminPassword": {
30
+ "type": "securestring",
31
+ "metadata": {
32
+ "description": "Password for the Virtual Machine."
33
+ }
34
+ },
35
+ "dnsNameForPublicIP": {
36
+ "type": "string",
37
+ "metadata": {
38
+ "description": "Unique DNS Name for the Public IP used to access the Virtual Machine."
39
+ }
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 -%>
96
+ "imagePublisher": {
97
+ "type": "string",
98
+ "defaultValue": "Canonical",
99
+ "metadata": {
100
+ "description": "Publisher for the VM, e.g. Canonical, MicrosoftWindowsServer"
101
+ }
102
+ },
103
+ "imageOffer": {
104
+ "type": "string",
105
+ "defaultValue": "UbuntuServer",
106
+ "metadata": {
107
+ "description": "Offer for the VM, e.g. UbuntuServer, WindowsServer."
108
+ }
109
+ },
110
+ "imageSku": {
111
+ "type": "string",
112
+ "defaultValue": "14.04.3-LTS",
113
+ "metadata": {
114
+ "description": "Sku for the VM, e.g. 14.04.3-LTS"
115
+ }
116
+ },
117
+ "imageVersion": {
118
+ "type": "string",
119
+ "defaultValue": "latest",
120
+ "metadata": {
121
+ "description": "Either a date or latest."
122
+ }
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
+ },
132
+ "vmName": {
133
+ "type": "string",
134
+ "defaultValue": "vm",
135
+ "metadata": {
136
+ "description": "The vm name created inside of the resource group."
137
+ }
138
+ },
139
+ "storageAccountType": {
140
+ "type": "string",
141
+ "defaultValue": "Standard_LRS",
142
+ "metadata": {
143
+ "description": "The type of storage to use (e.g. Standard_LRS or Premium_LRS)."
144
+ }
145
+ },
146
+ "bootDiagnosticsEnabled": {
147
+ "type": "string",
148
+ "defaultValue": "true",
149
+ "metadata": {
150
+ "description": "Whether to enable (true) or disable (false) boot diagnostics. Default: true (requires Standard storage)."
151
+ }
152
+ }
153
+ },
154
+ "variables": {
155
+ "location": "[parameters('location')]",
156
+ "OSDiskName": "osdisk",
157
+ "nicName": "nic",
158
+ "addressPrefix": "10.0.0.0/16",
159
+ "subnetName": "<%= subnet_id %>",
160
+ "subnetPrefix": "10.0.0.0/24",
161
+ "storageAccountType": "[parameters('storageAccountType')]",
162
+ "publicIPAddressName": "publicip",
163
+ "publicIPAddressType": "Dynamic",
164
+ "vmStorageAccountContainerName": "vhds",
165
+ "vmName": "[parameters('vmName')]",
166
+ "vmSize": "[parameters('vmSize')]",
167
+ "virtualNetworkName": "vnet",
168
+ "vnetID": "<%= vnet_id %>",
169
+ "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]"
170
+ },
171
+ "resources": [
172
+ {
173
+ "apiVersion": "2017-05-10",
174
+ "name": "pid-18d63047-6cdf-4f34-beed-62f01fc73fc2",
175
+ "type": "Microsoft.Resources/deployments",
176
+ "properties": {
177
+ "mode": "Incremental",
178
+ "template": {
179
+ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
180
+ "contentVersion": "1.0.0.0",
181
+ "resources": []
182
+ }
183
+ }
184
+ },
185
+ <%- unless use_managed_disks -%>
186
+ <%- if existing_storage_account_blob_url.empty? -%>
187
+ {
188
+ "type": "Microsoft.Storage/storageAccounts",
189
+ "name": "[parameters('newStorageAccountName')]",
190
+ "apiVersion": "2015-05-01-preview",
191
+ "location": "[variables('location')]",
192
+ "properties": {
193
+ "accountType": "[variables('storageAccountType')]"
194
+ },
195
+ "tags": {
196
+ }
197
+ },
198
+ <%- end -%>
199
+ <%- end -%>
200
+ <%- if public_ip -%>
201
+ {
202
+ "apiVersion": "2015-05-01-preview",
203
+ "type": "Microsoft.Network/publicIPAddresses",
204
+ "name": "[variables('publicIPAddressName')]",
205
+ "location": "[variables('location')]",
206
+ "properties": {
207
+ "publicIPAllocationMethod": "[variables('publicIPAddressType')]",
208
+ "dnsSettings": {
209
+ "domainNameLabel": "[parameters('dnsNameForPublicIP')]"
210
+ }
211
+ },
212
+ "tags": {
213
+ }
214
+ },
215
+ <%- end -%>
216
+ {
217
+ "apiVersion": "2015-05-01-preview",
218
+ "type": "Microsoft.Network/networkInterfaces",
219
+ "name": "[variables('nicName')]",
220
+ "location": "[variables('location')]",
221
+ <%- if public_ip -%>
222
+ "dependsOn": [
223
+ "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]"
224
+ ],
225
+ <%- end -%>
226
+ "properties": {
227
+ "ipConfigurations": [
228
+ {
229
+ "name": "ipconfig1",
230
+ "properties": {
231
+ "privateIPAllocationMethod": "Dynamic",
232
+ <%- if public_ip -%>
233
+ "publicIPAddress": {
234
+ "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
235
+ },
236
+ <%- end -%>
237
+ "subnet": {
238
+ "id": "[variables('subnetRef')]"
239
+ }
240
+ }
241
+ }
242
+ ]
243
+ },
244
+ "tags": {
245
+ }
246
+ },
247
+ {
248
+ "apiVersion": "2017-03-30",
249
+ "type": "Microsoft.Compute/virtualMachines",
250
+ "name": "[variables('vmName')]",
251
+ "location": "[variables('location')]",
252
+ "dependsOn": [
253
+ <%- unless use_managed_disks -%>
254
+ <%- if existing_storage_account_blob_url.empty? -%>
255
+ "[concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName'))]",
256
+ <%- end -%>
257
+ <%- end -%>
258
+ "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
259
+ ],
260
+ "properties": {
261
+ "hardwareProfile": {
262
+ "vmSize": "[variables('vmSize')]"
263
+ },
264
+ "osProfile": {
265
+ "computername": "[variables('vmName')]",
266
+ <%- unless custom_data.empty? -%>
267
+ "customData": "[parameters('customData')]",
268
+ <%- end -%>
269
+ "adminUsername": "[parameters('adminUsername')]",
270
+ "adminPassword": "[parameters('adminPassword')]"
271
+ },
272
+ "storageProfile": {
273
+ <%- if image_url.empty? and image_id.empty? -%>
274
+ "imageReference": {
275
+ "publisher": "[parameters('imagePublisher')]",
276
+ "offer": "[parameters('imageOffer')]",
277
+ "sku": "[parameters('imageSku')]",
278
+ "version": "[parameters('imageVersion')]"
279
+ },
280
+ <%- elsif !image_id.empty? -%>
281
+ "imageReference": {
282
+ "id": "[parameters('imageId')]"
283
+ },
284
+ <%- end -%>
285
+ <%- if use_managed_disks -%>
286
+ "osDisk": {
287
+ "name": "osdisk",
288
+ <%- unless os_disk_size_gb.to_s.empty? -%>
289
+ "diskSizeGB": "[parameters('osDiskSizeGB')]",
290
+ <%- end -%>
291
+ "createOption": "FromImage"
292
+ }
293
+ <%- else -%>
294
+ "osDisk": {
295
+ "name": "osdisk",
296
+ <%- unless os_disk_size_gb.to_s.empty? -%>
297
+ "diskSizeGB": "[parameters('osDiskSizeGB')]",
298
+ <%- end -%>
299
+ <%- if !image_url.empty? -%>
300
+ "image": {
301
+ "uri": "[parameters('imageUrl')]"
302
+ },
303
+ "osType": "[parameters('osType')]",
304
+ <%- end -%>
305
+ "vhd": {
306
+ <%- if existing_storage_account_blob_url.empty? -%>
307
+ "uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName')), '2015-06-15').primaryEndpoints.blob, variables('vmStorageAccountContainerName'), '/',variables('OSDiskName'),parameters('osDiskNameSuffix'),'.vhd')]"
308
+ <%- else -%>
309
+ <%- if existing_storage_account_container.empty? -%>
310
+ "uri": "[concat(parameters('existingStorageAccountBlobURL'), '/', variables('vmStorageAccountContainerName'), '/', variables('OSDiskName'),parameters('osDiskNameSuffix'),'.vhd')]"
311
+ <%- else -%>
312
+ "uri": "[concat(parameters('existingStorageAccountBlobURL'), '/', parameters('existingStorageAccountBlobContainer'), '/', variables('OSDiskName'),parameters('osDiskNameSuffix'),'.vhd')]"
313
+ <%- end -%>
314
+ <%- end -%>
315
+ },
316
+ "caching": "ReadWrite",
317
+ "createOption": "FromImage"
318
+ }
319
+ <%- end -%>
320
+ <%- unless data_disks_for_vm_json.nil? -%>
321
+ ,"dataDisks":
322
+ <%= data_disks_for_vm_json %>
323
+ <%- end -%>
324
+ },
325
+ "networkProfile": {
326
+ "networkInterfaces": [
327
+ {
328
+ "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
329
+ }
330
+ ]
331
+ },
332
+ "diagnosticsProfile": {
333
+ <%- unless use_managed_disks -%>
334
+ "bootDiagnostics": {
335
+ "enabled": "[parameters('bootDiagnosticsEnabled')]",
336
+ <%- if existing_storage_account_blob_url.empty? -%>
337
+ "storageUri": "[reference(concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName')), '2015-06-15').primaryEndpoints.blob]"
338
+ <%- else -%>
339
+ "storageUri": "[parameters('existingStorageAccountBlobURL')]"
340
+ <%- end -%>
341
+ }
342
+ <%- end -%>
343
+ }
344
+ },
345
+ "tags": {
346
+ <%= vm_tags unless vm_tags.empty? %>
347
+ }
348
+ }
349
+ ]
350
+ }