1 |
{ |
2 |
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", |
3 |
"contentVersion": "1.0.0.0", |
4 |
"parameters": { |
5 |
"admin-username": { |
6 |
"type": "string" |
7 |
}, |
8 |
"ssh-public-key": { |
9 |
"type": "string" |
10 |
} |
11 |
}, |
12 |
"variables": { |
13 |
"ssh-keypath": "[concat('/home/', parameters('admin-username'), '/.ssh/authorized_keys')]", |
14 |
"unique-prefix": "[concat(replace(resourceGroup().name,'-',''), substring(uniquestring(resourceGroup().name), 0, 5))]", |
15 |
"storage-name": "[variables('unique-prefix')]", |
16 |
"vnet-name": "[concat(resourceGroup().name, '-vnet')]", |
17 |
"ip-prefix": "[concat(resourceGroup().name, '-ip-')]", |
18 |
"nsg-prefix": "[concat(resourceGroup().name, '-nsg-')]", |
19 |
"vm-prefix": "[concat(resourceGroup().name, '-vm-')]", |
20 |
"nic-prefix": "[concat(resourceGroup().name, '-nic-')]", |
21 |
"names": [ "alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta", "theta", "iota", "kappa", "lambda", "mu", "nu", "xi", "omicron", "pi", "rho", "sigma", "tau", "upsilon", "phi", "chi", "psi", "omega" ], |
22 |
"vm-size": "Standard_DS1_v2", |
23 |
"vnet-address-space": "10.16.0.0/12", |
24 |
"vnet-subnet01-octet": 17, |
25 |
"vm-count": 2 |
26 |
}, |
27 |
"resources": [ |
28 |
{ |
29 |
"comments": "", |
30 |
"type": "Microsoft.Network/publicIPAddresses", |
31 |
"name": "[concat(variables('ip-prefix'), variables('names')[copyindex()])]", |
32 |
"copy": { |
33 |
"name": "vm-count", |
34 |
"count": "[variables('vm-count')]" |
35 |
}, |
36 |
"apiVersion": "2017-03-01", |
37 |
"location": "[resourceGroup().location]", |
38 |
"properties": { |
39 |
"publicIPAllocationMethod": "Dynamic", |
40 |
"idleTimeoutInMinutes": 4, |
41 |
"dnsSettings": { |
42 |
"domainNameLabel": "[concat(variables('unique-prefix'), '-', variables('names')[copyindex()])]" |
43 |
} |
44 |
}, |
45 |
"resources": [], |
46 |
"dependsOn": [] |
47 |
}, |
48 |
{ |
49 |
"comments": "public machine", |
50 |
"type": "Microsoft.Compute/virtualMachines", |
51 |
"name": "[concat(variables('vm-prefix'), variables('names')[copyindex()])]", |
52 |
"copy": { |
53 |
"name": "vm-count", |
54 |
"count": "[variables('vm-count')]" |
55 |
}, |
56 |
"apiVersion": "2016-04-30-preview", |
57 |
"location": "[resourceGroup().location]", |
58 |
"properties": { |
59 |
"hardwareProfile": { |
60 |
"vmSize": "[variables('vm-size')]" |
61 |
}, |
62 |
"storageProfile": { |
63 |
"imageReference": { |
64 |
"publisher": "OpenLogic", |
65 |
"offer": "CentOS", |
66 |
"sku": "7.2", |
67 |
"version": "latest" |
68 |
}, |
69 |
"osDisk": { |
70 |
"name": "[concat(variables('vm-prefix'), variables('names')[copyindex()], '-boot')]", |
71 |
"createOption": "FromImage", |
72 |
"vhd": { |
73 |
"uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storage-name')), '2015-06-15').primaryEndpoints.blob, 'vhds/', variables('names')[copyindex()], '-boot.vhd')]" |
74 |
}, |
75 |
"caching": "ReadWrite" |
76 |
} |
77 |
}, |
78 |
"osProfile": { |
79 |
"computerName": "[concat(variables('vm-prefix'), variables('names')[copyindex()])]", |
80 |
"adminUsername": "[parameters('admin-username')]", |
81 |
"linuxConfiguration": { |
82 |
"disablePasswordAuthentication": true, |
83 |
"ssh": { |
84 |
"publicKeys": [ |
85 |
{ |
86 |
"path": "[variables('ssh-keypath')]", |
87 |
"keyData": "[parameters('ssh-public-key')]" |
88 |
} |
89 |
] |
90 |
} |
91 |
} |
92 |
}, |
93 |
"networkProfile": { |
94 |
"networkInterfaces": [ |
95 |
{ |
96 |
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat('nic-', variables('names')[copyindex()]))]" |
97 |
} |
98 |
] |
99 |
} |
100 |
}, |
101 |
"resources": [], |
102 |
"dependsOn": [ |
103 |
"[resourceId('Microsoft.Storage/storageAccounts', variables('storage-name'))]", |
104 |
"[resourceId('Microsoft.Network/networkInterfaces', concat('nic-', variables('names')[copyindex()]))]" |
105 |
] |
106 |
}, |
107 |
{ |
108 |
"type": "Microsoft.Compute/virtualMachines/extensions", |
109 |
"name": "[concat(variables('vm-prefix'), variables('names')[copyindex()], '/script')]", |
110 |
"copy": { |
111 |
"name": "vm-count", |
112 |
"count": "[variables('vm-count')]" |
113 |
}, |
114 |
"apiVersion": "2015-05-01-preview", |
115 |
"location": "[resourceGroup().location]", |
116 |
"dependsOn": [ |
117 |
"[concat(variables('vm-prefix'), variables('names')[copyindex()])]" |
118 |
], |
119 |
"properties": { |
120 |
"publisher": "Microsoft.Azure.Extensions", |
121 |
"type": "CustomScript", |
122 |
"typeHandlerVersion": "2.0", |
123 |
"autoUpgradeMinorVersion": true, |
124 |
"settings": { |
125 |
"fileUris": [ |
126 |
"[concat('https://linux.azure.david.betz.space/raw/samba/', variables('names')[copyindex()], '-install.sh')]" |
127 |
], |
128 |
"commandToExecute": "[concat('sh ', variables('names')[copyindex()], '-install.sh')]" |
129 |
} |
130 |
} |
131 |
}, |
132 |
{ |
133 |
"comments": "public ip", |
134 |
"type": "Microsoft.Network/networkInterfaces", |
135 |
"name": "[concat('nic-', variables('names')[copyindex()])]", |
136 |
"copy": { |
137 |
"name": "vm-count", |
138 |
"count": "[variables('vm-count')]" |
139 |
}, |
140 |
"apiVersion": "2017-03-01", |
141 |
"location": "[resourceGroup().location]", |
142 |
"properties": { |
143 |
"ipConfigurations": [ |
144 |
{ |
145 |
"name": "ifconfig1", |
146 |
"properties": { |
147 |
"privateIPAddress": "[concat('10.', variables('vnet-subnet01-octet'), '.0.', copyindex(4))]", |
148 |
"privateIPAllocationMethod": "Static", |
149 |
"publicIPAddress": { |
150 |
"id": "[resourceId('Microsoft.Network/publicIPAddresses', concat(variables('ip-prefix'), variables('names')[copyindex()]))]" |
151 |
}, |
152 |
"subnet": { |
153 |
"id": "[concat(resourceId('Microsoft.Network/virtualNetworks', variables('vnet-name')), '/subnets/subnet01')]" |
154 |
} |
155 |
} |
156 |
} |
157 |
], |
158 |
"dnsSettings": { |
159 |
"dnsServers": [] |
160 |
}, |
161 |
"enableIPForwarding": false, |
162 |
"networkSecurityGroup": { |
163 |
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', concat(variables('nsg-prefix'), variables('names')[copyindex()]))]" |
164 |
} |
165 |
}, |
166 |
"resources": [], |
167 |
"dependsOn": [ |
168 |
"[resourceId('Microsoft.Network/publicIPAddresses', concat(variables('ip-prefix'), variables('names')[copyindex()]))]", |
169 |
"[resourceId('Microsoft.Network/virtualNetworks', variables('vnet-name'))]", |
170 |
"[resourceId('Microsoft.Network/networkSecurityGroups', concat(variables('nsg-prefix'), variables('names')[copyindex()]))]" |
171 |
] |
172 |
}, |
173 |
{ |
174 |
"comments": "", |
175 |
"type": "Microsoft.Network/virtualNetworks", |
176 |
"name": "[variables('vnet-name')]", |
177 |
"apiVersion": "2017-03-01", |
178 |
"location": "[resourceGroup().location]", |
179 |
"properties": { |
180 |
"addressSpace": { |
181 |
"addressPrefixes": [ |
182 |
"[variables('vnet-address-space')]" |
183 |
] |
184 |
}, |
185 |
"subnets": [ |
186 |
{ |
187 |
"name": "subnet01", |
188 |
"properties": { |
189 |
"addressPrefix": "[concat('10.', variables('vnet-subnet01-octet'), '.0.0/16')]" |
190 |
} |
191 |
} |
192 |
] |
193 |
}, |
194 |
"resources": [], |
195 |
"dependsOn": [] |
196 |
}, |
197 |
{ |
198 |
"comments": "", |
199 |
"type": "Microsoft.Network/networkSecurityGroups", |
200 |
"name": "[concat(variables('nsg-prefix'), variables('names')[1])]", |
201 |
"apiVersion": "2017-03-01", |
202 |
"location": "[resourceGroup().location]", |
203 |
"properties": { |
204 |
"securityRules": [ |
205 |
{ |
206 |
"name": "default-allow-ssh", |
207 |
"properties": { |
208 |
"protocol": "Tcp", |
209 |
"sourcePortRange": "*", |
210 |
"destinationPortRange": "22", |
211 |
"sourceAddressPrefix": "*", |
212 |
"destinationAddressPrefix": "*", |
213 |
"access": "Allow", |
214 |
"priority": 1000, |
215 |
"direction": "Inbound" |
216 |
} |
217 |
}, |
218 |
{ |
219 |
"name": "netbios-udp", |
220 |
"properties": { |
221 |
"protocol": "Udp", |
222 |
"sourcePortRange": "*", |
223 |
"destinationPortRange": "137-138", |
224 |
"sourceAddressPrefix": "*", |
225 |
"destinationAddressPrefix": "*", |
226 |
"access": "Allow", |
227 |
"priority": 1100, |
228 |
"direction": "Inbound" |
229 |
} |
230 |
}, |
231 |
{ |
232 |
"name": "netbios-tcp-1", |
233 |
"properties": { |
234 |
"protocol": "Tcp", |
235 |
"sourcePortRange": "*", |
236 |
"destinationPortRange": "139", |
237 |
"sourceAddressPrefix": "*", |
238 |
"destinationAddressPrefix": "*", |
239 |
"access": "Allow", |
240 |
"priority": 1200, |
241 |
"direction": "Inbound" |
242 |
} |
243 |
}, |
244 |
{ |
245 |
"name": "netbios-tcp-2", |
246 |
"properties": { |
247 |
"protocol": "Tcp", |
248 |
"sourcePortRange": "*", |
249 |
"destinationPortRange": "445", |
250 |
"sourceAddressPrefix": "*", |
251 |
"destinationAddressPrefix": "*", |
252 |
"access": "Allow", |
253 |
"priority": 1300, |
254 |
"direction": "Inbound" |
255 |
} |
256 |
} |
257 |
] |
258 |
}, |
259 |
"resources": [], |
260 |
"dependsOn": [] |
261 |
}, |
262 |
{ |
263 |
"comments": "", |
264 |
"type": "Microsoft.Network/networkSecurityGroups", |
265 |
"name": "[concat(variables('nsg-prefix'), variables('names')[0])]", |
266 |
"apiVersion": "2017-03-01", |
267 |
"location": "[resourceGroup().location]", |
268 |
"properties": { |
269 |
"securityRules": [ |
270 |
{ |
271 |
"name": "default-allow-ssh", |
272 |
"properties": { |
273 |
"protocol": "Tcp", |
274 |
"sourcePortRange": "*", |
275 |
"destinationPortRange": "22", |
276 |
"sourceAddressPrefix": "*", |
277 |
"destinationAddressPrefix": "*", |
278 |
"access": "Allow", |
279 |
"priority": 1000, |
280 |
"direction": "Inbound" |
281 |
} |
282 |
}, |
283 |
{ |
284 |
"name": "netbios-udp", |
285 |
"properties": { |
286 |
"protocol": "Udp", |
287 |
"sourcePortRange": "*", |
288 |
"destinationPortRange": "137-138", |
289 |
"sourceAddressPrefix": "*", |
290 |
"destinationAddressPrefix": "*", |
291 |
"access": "Allow", |
292 |
"priority": 1100, |
293 |
"direction": "Inbound" |
294 |
} |
295 |
} |
296 |
] |
297 |
}, |
298 |
"resources": [], |
299 |
"dependsOn": [] |
300 |
}, |
301 |
{ |
302 |
"comments": "", |
303 |
"type": "Microsoft.Storage/storageAccounts", |
304 |
"sku": { |
305 |
"name": "Standard_LRS", |
306 |
"tier": "Standard" |
307 |
}, |
308 |
"kind": "Storage", |
309 |
"name": "[variables('storage-name')]", |
310 |
"apiVersion": "2016-01-01", |
311 |
"location": "[resourceGroup().location]", |
312 |
"tags": {}, |
313 |
"properties": { }, |
314 |
"resources": [], |
315 |
"dependsOn": [] |
316 |
} |
317 |
], |
318 |
"outputs": { |
319 |
"sshCommand": { |
320 |
"type": "string", |
321 |
"value": "[concat('ssh ', variables('unique-prefix'), '-', variables('names')[0], '.', resourceGroup().location, '.cloudapp.azure.com')]" |
322 |
} |
323 |
} |
324 |
} |
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|