vagrant-azure 2.0.0.pre7 → 2.0.0.pre8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.rubocop.yml +120 -0
- data/.travis.yml +13 -0
- data/Gemfile +4 -5
- data/README.md +98 -57
- data/docs/basic_linux/Vagrantfile +17 -0
- data/docs/basic_linux/readme.md +12 -0
- data/docs/basic_windows/Vagrantfile +20 -0
- data/docs/basic_windows/readme.md +12 -0
- data/docs/custom_vhd/Vagrantfile +16 -0
- data/docs/custom_vhd/readme.md +48 -0
- data/docs/data_disks/Vagrantfile +16 -0
- data/docs/data_disks/readme.md +20 -0
- data/docs/managed_image/Vagrantfile +15 -0
- data/docs/managed_image/readme.md +66 -0
- data/docs/readme.md +30 -0
- data/lib/vagrant-azure/action/run_instance.rb +95 -69
- data/lib/vagrant-azure/config.rb +75 -4
- data/lib/vagrant-azure/util/machine_id_helper.rb +4 -0
- data/lib/vagrant-azure/util/managed_image_helper.rb +26 -0
- data/lib/vagrant-azure/util/template_renderer.rb +54 -0
- data/lib/vagrant-azure/util/timer.rb +4 -0
- data/lib/vagrant-azure/util/vm_await.rb +4 -0
- data/lib/vagrant-azure/util/vm_status_translator.rb +4 -0
- data/lib/vagrant-azure/version.rb +1 -1
- data/locales/en.yml +6 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/templates/arm/deployment_spec.rb +169 -0
- data/spec/vagrant-azure/config_spec.rb +3 -3
- data/templates/arm/deployment.json.erb +50 -258
- data/templates/arm/resources/availability_set.json.erb +6 -0
- data/templates/arm/resources/data_disk.json.erb +21 -0
- data/templates/arm/resources/import_vhd_image.json.erb +23 -0
- data/templates/arm/resources/linux_reset_root_ext.json.erb +20 -0
- data/templates/arm/resources/network_interface.json.erb +26 -0
- data/templates/arm/resources/network_security_group.json.erb +85 -0
- data/templates/arm/resources/public_ip_address.json.erb +12 -0
- data/templates/arm/resources/storage_account.json.erb +9 -0
- data/templates/arm/resources/virtual_machine.json.erb +82 -0
- data/templates/arm/resources/virtual_network.json.erb +27 -0
- data/templates/arm/resources/windows_reset_access_ext.json.erb +21 -0
- data/vagrant-azure.gemspec +4 -6
- metadata +38 -40
- data/spec/vagrant-azure/services/azure_resource_manager_spec.rb +0 -19
@@ -2,14 +2,14 @@
|
|
2
2
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
3
3
|
# Licensed under the MIT License. See License in the project root for license information.
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
5
|
+
require "spec_helper"
|
6
|
+
require "vagrant-azure/config"
|
7
7
|
|
8
8
|
module VagrantPlugins
|
9
9
|
module Azure
|
10
10
|
describe Config do
|
11
11
|
|
12
|
-
it
|
12
|
+
it "should config" do
|
13
13
|
|
14
14
|
end
|
15
15
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"$schema": "http://schema.management.azure.com/schemas/
|
2
|
+
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
|
3
3
|
"contentVersion": "1.0.0.0",
|
4
4
|
"parameters": {
|
5
5
|
"adminUserName": {
|
@@ -30,6 +30,12 @@
|
|
30
30
|
"description": "Unique DNS Name for the Public IP used to access the Virtual Machine."
|
31
31
|
}
|
32
32
|
},
|
33
|
+
"nsgLabelPrefix": {
|
34
|
+
"type": "string",
|
35
|
+
"metadata": {
|
36
|
+
"description": "Network Security Group Label Prefix for the Virtual Machine."
|
37
|
+
}
|
38
|
+
},
|
33
39
|
"vmSize": {
|
34
40
|
"type": "string",
|
35
41
|
"defaultValue": "Standard_DS2_v2",
|
@@ -43,34 +49,6 @@
|
|
43
49
|
"description": "Name of the VM"
|
44
50
|
}
|
45
51
|
},
|
46
|
-
"imagePublisher": {
|
47
|
-
"type": "string",
|
48
|
-
"defaultValue": "canonical",
|
49
|
-
"metadata": {
|
50
|
-
"description": "Name of the image publisher"
|
51
|
-
}
|
52
|
-
},
|
53
|
-
"imageOffer": {
|
54
|
-
"type": "string",
|
55
|
-
"defaultValue": "ubuntuserver",
|
56
|
-
"metadata": {
|
57
|
-
"description": "Name of the image offer"
|
58
|
-
}
|
59
|
-
},
|
60
|
-
"imageSku": {
|
61
|
-
"type": "string",
|
62
|
-
"defaultValue": "16.04-LTS",
|
63
|
-
"metadata": {
|
64
|
-
"description": "Name of the image sku"
|
65
|
-
}
|
66
|
-
},
|
67
|
-
"imageVersion": {
|
68
|
-
"type": "string",
|
69
|
-
"defaultValue": "latest",
|
70
|
-
"metadata": {
|
71
|
-
"description": "Name of the image sku"
|
72
|
-
}
|
73
|
-
},
|
74
52
|
"subnetName": {
|
75
53
|
"type": "string",
|
76
54
|
"defaultValue": "vagrant-subnet",
|
@@ -91,21 +69,25 @@
|
|
91
69
|
"metadata": {
|
92
70
|
"description": "WinRM port"
|
93
71
|
}
|
72
|
+
},
|
73
|
+
"storageAccountType": {
|
74
|
+
"type": "string",
|
75
|
+
"defaultValue": "Premium_LRS",
|
76
|
+
"metadata": {
|
77
|
+
"description": "Storage account type for VM Disks"
|
78
|
+
}
|
94
79
|
}
|
95
80
|
},
|
96
81
|
"variables": {
|
97
|
-
"storageAccountName": "[concat(uniquestring(resourceGroup().id), 'vagrant')]",
|
98
82
|
"location": "[resourceGroup().location]",
|
99
|
-
"
|
100
|
-
"
|
101
|
-
"subnetPrefix": "10.0.0.0/24",
|
102
|
-
"vmStorageAccountContainerName": "vagrant-vhds",
|
83
|
+
"managedImageName": "[concat(parameters('vmName'), '-vagrantanagedImage')]",
|
84
|
+
"sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]",
|
103
85
|
"nicName": "[concat(parameters('vmName'), '-vagrantNIC')]",
|
104
86
|
"publicIPAddressName": "[concat(parameters('vmName'), '-vagrantPublicIP')]",
|
105
87
|
"publicIPAddressType": "Dynamic",
|
106
|
-
"
|
107
|
-
"
|
108
|
-
"
|
88
|
+
"networkSecurityGroupName": "[concat(parameters('nsgLabelPrefix'), '-vagrantNSG')]",
|
89
|
+
"addressPrefix": "10.0.0.0/16",
|
90
|
+
"subnetPrefix": "10.0.0.0/24",
|
109
91
|
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
|
110
92
|
"subnetRef": "[concat(variables('vnetID'),'/subnets/',parameters('subnetName'))]",
|
111
93
|
"apiVersion": "2015-06-15",
|
@@ -113,227 +95,37 @@
|
|
113
95
|
"doubleQuote": "\""
|
114
96
|
},
|
115
97
|
"resources": [
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
}
|
124
|
-
},
|
125
|
-
{
|
126
|
-
"apiVersion": "[variables('apiVersion')]",
|
127
|
-
"type": "Microsoft.Network/networkSecurityGroups",
|
128
|
-
"name": "[variables('networkSecurityGroupName')]",
|
129
|
-
"location": "[variables('location')]",
|
130
|
-
"properties": {
|
131
|
-
"securityRules": [
|
132
|
-
<% if operating_system == 'Windows' %>
|
133
|
-
{
|
134
|
-
"name": "rdp_rule",
|
135
|
-
"properties": {
|
136
|
-
"description": "Enable Inbound RDP",
|
137
|
-
"protocol": "Tcp",
|
138
|
-
"sourcePortRange": "*",
|
139
|
-
"destinationPortRange": "3389",
|
140
|
-
"sourceAddressPrefix": "*",
|
141
|
-
"destinationAddressPrefix": "*",
|
142
|
-
"access": "Allow",
|
143
|
-
"priority": 123,
|
144
|
-
"direction": "Inbound"
|
145
|
-
}
|
146
|
-
},
|
147
|
-
{
|
148
|
-
"name": "winrm_rule",
|
149
|
-
"properties": {
|
150
|
-
"description": "Enable Inbound WinRM",
|
151
|
-
"protocol": "Tcp",
|
152
|
-
"sourcePortRange": "*",
|
153
|
-
"destinationPortRange": "[parameters('winRmPort')]",
|
154
|
-
"sourceAddressPrefix": "*",
|
155
|
-
"destinationAddressPrefix": "*",
|
156
|
-
"access": "Allow",
|
157
|
-
"priority": 124,
|
158
|
-
"direction": "Inbound"
|
159
|
-
}
|
160
|
-
}
|
161
|
-
<% else %>
|
162
|
-
{
|
163
|
-
"name": "ssh_rule",
|
164
|
-
"properties": {
|
165
|
-
"description": "Locks inbound down to ssh default port 22.",
|
166
|
-
"protocol": "Tcp",
|
167
|
-
"sourcePortRange": "*",
|
168
|
-
"destinationPortRange": "22",
|
169
|
-
"sourceAddressPrefix": "*",
|
170
|
-
"destinationAddressPrefix": "*",
|
171
|
-
"access": "Allow",
|
172
|
-
"priority": 123,
|
173
|
-
"direction": "Inbound"
|
174
|
-
}
|
175
|
-
}
|
176
|
-
<% end %>
|
177
|
-
<% endpoints.each_with_index do |ports, index| %>
|
178
|
-
,
|
179
|
-
{
|
180
|
-
"name": "custom_rule_<%= index %>",
|
181
|
-
"properties": {
|
182
|
-
"description": "Custom opened ports.",
|
183
|
-
"protocol": "Tcp",
|
184
|
-
"sourcePortRange": "*",
|
185
|
-
"destinationPortRange": "<%= ports %>",
|
186
|
-
"sourceAddressPrefix": "*",
|
187
|
-
"destinationAddressPrefix": "*",
|
188
|
-
"access": "Allow",
|
189
|
-
"priority": <%= 133 + index %>,
|
190
|
-
"direction": "Inbound"
|
191
|
-
}
|
192
|
-
}
|
193
|
-
<% end %>
|
194
|
-
]
|
195
|
-
}
|
196
|
-
},
|
197
|
-
{
|
198
|
-
"apiVersion": "[variables('apiVersion')]",
|
199
|
-
"type": "Microsoft.Network/publicIPAddresses",
|
200
|
-
"name": "[variables('publicIPAddressName')]",
|
201
|
-
"location": "[variables('location')]",
|
202
|
-
"properties": {
|
203
|
-
"publicIPAllocationMethod": "[variables('publicIPAddressType')]",
|
204
|
-
"dnsSettings": {
|
205
|
-
"domainNameLabel": "[parameters('dnsLabelPrefix')]"
|
206
|
-
}
|
207
|
-
}
|
208
|
-
},
|
209
|
-
{
|
210
|
-
"apiVersion": "[variables('apiVersion')]",
|
211
|
-
"type": "Microsoft.Network/virtualNetworks",
|
212
|
-
"name": "[parameters('virtualNetworkName')]",
|
213
|
-
"location": "[variables('location')]",
|
214
|
-
"dependsOn": [
|
215
|
-
"[concat('Microsoft.Network/networkSecurityGroups/', variables('networkSecurityGroupName'))]"
|
216
|
-
],
|
217
|
-
"properties": {
|
218
|
-
"addressSpace": {
|
219
|
-
"addressPrefixes": [
|
220
|
-
"[variables('addressPrefix')]"
|
221
|
-
]
|
222
|
-
},
|
223
|
-
"subnets": [
|
224
|
-
{
|
225
|
-
"name": "[parameters('subnetName')]",
|
226
|
-
"properties": {
|
227
|
-
"addressPrefix": "[variables('subnetPrefix')]",
|
228
|
-
"networkSecurityGroup": {
|
229
|
-
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"
|
230
|
-
}
|
231
|
-
}
|
232
|
-
}
|
233
|
-
]
|
234
|
-
}
|
235
|
-
},
|
236
|
-
{
|
237
|
-
"apiVersion": "[variables('apiVersion')]",
|
238
|
-
"type": "Microsoft.Network/networkInterfaces",
|
239
|
-
"name": "[variables('nicName')]",
|
240
|
-
"location": "[variables('location')]",
|
241
|
-
"dependsOn": [
|
242
|
-
"[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]",
|
243
|
-
"[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]"
|
244
|
-
],
|
245
|
-
"properties": {
|
246
|
-
"ipConfigurations": [
|
247
|
-
{
|
248
|
-
"name": "ipconfig1",
|
249
|
-
"properties": {
|
250
|
-
"privateIPAllocationMethod": "Dynamic",
|
251
|
-
"publicIPAddress": {
|
252
|
-
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
|
253
|
-
},
|
254
|
-
"subnet": {
|
255
|
-
"id": "[variables('subnetRef')]"
|
256
|
-
}
|
257
|
-
}
|
258
|
-
}
|
259
|
-
]
|
260
|
-
}
|
261
|
-
},
|
262
|
-
<% if availabilitySetName = availability_set_name.nil? || availability_set_name.empty? ? nil : availability_set_name %>
|
263
|
-
{
|
264
|
-
"apiVersion": "[variables('apiVersion')]",
|
265
|
-
"type": "Microsoft.Compute/availabilitySets",
|
266
|
-
"name": "<%= availabilitySetName %>",
|
267
|
-
"location": "[variables('location')]"
|
268
|
-
},
|
98
|
+
<% if vhd_uri %>
|
99
|
+
<%= VagrantPlugins::Azure::Util::TemplateRenderer.render("arm/resources/import_vhd_image.json", {
|
100
|
+
name: "[variables('managedImageName')]",
|
101
|
+
account_type: "[parameters('storageAccountType')]",
|
102
|
+
os_type: "#{operating_system}",
|
103
|
+
source_uri: "#{vhd_uri}"
|
104
|
+
}) + "," %>
|
269
105
|
<% end %>
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
"
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
<% else %>
|
295
|
-
"linuxConfiguration": {
|
296
|
-
"disablePasswordAuthentication": "true",
|
297
|
-
"ssh": {
|
298
|
-
"publicKeys": [
|
299
|
-
{
|
300
|
-
"path": "[variables('sshKeyPath')]",
|
301
|
-
"keyData": "[parameters('sshKeyData')]"
|
302
|
-
}
|
303
|
-
]
|
304
|
-
}
|
305
|
-
}
|
306
|
-
<% end %>
|
307
|
-
},
|
308
|
-
"storageProfile": {
|
309
|
-
"imageReference": {
|
310
|
-
"publisher": "[parameters('imagePublisher')]",
|
311
|
-
"offer": "[parameters('imageOffer')]",
|
312
|
-
"sku": "[parameters('imageSku')]",
|
313
|
-
"version": "latest"
|
314
|
-
},
|
315
|
-
"osDisk": {
|
316
|
-
"name": "osdisk",
|
317
|
-
"vhd": {
|
318
|
-
"uri": "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/', variables('osDiskName'),'.vhd')]"
|
319
|
-
},
|
320
|
-
"caching": "ReadWrite",
|
321
|
-
"createOption": "FromImage"
|
322
|
-
}
|
323
|
-
},
|
324
|
-
"networkProfile": {
|
325
|
-
"networkInterfaces": [
|
326
|
-
{
|
327
|
-
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
|
328
|
-
}
|
329
|
-
]
|
330
|
-
}
|
331
|
-
<% if availabilitySetName %>,
|
332
|
-
"availabilitySet": {
|
333
|
-
"id": "[resourceId('Microsoft.Compute/availabilitySets', '<%= availabilitySetName %>')]"
|
334
|
-
}
|
335
|
-
<% end %>
|
336
|
-
}
|
337
|
-
}
|
106
|
+
<%= VagrantPlugins::Azure::Util::TemplateRenderer.render("arm/resources/network_security_group.json", self) + "," %>
|
107
|
+
<%= VagrantPlugins::Azure::Util::TemplateRenderer.render("arm/resources/public_ip_address.json", self) + "," %>
|
108
|
+
<%= VagrantPlugins::Azure::Util::TemplateRenderer.render("arm/resources/virtual_network.json", self) + "," %>
|
109
|
+
<%= VagrantPlugins::Azure::Util::TemplateRenderer.render("arm/resources/network_interface.json", self) + "," %>
|
110
|
+
<% if availability_set_name %>
|
111
|
+
<%= VagrantPlugins::Azure::Util::TemplateRenderer.render("arm/resources/availability_set.json", availability_set_name: availability_set_name) + "," %>
|
112
|
+
<% end %>
|
113
|
+
|
114
|
+
<%
|
115
|
+
vm_dependencies = ["[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"]
|
116
|
+
if availability_set_name
|
117
|
+
vm_dependencies.push("[resourceId('Microsoft.Compute/availabilitySets', '#{availability_set_name}')")
|
118
|
+
end
|
119
|
+
|
120
|
+
if vhd_uri
|
121
|
+
vm_dependencies.push("[resourceId('Microsoft.Compute/images', variables('managedImageName'))]")
|
122
|
+
end
|
123
|
+
%>
|
124
|
+
<%= VagrantPlugins::Azure::Util::TemplateRenderer.render("arm/resources/virtual_machine.json",
|
125
|
+
{
|
126
|
+
depends_on: vm_dependencies,
|
127
|
+
storage_account_type: "[parameters('storageAccountType')]"
|
128
|
+
}.merge(self.to_h))
|
129
|
+
%>
|
338
130
|
]
|
339
131
|
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"name": "<%= name %>",
|
3
|
+
"diskSizeGB": "<%= size_gb %>",
|
4
|
+
"lun": <%= lun %>,
|
5
|
+
<% if vhd_uri %>
|
6
|
+
"vhd": {
|
7
|
+
"uri": "<%= vhd_uri %>"
|
8
|
+
},
|
9
|
+
"createOption": "attach"
|
10
|
+
<% end %>
|
11
|
+
<% if image_uri %>
|
12
|
+
"image": {
|
13
|
+
// specifies the location of the data disk vhd when creating the vm from user image
|
14
|
+
"uri": "<%= image_uri %>"
|
15
|
+
},
|
16
|
+
"createOption": "fromImage"
|
17
|
+
<% end %>
|
18
|
+
<% if !vhd_uri && !image_uri %>
|
19
|
+
"createOption": "empty"
|
20
|
+
<% end %>
|
21
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
{
|
2
|
+
"type": "Microsoft.Compute/images",
|
3
|
+
"name": "<%= name %>",
|
4
|
+
"apiVersion": "2016-04-30-preview",
|
5
|
+
"location": "[variables('location')]",
|
6
|
+
"tags": {},
|
7
|
+
"properties": {
|
8
|
+
"storageProfile": {
|
9
|
+
"osDisk": {
|
10
|
+
"osType": "<%= os_type %>",
|
11
|
+
"blobUri": "<%= source_uri %>",
|
12
|
+
"caching": "ReadWrite",
|
13
|
+
"storageAccountType": "<%= account_type %>"
|
14
|
+
},
|
15
|
+
"dataDisks": [
|
16
|
+
<%= (data_disks || []).map{ |resource| "\"#{resource}\"" }.join(", ") %>
|
17
|
+
]
|
18
|
+
}
|
19
|
+
},
|
20
|
+
"dependsOn": [
|
21
|
+
<%= (depends_on || []).map{ |resource| "\"#{resource}\"" }.join(", ") %>
|
22
|
+
]
|
23
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"type": "Microsoft.Compute/virtualMachines/extensions",
|
3
|
+
"name": "<%= name %>",
|
4
|
+
"apiVersion": "2015-06-15",
|
5
|
+
"location": "[resourceGroup().location]",
|
6
|
+
"dependsOn": [
|
7
|
+
<%= (depends_on || []).map{ |resource| "\"#{resource}\"" }.join(", ") %>
|
8
|
+
],
|
9
|
+
"properties": {
|
10
|
+
"publisher": "Microsoft.OSTCExtensions",
|
11
|
+
"type": "VMAccessForLinux",
|
12
|
+
"typeHandlerVersion": "1.4",
|
13
|
+
"autoUpgradeMinorVersion": true,
|
14
|
+
"protectedSettings": {
|
15
|
+
"ssh_key": "<%= ssh_key %>",
|
16
|
+
"username": "<%= username %>",
|
17
|
+
"reset_ssh": "True"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"apiVersion": "2016-03-30",
|
3
|
+
"type": "Microsoft.Network/networkInterfaces",
|
4
|
+
"name": "[variables('nicName')]",
|
5
|
+
"location": "[variables('location')]",
|
6
|
+
"dependsOn": [
|
7
|
+
"[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]",
|
8
|
+
"[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]"
|
9
|
+
],
|
10
|
+
"properties": {
|
11
|
+
"ipConfigurations": [
|
12
|
+
{
|
13
|
+
"name": "ipconfig1",
|
14
|
+
"properties": {
|
15
|
+
"privateIPAllocationMethod": "Dynamic",
|
16
|
+
"publicIPAddress": {
|
17
|
+
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
|
18
|
+
},
|
19
|
+
"subnet": {
|
20
|
+
"id": "[variables('subnetRef')]"
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
]
|
25
|
+
}
|
26
|
+
}
|