Skip to content

Commit 3091f8d

Browse files
committed
created conditional template for network
1 parent 7d42855 commit 3091f8d

File tree

3 files changed

+174
-6
lines changed

3 files changed

+174
-6
lines changed

nestedtemplates/empty-resources.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
{
3+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
4+
"contentVersion": "1.0.0.0",
5+
"parameters": {
6+
"vnetName": {
7+
"type": "String",
8+
"defaultValue": ""
9+
},
10+
"zookeeperNetName": {
11+
"type": "String",
12+
"defaultValue": ""
13+
},
14+
"postgresNetName": {
15+
"type": "String",
16+
"defaultValue": ""
17+
},
18+
"clusterName": {
19+
"type": "String",
20+
"defaultValue": ""
21+
}
22+
},
23+
"variables": {},
24+
"resources": [],
25+
"outputs": {}
26+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"vnetName": {
6+
"type": "String",
7+
"defaultValue": ""
8+
},
9+
"zookeeperNetName": {
10+
"type": "String",
11+
"defaultValue": ""
12+
},
13+
"postgresNetName": {
14+
"type": "String",
15+
"defaultValue": ""
16+
},
17+
"clusterName": {
18+
"type": "String",
19+
"defaultValue": ""
20+
}
21+
},
22+
"variables": {
23+
"vnetName": "[concat(parameters('clusterName'), '-net')]"
24+
},
25+
"resources": [
26+
{
27+
"type": "Microsoft.Network/virtualNetworks",
28+
"name": "[variables('vnetName')]",
29+
"apiVersion": "2015-06-15",
30+
"location": "[resourceGroup().location]",
31+
"tags": {},
32+
"properties": {
33+
"addressSpace": {
34+
"addressPrefixes": [
35+
"10.0.0.0/16"
36+
]
37+
},
38+
"subnets": [
39+
{
40+
"name": "[parameters('zookeeperNetName')]",
41+
"properties": {
42+
"addressPrefix": "10.0.100.0/24"
43+
}
44+
},
45+
{
46+
"name": "[parameters('postgresNetName')]",
47+
"properties": {
48+
"addressPrefix": "10.0.101.0/24"
49+
}
50+
}
51+
]
52+
},
53+
"dependsOn": []
54+
}
55+
]
56+
}

template.json

