зеркало из https://github.com/microsoft/lisa.git
remove storage account from arm template.
This commit is contained in:
Родитель
6d39968054
Коммит
d8de2b79cc
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
|
||||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"resourceGroupName": {
|
||||
|
@ -20,12 +20,6 @@
|
|||
"description": "location"
|
||||
}
|
||||
},
|
||||
"resourceGroupLocation": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "location of resource groups, fixed location prevents errors"
|
||||
}
|
||||
},
|
||||
"nodes": {
|
||||
"type": "array",
|
||||
"metadata": {
|
||||
|
@ -65,111 +59,87 @@
|
|||
},
|
||||
"variables": {
|
||||
"sharedRGName": "lisa_shared_resource",
|
||||
"storageDeploymentName": "[concat('storage-deploy-', substring(parameters('resourceGroupName'),sub(length(parameters('resourceGroupName')),22),22))]"
|
||||
"virtualNetworkName": "lisa-virtualNetwork",
|
||||
"defaultSubnet": "lisa-subnetForPrimaryNIC",
|
||||
"vnetId": "[resourceId('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]",
|
||||
"nodeCount": "[length(parameters('nodes'))]",
|
||||
"availabilitySetName": "lisa-availabilitySet",
|
||||
"defaultSubnetId": "[concat(variables('vnetId'),'/subnets/', variables('defaultSubnet'))]"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Resources/resourceGroups",
|
||||
"apiVersion": "2020-06-01",
|
||||
"name": "[variables('sharedRGName')]",
|
||||
"location": "[parameters('resourceGroupLocation')]",
|
||||
"properties": {}
|
||||
"apiVersion": "2019-07-01",
|
||||
"type": "Microsoft.Compute/availabilitySets",
|
||||
"name": "[variables('availabilitySetName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"tags": "[parameters('availabilitySetTags')]",
|
||||
"sku": {
|
||||
"name": "Aligned"
|
||||
},
|
||||
"properties": "[parameters('availabilitySetProperties')]"
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"apiVersion": "2019-10-01",
|
||||
"name": "[variables('storageDeploymentName')]",
|
||||
"resourceGroup": "[variables('sharedRGName')]",
|
||||
"dependsOn": [ "[variables('sharedRGName')]" ],
|
||||
"apiVersion": "2020-05-01",
|
||||
"type": "Microsoft.Network/publicIPAddresses",
|
||||
"location": "[parameters('location')]",
|
||||
"name": "[concat(parameters('nodes')[copyIndex('vmCopy')]['name'],'-public-ip')]",
|
||||
"copy": {
|
||||
"name": "vmCopy",
|
||||
"count": "[variables('nodeCount')]"
|
||||
},
|
||||
"properties": {
|
||||
"expressionEvaluationOptions": {
|
||||
"scope": "inner"
|
||||
},
|
||||
"parameters": {
|
||||
"location": {
|
||||
"value": "[parameters('location')]"
|
||||
},
|
||||
"storageName": {
|
||||
"value": "[parameters('storageName')]"
|
||||
}
|
||||
},
|
||||
"mode": "Incremental",
|
||||
"template": {
|
||||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"location": {
|
||||
"type": "string"
|
||||
},
|
||||
"storageName": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"name": "[parameters('storageName')]",
|
||||
"type": "Microsoft.Storage/storageAccounts",
|
||||
"apiVersion": "2019-06-01",
|
||||
"location": "[parameters('location')]",
|
||||
"kind": "StorageV2",
|
||||
"sku": {
|
||||
"name": "Standard_LRS"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
"publicIPAllocationMethod": "Dynamic"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Resources/resourceGroups",
|
||||
"apiVersion": "2020-06-01",
|
||||
"name": "[parameters('resourceGroupName')]",
|
||||
"location": "[parameters('resourceGroupLocation')]",
|
||||
"properties": {}
|
||||
"apiVersion": "2020-05-01",
|
||||
"type": "Microsoft.Network/virtualNetworks",
|
||||
"name": "[variables('virtualNetworkName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"properties": {
|
||||
"addressSpace": {
|
||||
"addressPrefixes": [
|
||||
"10.0.0.0/16"
|
||||
]
|
||||
},
|
||||
"subnets": [
|
||||
{
|
||||
"name": "[variables('defaultSubnet')]",
|
||||
"properties": {
|
||||
"addressPrefix": "10.0.0.0/24"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"apiVersion": "2019-10-01",
|
||||
"name": "lisa-deployment",
|
||||
"resourceGroup": "[parameters('resourceGroupName')]",
|
||||
"copy": {
|
||||
"name": "vmCopy",
|
||||
"count": "[variables('nodeCount')]"
|
||||
},
|
||||
"name": "[concat(parameters('nodes')[copyIndex('vmCopy')]['name'],'-networkInterfaces')]",
|
||||
"dependsOn": [
|
||||
"[parameters('resourceGroupName')]",
|
||||
"[variables('storageDeploymentName')]"
|
||||
"[resourceId('Microsoft.Network/publicIPAddresses/', concat(parameters('nodes')[copyIndex('vmCopy')]['name'],'-public-ip'))]",
|
||||
"[variables('vnetId')]"
|
||||
],
|
||||
"properties": {
|
||||
"expressionEvaluationOptions": {
|
||||
"scope": "inner"
|
||||
},
|
||||
"parameters": {
|
||||
"resourceGroupName": {
|
||||
"value": "[parameters('resourceGroupName')]"
|
||||
"vmName": {
|
||||
"value": "[parameters('nodes')[copyIndex('vmCopy')]['name']]"
|
||||
},
|
||||
"nicCount": {
|
||||
"value": "[parameters('nodes')[copyIndex('vmCopy')]['nicCount']]"
|
||||
},
|
||||
"location": {
|
||||
"value": "[parameters('location')]"
|
||||
},
|
||||
"nodes": {
|
||||
"value": "[parameters('nodes')]"
|
||||
},
|
||||
"adminUsername": {
|
||||
"value": "[parameters('adminUsername')]"
|
||||
},
|
||||
"adminPassword": {
|
||||
"value": "[parameters('adminPassword')]"
|
||||
},
|
||||
"adminKeyData": {
|
||||
"value": "[parameters('adminKeyData')]"
|
||||
},
|
||||
"availabilitySetTags": {
|
||||
"value": "[parameters('availabilitySetTags')]"
|
||||
},
|
||||
"availabilitySetProperties": {
|
||||
"value": "[parameters('availabilitySetProperties')]"
|
||||
},
|
||||
"storageName": {
|
||||
"value": "[parameters('storageName')]"
|
||||
},
|
||||
"sharedRGName": {
|
||||
"value": "[variables('sharedRGName')]"
|
||||
"defaultSubnetId": {
|
||||
"value": "[variables('defaultSubnetId')]"
|
||||
}
|
||||
},
|
||||
"mode": "Incremental",
|
||||
|
@ -177,292 +147,51 @@
|
|||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"resourceGroupName": {
|
||||
"vmName": {
|
||||
"type": "string"
|
||||
},
|
||||
"nicCount": {
|
||||
"type": "int"
|
||||
},
|
||||
"location": {
|
||||
"type": "string"
|
||||
},
|
||||
"nodes": {
|
||||
"type": "array"
|
||||
},
|
||||
"adminUsername": {
|
||||
"type": "string"
|
||||
},
|
||||
"adminPassword": {
|
||||
"type": "string"
|
||||
},
|
||||
"adminKeyData": {
|
||||
"type": "string"
|
||||
},
|
||||
"availabilitySetTags": {
|
||||
"type": "object"
|
||||
},
|
||||
"availabilitySetProperties": {
|
||||
"type": "object"
|
||||
},
|
||||
"storageName": {
|
||||
"type": "string"
|
||||
},
|
||||
"sharedRGName": {
|
||||
"defaultSubnetId": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"virtualNetworkName": "lisa-virtualNetwork",
|
||||
"defaultSubnet": "lisa-subnetForPrimaryNIC",
|
||||
"vnetId": "[resourceId('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]",
|
||||
"nodeCount": "[length(parameters('nodes'))]",
|
||||
"availabilitySetName": "lisa-availabilitySet",
|
||||
"defaultSubnetId": "[concat(variables('vnetId'),'/subnets/', variables('defaultSubnet'))]"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"apiVersion": "2019-07-01",
|
||||
"type": "Microsoft.Compute/availabilitySets",
|
||||
"name": "[variables('availabilitySetName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"tags": "[parameters('availabilitySetTags')]",
|
||||
"sku": {
|
||||
"name": "Aligned"
|
||||
},
|
||||
"properties": "[parameters('availabilitySetProperties')]"
|
||||
},
|
||||
{
|
||||
"apiVersion": "2020-05-01",
|
||||
"type": "Microsoft.Network/publicIPAddresses",
|
||||
"location": "[parameters('location')]",
|
||||
"name": "[concat(parameters('nodes')[copyIndex('vmCopy')]['name'],'-public-ip')]",
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"copy": {
|
||||
"name": "vmCopy",
|
||||
"count": "[variables('nodeCount')]"
|
||||
"name": "nicCopy",
|
||||
"count": "[parameters('nicCount')]"
|
||||
},
|
||||
"properties": {
|
||||
"publicIPAllocationMethod": "Dynamic"
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2020-05-01",
|
||||
"type": "Microsoft.Network/virtualNetworks",
|
||||
"name": "[variables('virtualNetworkName')]",
|
||||
"name": "[concat(parameters('vmName'), '-nic-', copyIndex('nicCopy'))]",
|
||||
"location": "[parameters('location')]",
|
||||
"properties": {
|
||||
"addressSpace": {
|
||||
"addressPrefixes": [
|
||||
"10.0.0.0/16"
|
||||
]
|
||||
},
|
||||
"subnets": [
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "[variables('defaultSubnet')]",
|
||||
"name": "IPv4Config",
|
||||
"properties": {
|
||||
"addressPrefix": "10.0.0.0/24"
|
||||
"privateIPAddressVersion": "IPv4",
|
||||
"publicIPAddress": "[if(equals(0, copyIndex('nicCopy')), network.getPublicIpAddress(parameters('vmName')), json('null'))]",
|
||||
"subnet": {
|
||||
"id": "[parameters('defaultSubnetId')]"
|
||||
},
|
||||
"privateIPAllocationMethod": "Dynamic"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"apiVersion": "2019-10-01",
|
||||
"copy": {
|
||||
"name": "vmCopy",
|
||||
"count": "[variables('nodeCount')]"
|
||||
},
|
||||
"name": "[concat(parameters('nodes')[copyIndex('vmCopy')]['name'],'-networkInterfaces')]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.Network/publicIPAddresses/', concat(parameters('nodes')[copyIndex('vmCopy')]['name'],'-public-ip'))]",
|
||||
"[variables('vnetId')]"
|
||||
],
|
||||
"properties": {
|
||||
"expressionEvaluationOptions": {
|
||||
"scope": "inner"
|
||||
},
|
||||
"parameters": {
|
||||
"vmName": {
|
||||
"value": "[parameters('nodes')[copyIndex('vmCopy')]['name']]"
|
||||
},
|
||||
"nicCount": {
|
||||
"value": "[parameters('nodes')[copyIndex('vmCopy')]['nicCount']]"
|
||||
},
|
||||
"location": {
|
||||
"value": "[parameters('location')]"
|
||||
},
|
||||
"defaultSubnetId": {
|
||||
"value": "[variables('defaultSubnetId')]"
|
||||
}
|
||||
},
|
||||
"mode": "Incremental",
|
||||
"template": {
|
||||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"vmName": {
|
||||
"type": "string"
|
||||
},
|
||||
"nicCount": {
|
||||
"type": "int"
|
||||
},
|
||||
"location": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultSubnetId": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"apiVersion": "2020-05-01",
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"copy": {
|
||||
"name": "nicCopy",
|
||||
"count": "[parameters('nicCount')]"
|
||||
},
|
||||
"name": "[concat(parameters('vmName'), '-nic-', copyIndex('nicCopy'))]",
|
||||
"location": "[parameters('location')]",
|
||||
"properties": {
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "IPv4Config",
|
||||
"properties": {
|
||||
"privateIPAddressVersion": "IPv4",
|
||||
"publicIPAddress": "[if(equals(0, copyIndex('nicCopy')), network.getPublicIpAddress(parameters('vmName')), json('null'))]",
|
||||
"subnet": {
|
||||
"id": "[parameters('defaultSubnetId')]"
|
||||
},
|
||||
"privateIPAllocationMethod": "Dynamic"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"namespace": "network",
|
||||
"members": {
|
||||
"getPublicIpAddress": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "vmName",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"output": {
|
||||
"type": "object",
|
||||
"value": {
|
||||
"id": "[resourceId('Microsoft.Network/publicIPAddresses/', concat(parameters('vmName'),'-public-ip'))]"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2019-03-01",
|
||||
"type": "Microsoft.Compute/images",
|
||||
"copy": {
|
||||
"name": "imageCopy",
|
||||
"count": "[variables('nodeCount')]"
|
||||
},
|
||||
"condition": "[not(empty(parameters('nodes')[copyIndex('imageCopy')]['vhd']))]",
|
||||
"name": "[concat(parameters('nodes')[copyIndex('imageCopy')]['name'], '-image')]",
|
||||
"location": "[parameters('location')]",
|
||||
"properties": {
|
||||
"storageProfile": {
|
||||
"osDisk": {
|
||||
"osType": "Linux",
|
||||
"osState": "Generalized",
|
||||
"blobUri": "[parameters('nodes')[copyIndex('imageCopy')]['vhd']]",
|
||||
"storageAccountType": "Standard_LRS"
|
||||
}
|
||||
},
|
||||
"hyperVGeneration": "V1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2019-07-01",
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"copy": {
|
||||
"name": "vmCopy",
|
||||
"count": "[variables('nodeCount')]"
|
||||
},
|
||||
"name": "[parameters('nodes')[copyIndex('vmCopy')]['name']]",
|
||||
"location": "[parameters('nodes')[copyIndex('vmCopy')]['location']]",
|
||||
"tags": { "RG": "[parameters('resourceGroupName')]" },
|
||||
"plan": "[parameters('nodes')[copyIndex('vmCopy')]['purchasePlan']]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.Compute/availabilitySets', variables('availabilitySetName'))]",
|
||||
"[resourceId('Microsoft.Compute/images', concat(parameters('nodes')[copyIndex('vmCopy')]['name'], '-image'))]",
|
||||
"[concat(parameters('nodes')[copyIndex('vmCopy')]['name'],'-networkInterfaces')]"
|
||||
],
|
||||
"properties": {
|
||||
"availabilitySet": {
|
||||
"id": "[resourceId('Microsoft.Compute/availabilitySets',variables('availabilitySetName'))]"
|
||||
},
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[parameters('nodes')[copyIndex('vmCopy')]['vmSize']]"
|
||||
},
|
||||
"osProfile": {
|
||||
"computername": "[parameters('nodes')[copyIndex('vmCopy')]['name']]",
|
||||
"adminUsername": "[parameters('adminUserName')]",
|
||||
"adminPassword": "[if(empty(parameters('adminKeyData')), parameters('adminPassword'), json('null'))]",
|
||||
"linuxConfiguration": "[if(empty(parameters('adminKeyData')), json('null'), lisa.getLinuxConfiguration(concat('/home/', parameters('adminUserName'), '/.ssh/authorized_keys'), parameters('adminKeyData')))]"
|
||||
},
|
||||
"storageProfile": {
|
||||
"imageReference": "[if(not(empty(parameters('nodes')[copyIndex('vmCopy')]['vhd'])), lisa.getOsDiskVhd(parameters('nodes')[copyIndex('vmCopy')]['name']), lisa.getOsDiskGallery(parameters('nodes')[copyIndex('vmCopy')]))]",
|
||||
"osDisk": {
|
||||
"name": "[concat(parameters('nodes')[copyIndex('vmCopy')]['name'], '-osDisk')]",
|
||||
"managedDisk": {
|
||||
"storageAccountType": "Standard_LRS"
|
||||
},
|
||||
"caching": "ReadWrite",
|
||||
"createOption": "FromImage"
|
||||
}
|
||||
},
|
||||
"networkProfile": {
|
||||
"copy": [
|
||||
{
|
||||
"name": "networkInterfaces",
|
||||
"count": "[parameters('nodes')[copyIndex('vmCopy')]['nicCount']]",
|
||||
"input": {
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat(parameters('nodes')[copyIndex('vmCopy')]['name'], '-nic-', copyIndex('networkInterfaces')))]",
|
||||
"properties": {
|
||||
"primary": "[if(equals(copyIndex('networkInterfaces'),0), json('true'), json('false'))]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"diagnosticsProfile": {
|
||||
"bootDiagnostics": {
|
||||
"enabled": true,
|
||||
"storageUri": "[reference(resourceId(parameters('sharedRGName'), 'Microsoft.Storage/storageAccounts', parameters('storageName')), '2015-06-15').primaryEndpoints['blob']]"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"namespace": "lisa",
|
||||
"namespace": "network",
|
||||
"members": {
|
||||
"getOsDiskGallery": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "node",
|
||||
"type": "object"
|
||||
}
|
||||
],
|
||||
"output": {
|
||||
"type": "object",
|
||||
"value": "[parameters('node')['gallery']]"
|
||||
}
|
||||
},
|
||||
"getOsDiskVhd": {
|
||||
"getPublicIpAddress": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "vmName",
|
||||
|
@ -472,34 +201,7 @@
|
|||
"output": {
|
||||
"type": "object",
|
||||
"value": {
|
||||
"id": "[resourceId('Microsoft.Compute/images', concat(parameters('vmName'), '-image'))]"
|
||||
}
|
||||
}
|
||||
},
|
||||
"getLinuxConfiguration": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "keyPath",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "publicKeyData",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"output": {
|
||||
"type": "object",
|
||||
"value": {
|
||||
"disablePasswordAuthentication": true,
|
||||
"ssh": {
|
||||
"publicKeys": [
|
||||
{
|
||||
"path": "[parameters('keyPath')]",
|
||||
"keyData": "[parameters('publicKeyData')]"
|
||||
}
|
||||
]
|
||||
},
|
||||
"provisionVMAgent": true
|
||||
"id": "[resourceId('Microsoft.Network/publicIPAddresses/', concat(parameters('vmName'),'-public-ip'))]"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -508,6 +210,150 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2019-03-01",
|
||||
"type": "Microsoft.Compute/images",
|
||||
"copy": {
|
||||
"name": "imageCopy",
|
||||
"count": "[variables('nodeCount')]"
|
||||
},
|
||||
"condition": "[not(empty(parameters('nodes')[copyIndex('imageCopy')]['vhd']))]",
|
||||
"name": "[concat(parameters('nodes')[copyIndex('imageCopy')]['name'], '-image')]",
|
||||
"location": "[parameters('location')]",
|
||||
"properties": {
|
||||
"storageProfile": {
|
||||
"osDisk": {
|
||||
"osType": "Linux",
|
||||
"osState": "Generalized",
|
||||
"blobUri": "[parameters('nodes')[copyIndex('imageCopy')]['vhd']]",
|
||||
"storageAccountType": "Standard_LRS"
|
||||
}
|
||||
},
|
||||
"hyperVGeneration": "V1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2019-07-01",
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"copy": {
|
||||
"name": "vmCopy",
|
||||
"count": "[variables('nodeCount')]"
|
||||
},
|
||||
"name": "[parameters('nodes')[copyIndex('vmCopy')]['name']]",
|
||||
"location": "[parameters('nodes')[copyIndex('vmCopy')]['location']]",
|
||||
"tags": { "RG": "[parameters('resourceGroupName')]" },
|
||||
"plan": "[parameters('nodes')[copyIndex('vmCopy')]['purchasePlan']]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.Compute/availabilitySets', variables('availabilitySetName'))]",
|
||||
"[resourceId('Microsoft.Compute/images', concat(parameters('nodes')[copyIndex('vmCopy')]['name'], '-image'))]",
|
||||
"[concat(parameters('nodes')[copyIndex('vmCopy')]['name'],'-networkInterfaces')]"
|
||||
],
|
||||
"properties": {
|
||||
"availabilitySet": {
|
||||
"id": "[resourceId('Microsoft.Compute/availabilitySets',variables('availabilitySetName'))]"
|
||||
},
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[parameters('nodes')[copyIndex('vmCopy')]['vmSize']]"
|
||||
},
|
||||
"osProfile": {
|
||||
"computername": "[parameters('nodes')[copyIndex('vmCopy')]['name']]",
|
||||
"adminUsername": "[parameters('adminUserName')]",
|
||||
"adminPassword": "[if(empty(parameters('adminKeyData')), parameters('adminPassword'), json('null'))]",
|
||||
"linuxConfiguration": "[if(empty(parameters('adminKeyData')), json('null'), lisa.getLinuxConfiguration(concat('/home/', parameters('adminUserName'), '/.ssh/authorized_keys'), parameters('adminKeyData')))]"
|
||||
},
|
||||
"storageProfile": {
|
||||
"imageReference": "[if(not(empty(parameters('nodes')[copyIndex('vmCopy')]['vhd'])), lisa.getOsDiskVhd(parameters('nodes')[copyIndex('vmCopy')]['name']), lisa.getOsDiskGallery(parameters('nodes')[copyIndex('vmCopy')]))]",
|
||||
"osDisk": {
|
||||
"name": "[concat(parameters('nodes')[copyIndex('vmCopy')]['name'], '-osDisk')]",
|
||||
"managedDisk": {
|
||||
"storageAccountType": "Standard_LRS"
|
||||
},
|
||||
"caching": "ReadWrite",
|
||||
"createOption": "FromImage"
|
||||
}
|
||||
},
|
||||
"networkProfile": {
|
||||
"copy": [
|
||||
{
|
||||
"name": "networkInterfaces",
|
||||
"count": "[parameters('nodes')[copyIndex('vmCopy')]['nicCount']]",
|
||||
"input": {
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat(parameters('nodes')[copyIndex('vmCopy')]['name'], '-nic-', copyIndex('networkInterfaces')))]",
|
||||
"properties": {
|
||||
"primary": "[if(equals(copyIndex('networkInterfaces'),0), json('true'), json('false'))]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"diagnosticsProfile": {
|
||||
"bootDiagnostics": {
|
||||
"enabled": true,
|
||||
"storageUri": "[reference(resourceId(variables('sharedRGName'), 'Microsoft.Storage/storageAccounts', parameters('storageName')), '2015-06-15').primaryEndpoints['blob']]"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"namespace": "lisa",
|
||||
"members": {
|
||||
"getOsDiskGallery": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "node",
|
||||
"type": "object"
|
||||
}
|
||||
],
|
||||
"output": {
|
||||
"type": "object",
|
||||
"value": "[parameters('node')['gallery']]"
|
||||
}
|
||||
},
|
||||
"getOsDiskVhd": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "vmName",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"output": {
|
||||
"type": "object",
|
||||
"value": {
|
||||
"id": "[resourceId('Microsoft.Compute/images', concat(parameters('vmName'), '-image'))]"
|
||||
}
|
||||
}
|
||||
},
|
||||
"getLinuxConfiguration": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "keyPath",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "publicKeyData",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"output": {
|
||||
"type": "object",
|
||||
"value": {
|
||||
"disablePasswordAuthentication": true,
|
||||
"ssh": {
|
||||
"publicKeys": [
|
||||
{
|
||||
"path": "[parameters('keyPath')]",
|
||||
"keyData": "[parameters('publicKeyData')]"
|
||||
}
|
||||
]
|
||||
},
|
||||
"provisionVMAgent": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ from datetime import datetime
|
|||
from functools import lru_cache
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from typing import Any, Dict, List, Optional, Type, Union
|
||||
from typing import Any, Dict, List, Optional, Tuple, Type, Union
|
||||
|
||||
from azure.core.exceptions import HttpResponseError
|
||||
from azure.identity import DefaultAzureCredential # type: ignore
|
||||
|
@ -63,6 +63,7 @@ from .common import (
|
|||
)
|
||||
|
||||
# used by azure
|
||||
AZURE_DEPLOYMENT_NAME = "lisa_default_deployment_script"
|
||||
AZURE_RG_NAME_KEY = "resource_group_name"
|
||||
AZURE_SHARED_RG_NAME = "lisa_shared_resource"
|
||||
|
||||
|
@ -199,7 +200,6 @@ class AzureNodeSchema:
|
|||
@dataclass
|
||||
class AzureArmParameter:
|
||||
resource_group_name: str = ""
|
||||
resource_group_location: str = ""
|
||||
storage_name: str = ""
|
||||
location: str = ""
|
||||
admin_username: str = ""
|
||||
|
@ -511,13 +511,23 @@ class AzurePlatform(Platform):
|
|||
else:
|
||||
log.info(f"used resource group: {resource_group_name}")
|
||||
try:
|
||||
deployment_parameters = self._create_deployment_parameters(
|
||||
if self._azure_runbook.deploy:
|
||||
log.info(
|
||||
f"creating or updating resource group: {resource_group_name}"
|
||||
)
|
||||
self._rm_client.resource_groups.create_or_update(
|
||||
resource_group_name, {"location": RESOURCE_GROUP_LOCATION}
|
||||
)
|
||||
else:
|
||||
log.info(f"reusing resource group: {resource_group_name}")
|
||||
|
||||
location, deployment_parameters = self._create_deployment_parameters(
|
||||
resource_group_name, environment, log
|
||||
)
|
||||
|
||||
if self._azure_runbook.deploy:
|
||||
self._validate_template(deployment_parameters, log)
|
||||
self._deploy(deployment_parameters, log)
|
||||
self._deploy(location, deployment_parameters, log)
|
||||
|
||||
# Even skipped deploy, try best to initialize nodes
|
||||
self._initialize_nodes(environment)
|
||||
|
@ -707,7 +717,7 @@ class AzurePlatform(Platform):
|
|||
|
||||
def _create_deployment_parameters(
|
||||
self, resource_group_name: str, environment: Environment, log: Logger
|
||||
) -> Dict[str, Any]:
|
||||
) -> Tuple[str, Dict[str, Any]]:
|
||||
assert environment.runbook, "env data cannot be None"
|
||||
assert environment.runbook.nodes_requirement, "node requirement cannot be None"
|
||||
|
||||
|
@ -730,7 +740,6 @@ class AzurePlatform(Platform):
|
|||
|
||||
environment_context = get_environment_context(environment=environment)
|
||||
arm_parameters.resource_group_name = environment_context.resource_group_name
|
||||
arm_parameters.resource_group_location = RESOURCE_GROUP_LOCATION
|
||||
nodes_parameters: List[AzureNodeSchema] = []
|
||||
for node_space in environment.runbook.nodes_requirement:
|
||||
assert isinstance(
|
||||
|
@ -798,15 +807,14 @@ class AzurePlatform(Platform):
|
|||
parameters=parameters,
|
||||
)
|
||||
|
||||
return {
|
||||
# deployment name must be different, or there may be concurrent issue.
|
||||
# the max name is 64 charactors, so take end part if it's too long.
|
||||
"deployment_name": f"lisa_deploy_"
|
||||
f"{environment_context.resource_group_name[-50:]}",
|
||||
"parameters": Deployment(
|
||||
location=arm_parameters.location, properties=deployment_properties
|
||||
),
|
||||
}
|
||||
return (
|
||||
arm_parameters.location,
|
||||
{
|
||||
AZURE_RG_NAME_KEY: resource_group_name,
|
||||
"deployment_name": AZURE_DEPLOYMENT_NAME,
|
||||
"parameters": Deployment(properties=deployment_properties),
|
||||
},
|
||||
)
|
||||
|
||||
def _validate_template(
|
||||
self, deployment_parameters: Dict[str, Any], log: Logger
|
||||
|
@ -815,14 +823,12 @@ class AzurePlatform(Platform):
|
|||
|
||||
validate_operation: Any = None
|
||||
try:
|
||||
validate_operation = (
|
||||
self._rm_client.deployments.begin_validate_at_subscription_scope(
|
||||
**deployment_parameters
|
||||
)
|
||||
validate_operation = self._rm_client.deployments.begin_validate(
|
||||
**deployment_parameters
|
||||
)
|
||||
result = wait_operation(validate_operation)
|
||||
if result:
|
||||
raise LisaException(f"deploy failed: {result}")
|
||||
raise LisaException(f"validation failed: {result}")
|
||||
except Exception as identifier:
|
||||
error_messages: List[str] = [str(identifier)]
|
||||
|
||||
|
@ -835,20 +841,19 @@ class AzurePlatform(Platform):
|
|||
|
||||
assert result is None, f"validate error: {result}"
|
||||
|
||||
def _deploy(self, deployment_parameters: Dict[str, Any], log: Logger) -> None:
|
||||
log.info("deployment is in progress...")
|
||||
def _deploy(
|
||||
self, location: str, deployment_parameters: Dict[str, Any], log: Logger
|
||||
) -> None:
|
||||
resource_group_name = deployment_parameters[AZURE_RG_NAME_KEY]
|
||||
log.info(f"resource group '{resource_group_name}' deployment is in progress...")
|
||||
|
||||
self._check_or_create_storage_account(
|
||||
location=deployment_parameters["parameters"].location, log=log
|
||||
)
|
||||
self._check_or_create_storage_account(location=location, log=log)
|
||||
|
||||
deployment_operation: Any = None
|
||||
deployments = self._rm_client.deployments
|
||||
try:
|
||||
deployment_operation = (
|
||||
deployments.begin_create_or_update_at_subscription_scope(
|
||||
**deployment_parameters
|
||||
)
|
||||
deployment_operation = deployments.begin_create_or_update(
|
||||
**deployment_parameters
|
||||
)
|
||||
result = wait_operation(deployment_operation)
|
||||
if result:
|
||||
|
|
Загрузка…
Ссылка в новой задаче