Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
361 lines (338 sloc) 11.6 KB
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"vmSize": {
"type": "string",
"defaultValue": "Standard_DS2_v2",
"minLength": 1
},
"dnsPrefix": {
"type": "string",
"metadata": {
"description": "DNS name used for public IP addresses and as base for naming other resources. Must be globally unique and 3 to 61 characters long."
},
"minLength": 3,
"maxLength": 61
},
"instanceCount": {
"type": "int",
"metadata": {
"description": "Number of VM instances (100 or less)"
},
"minValue": 1,
"maxValue": 100
},
"adminUsername": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "Administrator username on all VMs"
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": "Administrator password on all VMs"
}
},
"registryServer": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "Regsitry Server"
}
},
"registryUsername": {
"type": "string",
"metadata": {
"description": "ACR username"
}
},
"registryPassword": {
"type": "securestring",
"metadata": {
"description": "ACR Password"
}
},
"_artifactsLocation": {
"type": "string",
"defaultValue": "https://github.com/marrobi/RancherOnAzure/raw/master/"
},
"_artifactsLocationSasToken": {
"type": "securestring",
"defaultValue": "?"
}
},
"variables": {
"singleQuote": "'",
"addressPrefix": "192.168.100.0/24",
"subnetPrefix": "192.168.100.0/25",
"virtualNetworkName": "vnetRancherServer",
"publicIPAddressName": "pipRancherServer",
"subnetName": "subnetRancherServer",
"loadBalancerName": "lbRancherServer",
"publicIPAddressID": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]",
"lbID": "[resourceId('Microsoft.Network/loadBalancers', variables('loadBalancerName'))]",
"natPoolName": "natpool",
"bePoolName": "bepool",
"nicName": "nic",
"ipConfigName": "ipconfig",
"frontEndIPConfigID": "[concat(variables('lbID'), '/frontendIPConfigurations/loadBalancerFrontEnd')]",
"backEndIPConfigID": "[concat(variables('lbID'), '/backendAddressPools/',variables('bePoolName'))]",
"osType": {
"publisher": "CoreOS",
"offer": "CoreOS",
"sku": "stable",
"version": "latest"
},
"imageReference": "[variables('osType')]",
"MySQLTemplateFolder": "nestedtemplates",
"MySQLTemplateFileName": "MySQL.json",
"MySQLTemplateParametersFileName": "MySQL.parameters.json",
"mySQLServerName": "[concat('mysql',parameters('DNSPrefix'))]",
"ScriptScriptFolder": "scripts",
"ScriptScriptFileName": "configure_server.sh"
},
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"name": "[variables('virtualNetworkName')]",
"location": "[resourceGroup().location]",
"apiVersion": "2015-06-15",
"tags": {
"displayName": "VirtualNetwork"
},
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "[variables('subnetPrefix')]"
}
}
]
}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"name": "[variables('publicIPAddressName')]",
"location": "[resourceGroup().location]",
"apiVersion": "2015-06-15",
"tags": {
"displayName": "[variables('publicIPAddressName')]"
},
"properties": {
"publicIPAllocationMethod": "Static",
"dnsSettings": {
"domainNameLabel": "[parameters('dnsPrefix')]"
}
}
},
{
"type": "Microsoft.Network/loadBalancers",
"name": "[variables('loadBalancerName')]",
"location": "[resourceGroup().location]",
"apiVersion": "2017-03-01",
"tags": {
"displayName": "[variables('loadBalancerName')]"
},
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
],
"properties": {
"frontendIPConfigurations": [
{
"name": "LoadBalancerFrontEnd",
"properties": {
"publicIPAddress": {
"id": "[variables('publicIPAddressID')]"
}
}
}
],
"backendAddressPools": [
{
"name": "[variables('bePoolName')]"
}
],
"loadBalancingRules": [
{
"name": "RancherServer",
"properties": {
"frontendIPConfiguration": {
"id": "[variables('frontEndIPConfigID')]"
},
"frontendPort": 8080,
"backendPort": 8080,
"enableFloatingIP": false,
"idleTimeoutInMinutes": 4,
"protocol": "Tcp",
"loadDistribution": "SourceIP",
"backendAddressPool": {
"id": "[variables('backEndIPConfigID')]"
},
"probe": {
"id": "[concat(variables('lbID'), '/probes/','RancherServerProbe')]"
}
}
}
],
"probes": [
{
"name": "RancherServerProbe",
"properties": {
"protocol": "Tcp",
"port": 8080,
"intervalInSeconds": 5,
"numberOfProbes": 2
}
}
],
"inboundNatPools": [
{
"name": "[variables('natPoolName')]",
"properties": {
"frontendIPConfiguration": {
"id": "[variables('frontEndIPConfigID')]"
},
"protocol": "tcp",
"frontendPortRangeStart": 50000,
"frontendPortRangeEnd": 50099,
"backendPort": 22
}
}
]
}
},
{
"type": "Microsoft.Compute/virtualMachineScaleSets",
"name": "vmssRancherServer",
"location": "[resourceGroup().location]",
"apiVersion": "2017-03-30",
"tags": {
"displayName": "vmssRancherServer"
},
"dependsOn": [
"[resourceId('Microsoft.Network/loadBalancers', variables('loadBalancerName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
"[resourceId('Microsoft.Resources/deployments', 'MySQL')]"
],
"sku": {
"name": "[parameters('vmSize')]",
"tier": "Standard",
"capacity": "[parameters('instanceCount')]"
},
"properties": {
"overprovision": false,
"upgradePolicy": {
"mode": "Automatic"
},
"virtualMachineProfile": {
"storageProfile": {
"osDisk": {
"createOption": "FromImage",
"caching": "ReadWrite"
},
"imageReference": "[variables('imageReference')]"
},
"osProfile": {
"computerNamePrefix": "RancherServer",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "[variables('nicName')]",
"properties": {
"primary": true,
"ipConfigurations": [
{
"name": "[variables('ipConfigName')]",
"properties": {
"subnet": {
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'), '/subnets/', variables('subnetName'))]"
},
"loadBalancerBackendAddressPools": [
{
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/loadBalancers/', variables('loadBalancerName'), '/backendAddressPools/', variables('bePoolName'))]"
}
],
"loadBalancerInboundNatPools": [
{
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/loadBalancers/', variables('loadBalancerName'), '/inboundNatPools/', variables('natPoolName'))]"
}
]
}
}
]
}
}
]
},
"extensionProfile": {
"extensions": [
{
"name": "Script",
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": [
"[concat(parameters('_artifactsLocation'), '/', variables('ScriptScriptFolder'), '/', variables('ScriptScriptFileName'), parameters('_artifactsLocationSasToken'))]",
"[concat(parameters('_artifactsLocation'), '/mysql_ssl/ca.pem', parameters('_artifactsLocationSasToken'))]"
],
"commandToExecute": "[concat('sh ', variables('ScriptScriptFileName'),' ',reference(resourceId('Microsoft.Resources/deployments','MySQL')).outputs.mySqlFQDN.value,' ',concat(parameters('adminUsername'),'@',variables('mySQLServerName')),' ',variables('singleQuote'),parameters('adminPassword'),variables('singleQuote'),' ',parameters('registryServer'),' ',parameters('registryUsername'),' ',parameters('registryPassword'))]"
}
}
}
]
}
}
}
},
{
"name": "MySQL",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2016-09-01",
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
],
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[concat(parameters('_artifactsLocation'), '/', variables('MySQLTemplateFolder'), '/', variables('MySQLTemplateFileName'), parameters('_artifactsLocationSasToken'))]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"administratorLogin": {
"value": "[parameters('adminUsername')]"
},
"administratorLoginPassword": {
"value": "[parameters('adminPassword')]"
},
"firewallIP": {
"value": "[reference(resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))).IpAddress]"
},
"serverName": {
"value": "[variables('mySQLServerName')]"
}
}
}
}
],
"outputs": {
"rancherServerFQDN": {
"value": "[reference(resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))).dnsSettings.fqdn]",
"type": "string"
}
}
}