Lines changed: 92 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,63 @@
55
"clusterName": {
66
"type": "String"
77
},
8+
"_artifactsLocation": {
9+
"type": "string",
10+
"defaultValue": "https://raw.githubusercontent.com/HelloTech/azure_patroni/master",
11+
"metadata": {
12+
"description": "Change this value to your repo name if deploying from a fork"
13+
}
14+
},
15+
"vnetGroup": {
16+
"defaultValue": "",
17+
"type": "String",
18+
"metadata": {
19+
"description": "VNET Resource Group."
20+
}
21+
},
22+
"newVnet": {
23+
"type": "string",
24+
"defaultValue": "yes",
25+
"allowedValues": [
26+
"yes",
27+
"no"
28+
],
29+
"metadata": {
30+
"description": "Would you like to create a new vnet?"
31+
}
32+
},
33+
"lbType": {
34+
"type": "string",
35+
"defaultValue": "yes",
36+
"allowedValues": [
37+
"yes",
38+
"no"
39+
],
40+
"metadata": {
41+
"description": "Would you like to create an internal or external load balancer?"
42+
}
43+
},
44+
"vnetName": {
45+
"defaultValue": "",
46+
"type": "String",
47+
"metadata": {
48+
"description": "Name of the vnet you would like to create, or that you would like to deploy this into."
49+
}
50+
},
51+
"zookeeperNetName": {
52+
"defaultValue": "dcos-agentPublicSubnet",
53+
"type": "String",
54+
"metadata": {
55+
"description": "Name you would like to give to zookeeper's subnet."
56+
}
57+
},
58+
"postgresNetName": {
59+
"defaultValue": "dcos-agentPublicSubnet",
60+
"type": "String",
61+
"metadata": {
62+
"description": "Name you would like to give to postgres' subnet."
63+
}
64+
},
865
"instanceCount": {
966
"defaultValue": 2,
1067
"minValue": 2,
@@ -30,15 +87,18 @@
3087
"s",
3188
"y"
3289
],
90+
"nestedTemplates": "[concat(parameters('_artifactsLocation'), '/nestedtemplates/']",
3391
"storageAccountType": "Standard_LRS",
3492
"lbName": "postgresLoadBalancer",
93+
"vnetFile": {
94+
"yes": "network-resources.json",
95+
"no": "empty-resources.json"
96+
},
3597
"lbId": "[resourceId('Microsoft.Network/loadBalancers/', variables('lbName'))]",
3698
"vnetName": "dcos-vnet-F0547AD4",
3799
"vnetGroup": "testht",
38-
"vnetId": "[resourceId(variables('vnetGroup'), 'Microsoft.Network/virtualNetworks', variables('vnetName'))]",
39-
"zookeeperNetName": "dcos-agentPublicSubnet",
100+
"vnetId": "[resourceId(parameters('vnetGroup'), 'Microsoft.Network/virtualNetworks', parameters('vnetName'))]",
40101
"zookeeperInstanceCount": 3,
41-
"postgresNetName": "dcos-agentPublicSubnet",
42102
"postgresInstanceCount": "[parameters('instanceCount')]",
43103
"osType": {
44104
"publisher": "Canonical",
@@ -48,6 +108,32 @@
48108
}
49109
},
50110
"resources": [
111+
{
112+
"type": "Microsoft.Network/virtualNetworks",
113+
"name": "[variables('vnetName')]",
114+
"apiVersion": "2015-06-15",
115+
"properties": {
116+
"mode": "Incremental",
117+
"templateLink": {
118+
"uri": "[concat(variables('sharedTemplateFileName'), variables('vnetFile')[parameters('newVnet')])]",
119+
"contentVersion": "1.0.0.0"
120+
},
121+
"parameters": {
122+
"vnetName": {
123+
"value": "[variables('vnetName')]"
124+
},
125+
"zookeeperNetName": {
126+
"value": "[parameters('zookeeperNetName')]"
127+
},
128+
"postgresNetName": {
129+
"value": "[parameters('postgresNetName')]"
130+
},
131+
"clusterName": {
132+
"value": "[variables('clusterName')]"
133+
}
134+
}
135+
}
136+
},
51137
{
52138
"type": "Microsoft.Storage/storageAccounts",
53139
"name": "[concat(variables('storageAccountPrefix')[copyIndex()], variables('storageAccountSuffix'))]",
@@ -105,7 +191,7 @@
105191
"privateIPAllocationMethod": "Static",
106192
"privateIPAddress": "[concat('10.0.100.', copyIndex(10))]",
107193
"subnet": {
108-
"id": "[concat(variables('vnetId'), '/subnets/', variables('zookeeperNetName'))]"
194+
"id": "[concat(variables('vnetId'), '/subnets/', parameters('zookeeperNetName'))]"
109195
}
110196
}
111197
}
@@ -207,7 +293,7 @@
207293
"privateIPAllocationMethod": "Static",
208294
"privateIPAddress": "[concat('10.0.101.', copyIndex(10))]",
209295
"subnet": {
210-
"id": "[concat(variables('vnetId'), '/subnets/', variables('postgresNetName'))]"
296+
"id": "[concat(variables('vnetId'), '/subnets/', parameters('postgresNetName'))]"
211297
},
212298
"loadBalancerBackendAddressPools": [
213299
{
@@ -335,7 +421,7 @@
335421
"privateIPAddress": "10.0.101.4",
336422
"privateIPAllocationMethod": "Static",
337423
"subnet": {
338-
"id": "[concat(variables('vnetId'), '/subnets/', variables('zookeeperNetName'))]"
424+
"id": "[concat(variables('vnetId'), '/subnets/', parameters('zookeeperNetName'))]"
339425
}
340426
}
341427
}

0 commit comments

Comments
 (0)