зеркало из https://github.com/microsoft/lisa.git
support storage account in arm template
1. Deploy both shared rg and test rg in same template. 2. Enable serial console log to vms.
This commit is contained in:
Родитель
6dd4d1a246
Коммит
40d618d44f
|
@ -1,13 +1,25 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
|
||||
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"resourceGroupName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "resource gorup name"
|
||||
}
|
||||
},
|
||||
"location": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "location"
|
||||
}
|
||||
},
|
||||
"resourceGroupLocation": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "location of resource groups, fixed location prevents errors"
|
||||
}
|
||||
},
|
||||
"nodes": {
|
||||
"type": "array",
|
||||
"metadata": {
|
||||
|
@ -46,88 +58,33 @@
|
|||
}
|
||||
},
|
||||
"variables": {
|
||||
"nodeCount": "[length(parameters('nodes'))]",
|
||||
"resourceGroupName": "[resourceGroup().name]",
|
||||
"virtualNetworkName": "lisa-virtualNetwork",
|
||||
"defaultSubnet": "lisa-subnetForPrimaryNIC",
|
||||
"availabilitySetName": "lisa-availabilitySet",
|
||||
"defaultSubnetId": "[concat(variables('vnetId'),'/subnets/', variables('defaultSubnet'))]",
|
||||
"vnetId": "[resourceId('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
|
||||
"storageName": "[concat('lisas', substring(parameters('location'),0,min(11, length(parameters('location')))), substring(subscription().id,sub(length(subscription().id),8),8))]",
|
||||
"sharedRGName": "lisa_shared_resource"
|
||||
},
|
||||
"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')]",
|
||||
"copy": {
|
||||
"name": "vmCopy",
|
||||
"count": "[variables('nodeCount')]"
|
||||
},
|
||||
"properties": {
|
||||
"publicIPAllocationMethod": "Dynamic"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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/resourceGroups",
|
||||
"apiVersion": "2020-06-01",
|
||||
"name": "[variables('sharedRGName')]",
|
||||
"location": "[parameters('resourceGroupLocation')]",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"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')]"
|
||||
],
|
||||
"name": "[concat('storage-account-deployment-', parameters('location'))]",
|
||||
"resourceGroup": "[variables('sharedRGName')]",
|
||||
"dependsOn": [ "[variables('sharedRGName')]" ],
|
||||
"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')]"
|
||||
"storageName": {
|
||||
"value": "[variables('storageName')]"
|
||||
}
|
||||
},
|
||||
"mode": "Incremental",
|
||||
|
@ -135,51 +92,370 @@
|
|||
"$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": {
|
||||
"storageName": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"apiVersion": "2020-05-01",
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"copy": {
|
||||
"name": "nicCopy",
|
||||
"count": "[parameters('nicCount')]"
|
||||
"name": "[parameters('storageName')]",
|
||||
"type": "Microsoft.Storage/storageAccounts",
|
||||
"apiVersion": "2019-06-01",
|
||||
"location": "[parameters('location')]",
|
||||
"kind": "StorageV2",
|
||||
"sku": {
|
||||
"name": "Standard_LRS"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Resources/resourceGroups",
|
||||
"apiVersion": "2020-06-01",
|
||||
"name": "[parameters('resourceGroupName')]",
|
||||
"location": "[parameters('resourceGroupLocation')]",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"apiVersion": "2019-10-01",
|
||||
"name": "lisa-deployment",
|
||||
"resourceGroup": "[parameters('resourceGroupName')]",
|
||||
"dependsOn": [
|
||||
"[parameters('resourceGroupName')]",
|
||||
"[concat('storage-account-deployment-', parameters('location'))]"
|
||||
],
|
||||
"properties": {
|
||||
"expressionEvaluationOptions": {
|
||||
"scope": "inner"
|
||||
},
|
||||
"parameters": {
|
||||
"resourceGroupName": {
|
||||
"value": "[parameters('resourceGroupName')]"
|
||||
},
|
||||
"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": "[variables('storageName')]"
|
||||
},
|
||||
"sharedRGName": {
|
||||
"value": "[variables('sharedRGName')]"
|
||||
}
|
||||
},
|
||||
"mode": "Incremental",
|
||||
"template": {
|
||||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"resourceGroupName": {
|
||||
"type": "string"
|
||||
},
|
||||
"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": {
|
||||
"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"
|
||||
},
|
||||
"name": "[concat(parameters('vmName'), '-nic-', copyIndex('nicCopy'))]",
|
||||
"properties": "[parameters('availabilitySetProperties')]"
|
||||
},
|
||||
{
|
||||
"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": {
|
||||
"publicIPAllocationMethod": "Dynamic"
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2020-05-01",
|
||||
"type": "Microsoft.Network/virtualNetworks",
|
||||
"name": "[variables('virtualNetworkName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"properties": {
|
||||
"ipConfigurations": [
|
||||
"addressSpace": {
|
||||
"addressPrefixes": [
|
||||
"10.0.0.0/16"
|
||||
]
|
||||
},
|
||||
"subnets": [
|
||||
{
|
||||
"name": "IPv4Config",
|
||||
"name": "[variables('defaultSubnet')]",
|
||||
"properties": {
|
||||
"privateIPAddressVersion": "IPv4",
|
||||
"publicIPAddress": "[if(equals(0, copyIndex('nicCopy')), network.getPublicIpAddress(parameters('vmName')), json('null'))]",
|
||||
"subnet": {
|
||||
"id": "[parameters('defaultSubnetId')]"
|
||||
},
|
||||
"privateIPAllocationMethod": "Dynamic"
|
||||
"addressPrefix": "10.0.0.0/24"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"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')]" },
|
||||
"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": "network",
|
||||
"namespace": "lisa",
|
||||
"members": {
|
||||
"getPublicIpAddress": {
|
||||
"getOsDiskGallery": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "node",
|
||||
"type": "object"
|
||||
}
|
||||
],
|
||||
"output": {
|
||||
"type": "object",
|
||||
"value": "[parameters('node')['gallery']]"
|
||||
}
|
||||
},
|
||||
"getOsDiskVhd": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "vmName",
|
||||
|
@ -189,7 +465,34 @@
|
|||
"output": {
|
||||
"type": "object",
|
||||
"value": {
|
||||
"id": "[resourceId('Microsoft.Network/publicIPAddresses/', concat(parameters('vmName'),'-public-ip'))]"
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -198,143 +501,6 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"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": "[variables('resourceGroupName')]" },
|
||||
"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'))]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -53,7 +53,6 @@ from .common import (
|
|||
)
|
||||
|
||||
# used by azure
|
||||
AZURE_DEPLOYMENT_NAME = "lisa_default_deployment_script"
|
||||
AZURE_RG_NAME_KEY = "resource_group_name"
|
||||
|
||||
VM_SIZE_FALLBACK_LEVELS = [
|
||||
|
@ -175,6 +174,8 @@ class AzureNodeSchema:
|
|||
@dataclass_json(letter_case=LetterCase.CAMEL)
|
||||
@dataclass
|
||||
class AzureArmParameter:
|
||||
resource_group_name: str = ""
|
||||
resource_group_location: str = ""
|
||||
location: str = ""
|
||||
admin_username: str = ""
|
||||
admin_password: str = ""
|
||||
|
@ -483,17 +484,8 @@ class AzurePlatform(Platform):
|
|||
if self._azure_runbook.dry_run:
|
||||
log.info(f"dry_run: {self._azure_runbook.dry_run}")
|
||||
else:
|
||||
log.info(f"used resource group: {resource_group_name}")
|
||||
try:
|
||||
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}")
|
||||
|
||||
deployment_parameters = self._create_deployment_parameters(
|
||||
resource_group_name, environment, log
|
||||
)
|
||||
|
@ -536,10 +528,14 @@ class AzurePlatform(Platform):
|
|||
f"deleting resource group: {resource_group_name}, "
|
||||
f"wait: {self._azure_runbook.wait_delete}"
|
||||
)
|
||||
delete_operation = self._rm_client.resource_groups.begin_delete(
|
||||
resource_group_name
|
||||
)
|
||||
if self._azure_runbook.wait_delete:
|
||||
delete_operation: Any = None
|
||||
try:
|
||||
delete_operation = self._rm_client.resource_groups.begin_delete(
|
||||
resource_group_name
|
||||
)
|
||||
except Exception as indentifer:
|
||||
log.debug(f"exception on delete resource group: {indentifer}")
|
||||
if delete_operation and self._azure_runbook.wait_delete:
|
||||
result = wait_operation(delete_operation)
|
||||
if result:
|
||||
raise LisaException(f"error on deleting resource group: {result}")
|
||||
|
@ -548,7 +544,9 @@ class AzurePlatform(Platform):
|
|||
|
||||
def _initialize(self, *args: Any, **kwargs: Any) -> None:
|
||||
# set needed environment variables for authentication
|
||||
azure_runbook = self._runbook.get_extended_runbook(AzurePlatformSchema)
|
||||
azure_runbook: AzurePlatformSchema = self._runbook.get_extended_runbook(
|
||||
AzurePlatformSchema
|
||||
)
|
||||
assert azure_runbook, "platform runbook cannot be empty"
|
||||
self._azure_runbook = azure_runbook
|
||||
|
||||
|
@ -715,6 +713,8 @@ class AzurePlatform(Platform):
|
|||
arm_parameters.admin_password = self._runbook.admin_password
|
||||
|
||||
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(
|
||||
|
@ -774,22 +774,26 @@ class AzurePlatform(Platform):
|
|||
)
|
||||
|
||||
return {
|
||||
AZURE_RG_NAME_KEY: resource_group_name,
|
||||
"deployment_name": AZURE_DEPLOYMENT_NAME,
|
||||
"parameters": Deployment(properties=deployment_properties),
|
||||
# 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=RESOURCE_GROUP_LOCATION, properties=deployment_properties
|
||||
),
|
||||
}
|
||||
|
||||
def _validate_template(
|
||||
self, deployment_parameters: Dict[str, Any], log: Logger
|
||||
) -> None:
|
||||
resource_group_name = deployment_parameters[AZURE_RG_NAME_KEY]
|
||||
log.debug("validating deployment")
|
||||
|
||||
validate_operation: Any = None
|
||||
deployments = self._rm_client.deployments
|
||||
try:
|
||||
validate_operation = self._rm_client.deployments.begin_validate(
|
||||
**deployment_parameters
|
||||
validate_operation = (
|
||||
self._rm_client.deployments.begin_validate_at_subscription_scope(
|
||||
**deployment_parameters
|
||||
)
|
||||
)
|
||||
result = wait_operation(validate_operation)
|
||||
if result:
|
||||
|
@ -797,17 +801,7 @@ class AzurePlatform(Platform):
|
|||
except Exception as identifier:
|
||||
error_messages: List[str] = [str(identifier)]
|
||||
|
||||
# default error message is too general in most case,
|
||||
# so check for more details.
|
||||
if validate_operation:
|
||||
# validate_operation returned, it means deployments created
|
||||
# successfuly. so check errors from deployments by name.
|
||||
deployment = deployments.get(resource_group_name, AZURE_DEPLOYMENT_NAME)
|
||||
if deployment.properties.provisioning_state == "Failed":
|
||||
error_messages = self._parse_detail_errors(
|
||||
deployment.properties.error
|
||||
)
|
||||
elif isinstance(identifier, HttpResponseError) and identifier.error:
|
||||
if isinstance(identifier, HttpResponseError) and identifier.error:
|
||||
# no validate_operation returned, the message may include
|
||||
# some errors, so check details
|
||||
error_messages = self._parse_detail_errors(identifier.error)
|
||||
|
@ -817,14 +811,15 @@ class AzurePlatform(Platform):
|
|||
assert result is None, f"validate error: {result}"
|
||||
|
||||
def _deploy(self, 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...")
|
||||
log.info("deployment is in progress...")
|
||||
|
||||
deployment_operation: Any = None
|
||||
deployments = self._rm_client.deployments
|
||||
try:
|
||||
deployment_operation = deployments.begin_create_or_update(
|
||||
**deployment_parameters
|
||||
deployment_operation = (
|
||||
deployments.begin_create_or_update_at_subscription_scope(
|
||||
**deployment_parameters
|
||||
)
|
||||
)
|
||||
result = wait_operation(deployment_operation)
|
||||
if result:
|
||||
|
|
Загрузка…
Ссылка в новой задаче