From 832d16b0f0f30e49ae7eee2829224faea2be0a4a Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Wed, 28 Oct 2020 21:27:21 +0530 Subject: [PATCH 01/33] Added wrapper template to create fileshare storage account for data migration --- deploy-migration-storage.json | 83 +++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 deploy-migration-storage.json diff --git a/deploy-migration-storage.json b/deploy-migration-storage.json new file mode 100644 index 00000000..c1e69a96 --- /dev/null +++ b/deploy-migration-storage.json @@ -0,0 +1,83 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "_artifactsLocation": { + "type": "string", + "metadata": { + "description": "The base URI where artifacts required by this template are located. When the template is deployed using the accompanying scripts, a private location in the subscription will be used and this value will be automatically generated." + }, + "defaultValue": "https://raw.githubusercontent.com/Azure/Moodle/master/" + }, + "_artifactsLocationSasToken": { + "type": "securestring", + "metadata": { + "description": "The sasToken required to access _artifactsLocation. When the template is deployed using the accompanying scripts, a sasToken will be automatically generated." + }, + "defaultValue": "" + }, + "fileServerType": { + "defaultValue": "azurefiles", + "allowedValues": [ + "azurefiles" + ], + "type": "String", + "metadata": { + "description": "File server type: Only Azure File is supported" + } + }, + "storageAccountType": { + "defaultValue": "Premium_LRS", + "allowedValues": [ + "Premium_LRS" + ], + "type": "String", + "metadata": { + "description": "Storage Account type. This storage account is for Azure Files file share option" + } + }, + "location": { + "type": "string", + "defaultValue": "[resourceGroup().location]", + "metadata": { + "description": "Azure Location for all resources." + } + } + }, + "variables": { + "moodleCommon": { + "baseTemplateUrl": "[concat(parameters('_artifactsLocation'), 'nested/')]", + "artifactsSasToken": "[parameters('_artifactsLocationSasToken')]", + "fileServerType": "[parameters('fileServerType')]", + "location": "[parameters('location')]", + "resourcesPrefix": "[variables('resourceprefix')]", + "storageAccountName": "[tolower(concat('abs',variables('resourceprefix')))]", + "storageAccountType": "[parameters('storageAccountType')]" + }, + "resourceprefix": "[substring(uniqueString(resourceGroup().id, deployment().name), 3, 6)]" + }, + "resources": [ + { + "type": "Microsoft.Resources/deployments", + "apiVersion": "2017-05-10", + "name": "AzureFilesStorageAccountTemplate", + "properties": { + "mode": "Incremental", + "parameters": { + "moodleCommon": { + "value": "[variables('moodleCommon')]" + } + }, + "templateLink": { + "uri": "[concat(variables('moodleCommon').baseTemplateUrl,'storageAccount.json',parameters('_artifactsLocationSasToken'))]" + } + } + } + ], + "outputs": { + "AzureFilesStorageAccountTemplate": { + "type": "object", + "value": "[reference('AzureFilesStorageAccountTemplate').outputs]" + } + } +} From a31aa46d2b5ff5c2baa40b7b7ac06efe4e1680d5 Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Thu, 29 Oct 2020 20:57:44 +0530 Subject: [PATCH 02/33] Seperated custom script extension from vmss template --- deploy-migration-storage.json | 83 ----------------------------------- nested/webvmss-setup.json | 38 ++++++++++++++++ nested/webvmss.json | 45 +++++++++---------- 3 files changed, 59 insertions(+), 107 deletions(-) delete mode 100644 deploy-migration-storage.json create mode 100644 nested/webvmss-setup.json diff --git a/deploy-migration-storage.json b/deploy-migration-storage.json deleted file mode 100644 index c1e69a96..00000000 --- a/deploy-migration-storage.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "_artifactsLocation": { - "type": "string", - "metadata": { - "description": "The base URI where artifacts required by this template are located. When the template is deployed using the accompanying scripts, a private location in the subscription will be used and this value will be automatically generated." - }, - "defaultValue": "https://raw.githubusercontent.com/Azure/Moodle/master/" - }, - "_artifactsLocationSasToken": { - "type": "securestring", - "metadata": { - "description": "The sasToken required to access _artifactsLocation. When the template is deployed using the accompanying scripts, a sasToken will be automatically generated." - }, - "defaultValue": "" - }, - "fileServerType": { - "defaultValue": "azurefiles", - "allowedValues": [ - "azurefiles" - ], - "type": "String", - "metadata": { - "description": "File server type: Only Azure File is supported" - } - }, - "storageAccountType": { - "defaultValue": "Premium_LRS", - "allowedValues": [ - "Premium_LRS" - ], - "type": "String", - "metadata": { - "description": "Storage Account type. This storage account is for Azure Files file share option" - } - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]", - "metadata": { - "description": "Azure Location for all resources." - } - } - }, - "variables": { - "moodleCommon": { - "baseTemplateUrl": "[concat(parameters('_artifactsLocation'), 'nested/')]", - "artifactsSasToken": "[parameters('_artifactsLocationSasToken')]", - "fileServerType": "[parameters('fileServerType')]", - "location": "[parameters('location')]", - "resourcesPrefix": "[variables('resourceprefix')]", - "storageAccountName": "[tolower(concat('abs',variables('resourceprefix')))]", - "storageAccountType": "[parameters('storageAccountType')]" - }, - "resourceprefix": "[substring(uniqueString(resourceGroup().id, deployment().name), 3, 6)]" - }, - "resources": [ - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2017-05-10", - "name": "AzureFilesStorageAccountTemplate", - "properties": { - "mode": "Incremental", - "parameters": { - "moodleCommon": { - "value": "[variables('moodleCommon')]" - } - }, - "templateLink": { - "uri": "[concat(variables('moodleCommon').baseTemplateUrl,'storageAccount.json',parameters('_artifactsLocationSasToken'))]" - } - } - } - ], - "outputs": { - "AzureFilesStorageAccountTemplate": { - "type": "object", - "value": "[reference('AzureFilesStorageAccountTemplate').outputs]" - } - } -} diff --git a/nested/webvmss-setup.json b/nested/webvmss-setup.json new file mode 100644 index 00000000..dc6acb1e --- /dev/null +++ b/nested/webvmss-setup.json @@ -0,0 +1,38 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "moodleCommon": { + "metadata": { + "description": "Common Moodle values" + }, + "type": "object" + } + }, + "resources": [ + { + "type": "Microsoft.Compute/virtualMachines/extensions", + "apiVersion": "2017-03-30", + "location": "[parameters('moodleCommon').location]", + "name": "[concat(parameters('moodleCommon').vmssName,'/','setup_moodle')]", + "properties": { + "autoUpgradeMinorVersion": true, + "publisher": "Microsoft.Azure.Extensions", + "settings": { + "fileUris": [ + "[variables('scriptUri')]", + "[parameters('moodleCommon').commonFunctionsScriptUri]" + ] + }, + "protectedSettings": { + "commandToExecute": "[concat('bash ', parameters('moodleCommon').webServerSetupScriptFilename, ' ', parameters('moodleCommon').moodleOnAzureConfigsJsonPath)]" + }, + "type": "CustomScript", + "typeHandlerVersion": "2.0" + } + } + ], + "variables": { + "scriptUri": "[concat(parameters('moodleCommon').scriptLocation,parameters('moodleCommon').webServerSetupScriptFilename,parameters('moodleCommon').artifactsSasToken)]" + } +} diff --git a/nested/webvmss.json b/nested/webvmss.json index bba69def..e24f1fe1 100644 --- a/nested/webvmss.json +++ b/nested/webvmss.json @@ -87,26 +87,7 @@ }, "virtualMachineProfile": { "extensionProfile": { - "extensions": [ - { - "name": "setup_moodle", - "properties": { - "autoUpgradeMinorVersion": true, - "publisher": "Microsoft.Azure.Extensions", - "settings": { - "fileUris": [ - "[variables('scriptUri')]", - "[parameters('moodleCommon').commonFunctionsScriptUri]" - ] - }, - "protectedSettings": { - "commandToExecute": "[concat('bash ', parameters('moodleCommon').webServerSetupScriptFilename, ' ', parameters('moodleCommon').moodleOnAzureConfigsJsonPath)]" - }, - "type": "CustomScript", - "typeHandlerVersion": "2.0" - } - } - ] + "extensions": [ ] }, "networkProfile": { "networkInterfaceConfigurations": [ @@ -171,6 +152,26 @@ "displayName": "webfarm" } }, + { + "condition": "[parameters('moodleCommon').applyScriptsSwitch]", + "type": "Microsoft.Resources/deployments", + "apiVersion": "2017-05-10", + "dependsOn": [ + "[concat('Microsoft.Compute/virtualMachineScaleSets/', parameters('moodleCommon').vmssName)]" + ], + "name": "[concat(parameters('moodleCommon').vmssName,'-ScriptProcessor')]", + "properties": { + "mode": "Incremental", + "parameters": { + "moodleCommon": { + "value": "[parameters('moodleCommon')]" + } + }, + "templateLink": { + "uri": "[concat(parameters('moodleCommon').baseTemplateUrl, 'webvmss-setup.json', parameters('moodleCommon').artifactsSasToken)]" + } + } + }, { "type": "Microsoft.Insights/autoscaleSettings", "apiVersion": "2015-04-01", @@ -238,12 +239,8 @@ ], "variables": { "singleQuote": "'", - "dstorID": "[resourceId('Microsoft.Storage/storageAccounts',parameters('moodleCommon').vmssdStorageAccounttName)]", "extBeID": "[concat(variables('extLbID'),'/backendAddressPools/',parameters('moodleCommon').extBeName)]", - "extFeID": "[concat(variables('extLbID'),'/frontendIPConfigurations/',parameters('moodleCommon').extFeName)]", "extLbID": "[resourceId('Microsoft.Network/loadBalancers',parameters('moodleCommon').lbName)]", - "pipID": "[resourceId('Microsoft.Network/publicIPAddresses',parameters('moodleCommon').lbPipName)]", - "scriptUri": "[concat(parameters('moodleCommon').scriptLocation,parameters('moodleCommon').webServerSetupScriptFilename,parameters('moodleCommon').artifactsSasToken)]", "vmssID": "[resourceId('Microsoft.Compute/virtualMachineScaleSets',parameters('moodleCommon').vmssName)]", "webvmss1NIC": "[concat('Microsoft.Compute/virtualMachineScaleSets/', parameters('moodleCommon').vmssName, '/virtualMachines/0/networkInterfaces/vmssnic')]", "appGwID": "[resourceId('Microsoft.Network/applicationGateways', parameters('moodleCommon').appGwName)]", From e5bfd70f1b03c31d6ea9ec317b6b280b9aef311a Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Thu, 29 Oct 2020 21:31:44 +0530 Subject: [PATCH 03/33] Fixed the type propety value in webvmss-setup.json template --- nested/webvmss-setup.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nested/webvmss-setup.json b/nested/webvmss-setup.json index dc6acb1e..cd333fb1 100644 --- a/nested/webvmss-setup.json +++ b/nested/webvmss-setup.json @@ -11,7 +11,7 @@ }, "resources": [ { - "type": "Microsoft.Compute/virtualMachines/extensions", + "type": "Microsoft.Compute/virtualMachineScaleSets/extensions", "apiVersion": "2017-03-30", "location": "[parameters('moodleCommon').location]", "name": "[concat(parameters('moodleCommon').vmssName,'/','setup_moodle')]", From 5dd8a5083d66811d6a20bb5255a7632813f110c9 Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Fri, 22 Jan 2021 18:15:28 +0530 Subject: [PATCH 04/33] Reverted the custom script extension seperation logic --- nested/webvmss-setup.json | 38 --------------------------------- nested/webvmss.json | 45 +++++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 59 deletions(-) delete mode 100644 nested/webvmss-setup.json diff --git a/nested/webvmss-setup.json b/nested/webvmss-setup.json deleted file mode 100644 index cd333fb1..00000000 --- a/nested/webvmss-setup.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "moodleCommon": { - "metadata": { - "description": "Common Moodle values" - }, - "type": "object" - } - }, - "resources": [ - { - "type": "Microsoft.Compute/virtualMachineScaleSets/extensions", - "apiVersion": "2017-03-30", - "location": "[parameters('moodleCommon').location]", - "name": "[concat(parameters('moodleCommon').vmssName,'/','setup_moodle')]", - "properties": { - "autoUpgradeMinorVersion": true, - "publisher": "Microsoft.Azure.Extensions", - "settings": { - "fileUris": [ - "[variables('scriptUri')]", - "[parameters('moodleCommon').commonFunctionsScriptUri]" - ] - }, - "protectedSettings": { - "commandToExecute": "[concat('bash ', parameters('moodleCommon').webServerSetupScriptFilename, ' ', parameters('moodleCommon').moodleOnAzureConfigsJsonPath)]" - }, - "type": "CustomScript", - "typeHandlerVersion": "2.0" - } - } - ], - "variables": { - "scriptUri": "[concat(parameters('moodleCommon').scriptLocation,parameters('moodleCommon').webServerSetupScriptFilename,parameters('moodleCommon').artifactsSasToken)]" - } -} diff --git a/nested/webvmss.json b/nested/webvmss.json index e24f1fe1..bba69def 100644 --- a/nested/webvmss.json +++ b/nested/webvmss.json @@ -87,7 +87,26 @@ }, "virtualMachineProfile": { "extensionProfile": { - "extensions": [ ] + "extensions": [ + { + "name": "setup_moodle", + "properties": { + "autoUpgradeMinorVersion": true, + "publisher": "Microsoft.Azure.Extensions", + "settings": { + "fileUris": [ + "[variables('scriptUri')]", + "[parameters('moodleCommon').commonFunctionsScriptUri]" + ] + }, + "protectedSettings": { + "commandToExecute": "[concat('bash ', parameters('moodleCommon').webServerSetupScriptFilename, ' ', parameters('moodleCommon').moodleOnAzureConfigsJsonPath)]" + }, + "type": "CustomScript", + "typeHandlerVersion": "2.0" + } + } + ] }, "networkProfile": { "networkInterfaceConfigurations": [ @@ -152,26 +171,6 @@ "displayName": "webfarm" } }, - { - "condition": "[parameters('moodleCommon').applyScriptsSwitch]", - "type": "Microsoft.Resources/deployments", - "apiVersion": "2017-05-10", - "dependsOn": [ - "[concat('Microsoft.Compute/virtualMachineScaleSets/', parameters('moodleCommon').vmssName)]" - ], - "name": "[concat(parameters('moodleCommon').vmssName,'-ScriptProcessor')]", - "properties": { - "mode": "Incremental", - "parameters": { - "moodleCommon": { - "value": "[parameters('moodleCommon')]" - } - }, - "templateLink": { - "uri": "[concat(parameters('moodleCommon').baseTemplateUrl, 'webvmss-setup.json', parameters('moodleCommon').artifactsSasToken)]" - } - } - }, { "type": "Microsoft.Insights/autoscaleSettings", "apiVersion": "2015-04-01", @@ -239,8 +238,12 @@ ], "variables": { "singleQuote": "'", + "dstorID": "[resourceId('Microsoft.Storage/storageAccounts',parameters('moodleCommon').vmssdStorageAccounttName)]", "extBeID": "[concat(variables('extLbID'),'/backendAddressPools/',parameters('moodleCommon').extBeName)]", + "extFeID": "[concat(variables('extLbID'),'/frontendIPConfigurations/',parameters('moodleCommon').extFeName)]", "extLbID": "[resourceId('Microsoft.Network/loadBalancers',parameters('moodleCommon').lbName)]", + "pipID": "[resourceId('Microsoft.Network/publicIPAddresses',parameters('moodleCommon').lbPipName)]", + "scriptUri": "[concat(parameters('moodleCommon').scriptLocation,parameters('moodleCommon').webServerSetupScriptFilename,parameters('moodleCommon').artifactsSasToken)]", "vmssID": "[resourceId('Microsoft.Compute/virtualMachineScaleSets',parameters('moodleCommon').vmssName)]", "webvmss1NIC": "[concat('Microsoft.Compute/virtualMachineScaleSets/', parameters('moodleCommon').vmssName, '/virtualMachines/0/networkInterfaces/vmssnic')]", "appGwID": "[resourceId('Microsoft.Network/applicationGateways', parameters('moodleCommon').appGwName)]", From 79aefdda9a3fe72abce8baa914740b147a061643 Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Fri, 22 Jan 2021 23:58:23 +0530 Subject: [PATCH 05/33] provision to create azure fileshare storage account independently --- azuredeploy.json | 10 ++- nested/azure-fileshare-sa-deploy.json | 113 ++++++++++++++++++++++++++ nested/storageAccount.json | 41 +++++++++- 3 files changed, 161 insertions(+), 3 deletions(-) create mode 100644 nested/azure-fileshare-sa-deploy.json diff --git a/azuredeploy.json b/azuredeploy.json index 446bf495..71eae9f2 100644 --- a/azuredeploy.json +++ b/azuredeploy.json @@ -506,6 +506,14 @@ }, "type": "string" }, + "storageAccountNamePrefix": { + "defaultValue":"", + "maxLength": 15, + "metadata": { + "description": "Storage account name prefix. Instread of unsing random prefix, this value will be used to construct storage account name" + }, + "type": "string" + }, "searchType": { "defaultValue": "none", "allowedValues": [ @@ -1193,7 +1201,7 @@ "sshPublicKey": "[parameters('sshPublicKey')]", "sshUsername": "[parameters('sshUsername')]", "sslEnforcement": "[parameters('sslEnforcement')]", - "storageAccountName": "[tolower(concat('abs',variables('resourceprefix')))]", + "storageAccountName": "[if(empty(parameters('storageAccountNamePrefix')), concat('abs', variables('resourceprefix')), parameters('storageAccountNamePrefix'))]", "storageAccountType": "[parameters('storageAccountType')]", "subnetAppGw": "[concat('appgw-subnet-',variables('resourceprefix'))]", "subnetAppGwPrefix": "[concat(variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),6)))]", diff --git a/nested/azure-fileshare-sa-deploy.json b/nested/azure-fileshare-sa-deploy.json new file mode 100644 index 00000000..fb1c26cf --- /dev/null +++ b/nested/azure-fileshare-sa-deploy.json @@ -0,0 +1,113 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "_artifactsLocation": { + "type": "string", + "metadata": { + "description": "The base URI where artifacts required by this template are located." + }, + "defaultValue": "https://github.com/venu-sivanadham/Moodle/blob/master/" + }, + "_artifactsLocationSasToken": { + "type": "securestring", + "metadata": { + "description": "The sasToken required to access _artifactsLocation. When the template is deployed using the accompanying scripts, a sasToken will be automatically generated." + }, + "defaultValue": "" + }, + "storageAccountType": { + "defaultValue": "Premium_LRS", + "allowedValues": [ + "Standard_LRS", + "Standard_GRS", + "Standard_ZRS", + "Premium_LRS" + ], + "metadata": { + "description": "Storage Account type." + }, + "type": "string" + }, + "storageAccountNamePrefix": { + "defaultValue":"[substring(uniqueString(resourceGroup().id), 3, 12)]", + "maxLength": 15, + "metadata": { + "description": "Storage account name prefix. Instread of unsing random prefix, this value will be used to construct storage account name" + }, + "type": "string" + }, + "fileServerDiskSize": { + "defaultValue": 100, + "metadata": { + "description": "Size of the azure file share in GB." + }, + "type": "int" + }, + "location": { + "type": "string", + "defaultValue": "[resourceGroup().location]", + "metadata": { + "description": "Azure Location for all resources." + } + } + }, + "resources": [ + { + "type": "Microsoft.Resources/deployments", + "apiVersion": "2017-05-10", + "name": "pid-738e3eec-68d4-4667-8377-c05c77c21f1b", + "properties": { + "mode": "Incremental", + "template": { + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "resources": [] + } + } + }, + { + "type": "Microsoft.Resources/deployments", + "apiVersion": "2017-05-10", + "name": "storageAccountTemplate", + "properties": { + "mode": "Incremental", + "parameters": { + "moodleCommon": { + "value": "[variables('moodleCommon')]" + } + }, + "templateLink": { + "uri": "[concat(variables('moodleCommon').baseTemplateUrl,'storageAccount.json',parameters('_artifactsLocationSasToken'))]" + } + } + } + ], + "outputs": { + "storageAccountName": { + "type": "string", + "value": "[variables('moodleCommon').storageAccountName]" + }, + "storageAccountType": { + "type": "string", + "value": "[variables('moodleCommon').storageAccountType]" + }, + "fileServerDiskSize": { + "type": "string", + "value": "[variables('moodleCommon').fileServerDiskSize]" + } + }, + "variables": { + "moodleCommon": { + "baseTemplateUrl": "[concat(parameters('_artifactsLocation'), 'nested/')]", + "scriptLocation": "[concat(parameters('_artifactsLocation'), 'scripts/')]", + "artifactsSasToken": "[parameters('_artifactsLocationSasToken')]", + "fileServerType": "azurefiles", + "azureFileshareName": "moodle", + "location": "[parameters('location')]", + "storageAccountName": "[parameters('storageAccountNamePrefix')]", + "storageAccountType": "[parameters('storageAccountType')]", + "fileServerDiskSize": "[parameters('fileServerDiskSize')]" + } + } +} diff --git a/nested/storageAccount.json b/nested/storageAccount.json index bbdbafe8..2cc4e50b 100644 --- a/nested/storageAccount.json +++ b/nested/storageAccount.json @@ -15,7 +15,7 @@ "type": "Microsoft.Storage/storageAccounts", "apiVersion": "2019-06-01", "location": "[parameters('moodleCommon').location]", - "name": "[concat(parameters('moodleCommon').storageAccountName,'naf')]", + "name": "[variables('storageName')]", "kind": "Storage", "sku": { "name": "[parameters('moodleCommon').storageAccountType]" @@ -46,7 +46,7 @@ "type": "Microsoft.Storage/storageAccounts", "apiVersion": "2019-06-01", "location": "[parameters('moodleCommon').location]", - "name": "[concat(parameters('moodleCommon').storageAccountName,'af')]", + "name": "[variables('storageName')]", "kind": "[if(equals(parameters('moodleCommon').storageAccountType, 'Premium_LRS'), 'FileStorage', 'Storage')]", "sku": { "name": "[parameters('moodleCommon').storageAccountType]" @@ -74,12 +74,49 @@ "keySource": "Microsoft.Storage" } } + }, + { + "condition": "[equals(parameters('moodleCommon').azureFileshareName, 'moodle')]", + "type": "Microsoft.Storage/storageAccounts/fileServices", + "apiVersion": "2019-06-01", + "name": "[concat(variables('storageName'), '/default')]", + "dependsOn": [ + "[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]" + ], + "sku": { + "name": "[parameters('moodleCommon').storageAccountType]", + "tier": "[if(equals(parameters('moodleCommon').storageAccountType, 'Premium_LRS'),'Premium', 'Standard')]" + }, + "properties": { + "protocolSettings": { + "smb": {} + }, + "cors": { + "corsRules": [] + } + } + }, + { + "condition": "[equals(parameters('moodleCommon').azureFileshareName, 'moodle')]", + "type": "Microsoft.Storage/storageAccounts/fileServices/shares", + "apiVersion": "2019-06-01", + "name": "[concat(variables('storageName'), '/default/moodle')]", + "dependsOn": [ + "[resourceId('Microsoft.Storage/storageAccounts/fileServices', variables('storageName'), 'default')]", + "[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]" + ], + "properties": { + "accessTier": "[if(equals(parameters('moodleCommon').storageAccountType, 'Premium_LRS'), 'Premium', 'TransactionOptimized')]", + "shareQuota": "[int(parameters('moodleCommon').fileServerDiskSize)]", + "enabledProtocols": "SMB" + } } ], "variables": { "documentation1": "This sub-template creates a storage account. It expects certain values in the 'common' datastructure.", "documentation2": " storageAccountName - name of storage account", "documentation3": " storageAccountType - type of storage account", + "documentation4": " azureFileshareName - name of the azure files that needs to be created along with fileshare storage account. This value is introduced to support migration scenario, and it optional for fresh deployments.", "storageName": "[concat(parameters('moodleCommon').storageAccountName,if(equals(parameters('moodleCommon').fileServerType, 'azurefiles'), 'af', 'naf'))]", "storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]" }, From cb5e8acb923d62b3dbc4722e96546a059c441fb6 Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Fri, 22 Jan 2021 23:59:46 +0530 Subject: [PATCH 06/33] provision to create azure fileshare storage account independently --- nested/azure-fileshare-sa-deploy.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nested/azure-fileshare-sa-deploy.json b/nested/azure-fileshare-sa-deploy.json index fb1c26cf..ac82edef 100644 --- a/nested/azure-fileshare-sa-deploy.json +++ b/nested/azure-fileshare-sa-deploy.json @@ -7,7 +7,7 @@ "metadata": { "description": "The base URI where artifacts required by this template are located." }, - "defaultValue": "https://github.com/venu-sivanadham/Moodle/blob/master/" + "defaultValue": "https://github.com/venu-sivanadham/Moodle/blob/MigrationDevelop/" }, "_artifactsLocationSasToken": { "type": "securestring", From f3e8a1c2e210bf11babf9d967d4bcd8c60c2923f Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Sat, 23 Jan 2021 00:30:40 +0530 Subject: [PATCH 07/33] relocated file share storage account deployment template --- ...loy.json => azure-fileshare-sa-deploy.json | 26 +++---------------- azuredeploy.json | 10 +------ 2 files changed, 4 insertions(+), 32 deletions(-) rename nested/azure-fileshare-sa-deploy.json => azure-fileshare-sa-deploy.json (77%) diff --git a/nested/azure-fileshare-sa-deploy.json b/azure-fileshare-sa-deploy.json similarity index 77% rename from nested/azure-fileshare-sa-deploy.json rename to azure-fileshare-sa-deploy.json index ac82edef..1acd64a3 100644 --- a/nested/azure-fileshare-sa-deploy.json +++ b/azure-fileshare-sa-deploy.json @@ -29,14 +29,6 @@ }, "type": "string" }, - "storageAccountNamePrefix": { - "defaultValue":"[substring(uniqueString(resourceGroup().id), 3, 12)]", - "maxLength": 15, - "metadata": { - "description": "Storage account name prefix. Instread of unsing random prefix, this value will be used to construct storage account name" - }, - "type": "string" - }, "fileServerDiskSize": { "defaultValue": 100, "metadata": { @@ -53,19 +45,6 @@ } }, "resources": [ - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2017-05-10", - "name": "pid-738e3eec-68d4-4667-8377-c05c77c21f1b", - "properties": { - "mode": "Incremental", - "template": { - "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "resources": [] - } - } - }, { "type": "Microsoft.Resources/deployments", "apiVersion": "2017-05-10", @@ -105,9 +84,10 @@ "fileServerType": "azurefiles", "azureFileshareName": "moodle", "location": "[parameters('location')]", - "storageAccountName": "[parameters('storageAccountNamePrefix')]", + "storageAccountName": "[tolower(concat('abs',variables('resourceprefix')))]", "storageAccountType": "[parameters('storageAccountType')]", "fileServerDiskSize": "[parameters('fileServerDiskSize')]" - } + }, + "resourceprefix": "[substring(uniqueString(resourceGroup().id, 'mainTemplate'), 3, 6)]" } } diff --git a/azuredeploy.json b/azuredeploy.json index 71eae9f2..446bf495 100644 --- a/azuredeploy.json +++ b/azuredeploy.json @@ -506,14 +506,6 @@ }, "type": "string" }, - "storageAccountNamePrefix": { - "defaultValue":"", - "maxLength": 15, - "metadata": { - "description": "Storage account name prefix. Instread of unsing random prefix, this value will be used to construct storage account name" - }, - "type": "string" - }, "searchType": { "defaultValue": "none", "allowedValues": [ @@ -1201,7 +1193,7 @@ "sshPublicKey": "[parameters('sshPublicKey')]", "sshUsername": "[parameters('sshUsername')]", "sslEnforcement": "[parameters('sslEnforcement')]", - "storageAccountName": "[if(empty(parameters('storageAccountNamePrefix')), concat('abs', variables('resourceprefix')), parameters('storageAccountNamePrefix'))]", + "storageAccountName": "[tolower(concat('abs',variables('resourceprefix')))]", "storageAccountType": "[parameters('storageAccountType')]", "subnetAppGw": "[concat('appgw-subnet-',variables('resourceprefix'))]", "subnetAppGwPrefix": "[concat(variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),6)))]", From 0ac4804c56e6d92ccc2d98a574ff1904a2f94b72 Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Sat, 23 Jan 2021 01:05:53 +0530 Subject: [PATCH 08/33] fixed storage account name arguments --- azure-fileshare-sa-deploy.json | 2 +- nested/storageAccount.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-fileshare-sa-deploy.json b/azure-fileshare-sa-deploy.json index 1acd64a3..2b6789be 100644 --- a/azure-fileshare-sa-deploy.json +++ b/azure-fileshare-sa-deploy.json @@ -7,7 +7,7 @@ "metadata": { "description": "The base URI where artifacts required by this template are located." }, - "defaultValue": "https://github.com/venu-sivanadham/Moodle/blob/MigrationDevelop/" + "defaultValue": "https://raw.githubusercontent.com/venu-sivanadham/Moodle/MigrationDevelop/" }, "_artifactsLocationSasToken": { "type": "securestring", diff --git a/nested/storageAccount.json b/nested/storageAccount.json index 2cc4e50b..17435166 100644 --- a/nested/storageAccount.json +++ b/nested/storageAccount.json @@ -15,7 +15,7 @@ "type": "Microsoft.Storage/storageAccounts", "apiVersion": "2019-06-01", "location": "[parameters('moodleCommon').location]", - "name": "[variables('storageName')]", + "name": "[concat(parameters('moodleCommon').storageAccountName,'naf')]", "kind": "Storage", "sku": { "name": "[parameters('moodleCommon').storageAccountType]" @@ -46,7 +46,7 @@ "type": "Microsoft.Storage/storageAccounts", "apiVersion": "2019-06-01", "location": "[parameters('moodleCommon').location]", - "name": "[variables('storageName')]", + "name": "[concat(parameters('moodleCommon').storageAccountName,'af')]", "kind": "[if(equals(parameters('moodleCommon').storageAccountType, 'Premium_LRS'), 'FileStorage', 'Storage')]", "sku": { "name": "[parameters('moodleCommon').storageAccountType]" From 17993ed4055e4c6a641136b806c61ce8a8f148c3 Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Sat, 23 Jan 2021 01:40:16 +0530 Subject: [PATCH 09/33] restored original storage account template --- azure-fileshare-sa-deploy.json | 22 +++++++++++++++----- nested/storageAccount.json | 37 ---------------------------------- 2 files changed, 17 insertions(+), 42 deletions(-) diff --git a/azure-fileshare-sa-deploy.json b/azure-fileshare-sa-deploy.json index 2b6789be..71884f9d 100644 --- a/azure-fileshare-sa-deploy.json +++ b/azure-fileshare-sa-deploy.json @@ -7,7 +7,7 @@ "metadata": { "description": "The base URI where artifacts required by this template are located." }, - "defaultValue": "https://raw.githubusercontent.com/venu-sivanadham/Moodle/MigrationDevelop/" + "defaultValue": "https://raw.githubusercontent.com/Azure/Moodle/master/" }, "_artifactsLocationSasToken": { "type": "securestring", @@ -60,6 +60,19 @@ "uri": "[concat(variables('moodleCommon').baseTemplateUrl,'storageAccount.json',parameters('_artifactsLocationSasToken'))]" } } + }, + { + "type": "Microsoft.Storage/storageAccounts/fileServices/shares", + "apiVersion": "2019-06-01", + "name": "[concat(variables('storageName'), '/default/moodle')]", + "dependsOn": [ + "Microsoft.Resources/deployments/storageAccountTemplate" + ], + "properties": { + "accessTier": "[if(equals(variables('moodleCommon').storageAccountType, 'Premium_LRS'), 'Premium', 'TransactionOptimized')]", + "shareQuota": "[int(variables('moodleCommon').fileServerDiskSize)]", + "enabledProtocols": "SMB" + } } ], "outputs": { @@ -72,22 +85,21 @@ "value": "[variables('moodleCommon').storageAccountType]" }, "fileServerDiskSize": { - "type": "string", + "type": "int", "value": "[variables('moodleCommon').fileServerDiskSize]" } }, "variables": { "moodleCommon": { "baseTemplateUrl": "[concat(parameters('_artifactsLocation'), 'nested/')]", - "scriptLocation": "[concat(parameters('_artifactsLocation'), 'scripts/')]", "artifactsSasToken": "[parameters('_artifactsLocationSasToken')]", "fileServerType": "azurefiles", - "azureFileshareName": "moodle", "location": "[parameters('location')]", "storageAccountName": "[tolower(concat('abs',variables('resourceprefix')))]", "storageAccountType": "[parameters('storageAccountType')]", "fileServerDiskSize": "[parameters('fileServerDiskSize')]" }, - "resourceprefix": "[substring(uniqueString(resourceGroup().id, 'mainTemplate'), 3, 6)]" + "resourceprefix": "[substring(uniqueString(resourceGroup().id, 'mainTemplate'), 3, 6)]", + "storageName": "[concat(variables('moodleCommon').storageAccountName,if(equals(variables('moodleCommon').fileServerType, 'azurefiles'), 'af', 'naf'))]" } } diff --git a/nested/storageAccount.json b/nested/storageAccount.json index 17435166..bbdbafe8 100644 --- a/nested/storageAccount.json +++ b/nested/storageAccount.json @@ -74,49 +74,12 @@ "keySource": "Microsoft.Storage" } } - }, - { - "condition": "[equals(parameters('moodleCommon').azureFileshareName, 'moodle')]", - "type": "Microsoft.Storage/storageAccounts/fileServices", - "apiVersion": "2019-06-01", - "name": "[concat(variables('storageName'), '/default')]", - "dependsOn": [ - "[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]" - ], - "sku": { - "name": "[parameters('moodleCommon').storageAccountType]", - "tier": "[if(equals(parameters('moodleCommon').storageAccountType, 'Premium_LRS'),'Premium', 'Standard')]" - }, - "properties": { - "protocolSettings": { - "smb": {} - }, - "cors": { - "corsRules": [] - } - } - }, - { - "condition": "[equals(parameters('moodleCommon').azureFileshareName, 'moodle')]", - "type": "Microsoft.Storage/storageAccounts/fileServices/shares", - "apiVersion": "2019-06-01", - "name": "[concat(variables('storageName'), '/default/moodle')]", - "dependsOn": [ - "[resourceId('Microsoft.Storage/storageAccounts/fileServices', variables('storageName'), 'default')]", - "[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]" - ], - "properties": { - "accessTier": "[if(equals(parameters('moodleCommon').storageAccountType, 'Premium_LRS'), 'Premium', 'TransactionOptimized')]", - "shareQuota": "[int(parameters('moodleCommon').fileServerDiskSize)]", - "enabledProtocols": "SMB" - } } ], "variables": { "documentation1": "This sub-template creates a storage account. It expects certain values in the 'common' datastructure.", "documentation2": " storageAccountName - name of storage account", "documentation3": " storageAccountType - type of storage account", - "documentation4": " azureFileshareName - name of the azure files that needs to be created along with fileshare storage account. This value is introduced to support migration scenario, and it optional for fresh deployments.", "storageName": "[concat(parameters('moodleCommon').storageAccountName,if(equals(parameters('moodleCommon').fileServerType, 'azurefiles'), 'af', 'naf'))]", "storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]" }, From 6dfd3cfbd99368997f314daba29bbd9d7b127b3c Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Sat, 23 Jan 2021 10:56:48 +0530 Subject: [PATCH 10/33] dedicated entry point templates for migration --- azuredeploy.json | 10 +- .../azure-fileshare-sa-deploy.json | 0 migration/azuredeploy-migration.json | 276 ++++++++++++++++++ nested/vmsetupparams.json | 3 +- 4 files changed, 287 insertions(+), 2 deletions(-) rename azure-fileshare-sa-deploy.json => migration/azure-fileshare-sa-deploy.json (100%) create mode 100644 migration/azuredeploy-migration.json diff --git a/azuredeploy.json b/azuredeploy.json index 446bf495..38b1c546 100644 --- a/azuredeploy.json +++ b/azuredeploy.json @@ -653,6 +653,13 @@ "metadata": { "description": "Azure Location for all resources." } + }, + "isMigration": { + "type": "bool", + "defaultValue": false, + "metadata": { + "description": "Indicates whether the this template is using for migration scenario." + } } }, "resources": [ @@ -1232,7 +1239,8 @@ "vnetName": "[concat('vnet-',variables('resourceprefix'))]", "vpnType": "[parameters('vpnType')]", "webServerSetupScriptFilename": "setup_webserver.sh", - "webServerType": "[parameters('webServerType')]" + "webServerType": "[parameters('webServerType')]", + "isMigration": "[parameters('isMigration')]" }, "certUrlArray": [ { diff --git a/azure-fileshare-sa-deploy.json b/migration/azure-fileshare-sa-deploy.json similarity index 100% rename from azure-fileshare-sa-deploy.json rename to migration/azure-fileshare-sa-deploy.json diff --git a/migration/azuredeploy-migration.json b/migration/azuredeploy-migration.json new file mode 100644 index 00000000..3b0ae8e5 --- /dev/null +++ b/migration/azuredeploy-migration.json @@ -0,0 +1,276 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "_artifactsLocation": { + "type": "string", + "metadata": { + "description": "The base URI where artifacts required by this template are located. When the template is deployed using the accompanying scripts, a private location in the subscription will be used and this value will be automatically generated." + }, + "defaultValue": "https://raw.githubusercontent.com/venu-sivanadham/Moodle/MigrationDevelop/" + }, + "_artifactsLocationSasToken": { + "type": "securestring", + "metadata": { + "description": "The sasToken required to access _artifactsLocation. When the template is deployed using the accompanying scripts, a sasToken will be automatically generated." + }, + "defaultValue": "" + }, + "redisDeploySwitch": { + "defaultValue": false, + "metadata": { + "description": "Switch to deploy a redis cache or not. Note that certain versions of Moodle (e.g., 3.1) don't work well with Redis, so use this only for known well-working Moodle versions (e.g., 3.4)." + }, + "type": "bool" + }, + "httpsTermination": { + "allowedValues": [ + "VMSS", + "AppGw", + "None" + ], + "defaultValue": "VMSS", + "metadata": { + "description": "Indicates where https termination occurs. 'VMSS' is for https termination at the VMSS instance VMs (using nginx https proxy). 'AppGw' is for https termination with an Azure Application Gateway. When selecting this, you need to specify all appGw* parameters. 'None' is for testing only with no https. 'None' may not be used with a separately configured https termination layer. If you want to use the 'None' option with your separately configured https termination layer, you'll need to update your Moodle config.php manually for $cfg->wwwroot and $cfg->sslproxy." + }, + "type": "string" + }, + "siteURL": { + "metadata": { + "description": "URL for Moodle site" + }, + "type": "string" + }, + "moodleVersion": { + "allowedValues": [ + "MOODLE_39_STABLE", + "MOODLE_38_STABLE" + ], + "defaultValue": "MOODLE_38_STABLE", + "metadata": { + "description": "The Moodle version you want to install." + }, + "type": "string" + }, + "sshPublicKey": { + "metadata": { + "description": "ssh public key" + }, + "type": "string" + }, + "controllerVmSku": { + "defaultValue": "Standard_DS1_v2", + "metadata": { + "description": "VM size for the controller VM" + }, + "type": "string" + }, + "webServerType": { + "defaultValue": "nginx", + "allowedValues": [ + "apache", + "nginx" + ], + "metadata": { + "description": "Web server type" + }, + "type": "string" + }, + "autoscaleVmSku": { + "defaultValue": "Standard_DS2_v2", + "metadata": { + "description": "VM size for autoscaled web VMs" + }, + "type": "string" + }, + "autoscaleVmCountMax": { + "defaultValue": 10, + "metadata": { + "description": "Maximum number of autoscaled web VMs" + }, + "type": "int" + }, + "dbServerType": { + "defaultValue": "mysql", + "allowedValues": [ + "postgres", + "mysql" + ], + "metadata": { + "description": "Database type" + }, + "type": "string" + }, + "dbLogin": { + "defaultValue": "dbadmin", + "metadata": { + "description": "Database admin username" + }, + "type": "string" + }, + "mysqlPgresVcores": { + "allowedValues": [ + 1, + 2, + 4, + 8, + 16, + 32 + ], + "defaultValue": 2, + "metadata": { + "description": "MySql/Postgresql vCores. For Basic tier, only 1 & 2 are allowed. For GeneralPurpose tier, 2, 4, 8, 16, 32 are allowed. For MemoryOptimized, 2, 4, 8, 16 are allowed." + }, + "type": "int" + }, + "mysqlPgresStgSizeGB": { + "defaultValue": 125, + "minValue": 5, + "maxValue": 1024, + "metadata": { + "description": "MySql/Postgresql storage size in GB. Minimum 5GB, increase by 1GB, up to 1TB (1024 GB)" + }, + "type": "int" + }, + "mysqlPgresSkuTier": { + "allowedValues": [ + "Basic", + "GeneralPurpose", + "MemoryOptimized" + ], + "defaultValue": "GeneralPurpose", + "metadata": { + "description": "MySql/Postgresql sku tier" + }, + "type": "string" + }, + "mysqlPgresSkuHwFamily": { + "allowedValues": [ + "Gen4", + "Gen5" + ], + "defaultValue": "Gen5", + "metadata": { + "description": "MySql/Postgresql sku hardware family. Central US is Gen4 only, so make sure to change this parameter to Gen4 if your deployment is on Central US." + }, + "type": "string" + }, + "mysqlVersion": { + "allowedValues": [ + "5.6", + "5.7" + ], + "defaultValue": "5.7", + "metadata": { + "description": "Mysql version" + }, + "type": "string" + }, + "postgresVersion": { + "allowedValues": [ + "9.5", + "9.6" + ], + "defaultValue": "9.6", + "metadata": { + "description": "Postgresql version" + }, + "type": "string" + }, + "fileServerDiskSize": { + "defaultValue": 100, + "metadata": { + "description": "Size per disk for gluster nodes or nfs server" + }, + "type": "int" + }, + "searchType": { + "defaultValue": "none", + "allowedValues": [ + "none", + "azure", + "elastic" + ], + "metadata": { + "description": "options of moodle global search" + }, + "type": "string" + }, + "azureSearchSku": { + "defaultValue": "basic", + "allowedValues": [ + "free", + "basic", + "standard", + "standard2", + "standard3" + ], + "metadata": { + "description": "the search service level you want to create." + }, + "type": "string" + }, + "vNetAddressSpace": { + "defaultValue": "172.31.0.0", + "metadata": { + "description": "Address range for the Moodle virtual network and various subnets - presumed /16 for a newly created vnet in case customVnetId is blank. Further subneting (a number of */24 subnets starting from the xxx.yyy.zzz.0/24 will be created on a newly created vnet or your BYO-vnet (specified in customVnetId parameter)." + }, + "type": "string" + }, + "ubuntuVersion": { + "type": "string", + "allowedValues": [ + "18.04-LTS" + ], + "defaultValue": "18.04-LTS" + } + }, + "resources": [ + { + "type": "Microsoft.Resources/deployments", + "apiVersion": "2017-05-10", + "name": "mainTemplate", + "properties": { + "mode": "Incremental", + "parameters": { + "_artifactsLocation": { "value": "[parameters('_artifactsLocation')]" }, + "_artifactsLocationSasToken": { "value": "[parameters('_artifactsLocationSasToken')]" }, + "redisDeploySwitch": { "value": "[parameters('redisDeploySwitch')]" }, + "httpsTermination": { "value": "[parameters('httpsTermination')]"}, + "siteURL": { "value": "[parameters('siteURL')]"}, + "moodleVersion": { "value": "[parameters('moodleVersion')]"}, + "sshPublicKey": { "value": "[parameters('sshPublicKey')]" }, + "controllerVmSku": { "value": "[parameters('controllerVmSku')]"}, + "webServerType": { "value": "[parameters('webServerType')]"}, + "autoscaleVmSku": { "value": "[parameters('autoscaleVmSku')]" }, + "autoscaleVmCountMax": { "value": "[parameters('autoscaleVmCountMax')]" }, + "dbServerType": { "value": "[parameters('dbServerType')]" }, + "dbLogin": { "value": "[parameters('dbLogin')]" }, + "mysqlPgresVcores": { "value": "[parameters('mysqlPgresVcores')]" }, + "mysqlPgresStgSizeGB": { "value": "[parameters('mysqlPgresStgSizeGB')]" }, + "mysqlPgresSkuTier": { "value": "[parameters('mysqlPgresSkuTier')]" }, + "mysqlPgresSkuHwFamily": { "value": "[parameters('mysqlPgresSkuHwFamily')]" }, + "mysqlVersion": { "value": "[parameters('mysqlVersion')]" }, + "postgresVersion": { "value": "[parameters('postgresVersion')]" }, + "fileServerType": { "value": "azurefiles" }, + "storageAccountType": { "value": "Premium_LRS" }, + "fileServerDiskSize": { "value": "[parameters('fileServerDiskSize')]" }, + "searchType": { "value": "[parameters('searchType')]" }, + "azureSearchSku": { "value": "[parameters('azureSearchSku')]" }, + "vNetAddressSpace": { "value": "[parameters('vNetAddressSpace')]"}, + "ubuntuVersion": { "value": "[parameters('ubuntuVersion')]"}, + "isMigration": { "value": true } + }, + "templateLink": { + "uri": "[concat(parameters('_artifactsLocation'), 'azuredeploy.json', parameters('_artifactsLocationSasToken'))]" + } + } + } + ], + "outputs": { + "mainTemplateOutputs": { + "type": "object", + "value": "[reference('mainTemplate').outputs]" + } + } +} diff --git a/nested/vmsetupparams.json b/nested/vmsetupparams.json index 26f92402..dc17f9b9 100644 --- a/nested/vmsetupparams.json +++ b/nested/vmsetupparams.json @@ -71,7 +71,8 @@ "tikaVmIP": "[parameters('moodleCommon').tikaVmIP]", "syslogServer": "[parameters('moodleCommon').ctlrVmName]", "webServerType": "[parameters('moodleCommon').webServerType]", - "htmlLocalCopySwitch": "[parameters('moodleCommon').htmlLocalCopySwitch]" + "htmlLocalCopySwitch": "[parameters('moodleCommon').htmlLocalCopySwitch]", + "isMigration": "[parameters('moodleCommon').isMigration]" }, "dbServerProfile": { "type": "[parameters('moodleCommon').dbServerType]", From 78753cc0a2b99f23ac3304e951c0f018d1b1909d Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Sat, 23 Jan 2021 16:23:38 +0530 Subject: [PATCH 11/33] fixed parameter alignment for migration template --- migration/azuredeploy-migration.json | 29 +++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/migration/azuredeploy-migration.json b/migration/azuredeploy-migration.json index 3b0ae8e5..a16677b9 100644 --- a/migration/azuredeploy-migration.json +++ b/migration/azuredeploy-migration.json @@ -35,6 +35,17 @@ }, "type": "string" }, + "loadBalancerSku": { + "defaultValue": "Basic", + "allowedValues": [ + "Basic", + "Standard" + ], + "metadata": { + "description": "Loadbalancer SKU" + }, + "type": "string" + }, "siteURL": { "metadata": { "description": "URL for Moodle site" @@ -188,8 +199,7 @@ "defaultValue": "none", "allowedValues": [ "none", - "azure", - "elastic" + "azure" ], "metadata": { "description": "options of moodle global search" @@ -237,19 +247,20 @@ "_artifactsLocationSasToken": { "value": "[parameters('_artifactsLocationSasToken')]" }, "redisDeploySwitch": { "value": "[parameters('redisDeploySwitch')]" }, "httpsTermination": { "value": "[parameters('httpsTermination')]"}, + "loadBalancerSku": { "value": "[parameters('loadBalancerSku')]"}, "siteURL": { "value": "[parameters('siteURL')]"}, "moodleVersion": { "value": "[parameters('moodleVersion')]"}, "sshPublicKey": { "value": "[parameters('sshPublicKey')]" }, "controllerVmSku": { "value": "[parameters('controllerVmSku')]"}, "webServerType": { "value": "[parameters('webServerType')]"}, - "autoscaleVmSku": { "value": "[parameters('autoscaleVmSku')]" }, - "autoscaleVmCountMax": { "value": "[parameters('autoscaleVmCountMax')]" }, - "dbServerType": { "value": "[parameters('dbServerType')]" }, - "dbLogin": { "value": "[parameters('dbLogin')]" }, + "autoscaleVmSku": { "value": "[parameters('autoscaleVmSku')]" }, + "autoscaleVmCountMax": { "value": "[parameters('autoscaleVmCountMax')]" }, + "dbServerType": { "value": "[parameters('dbServerType')]" }, + "dbLogin": { "value": "[parameters('dbLogin')]" }, "mysqlPgresVcores": { "value": "[parameters('mysqlPgresVcores')]" }, "mysqlPgresStgSizeGB": { "value": "[parameters('mysqlPgresStgSizeGB')]" }, - "mysqlPgresSkuTier": { "value": "[parameters('mysqlPgresSkuTier')]" }, - "mysqlPgresSkuHwFamily": { "value": "[parameters('mysqlPgresSkuHwFamily')]" }, + "mysqlPgresSkuTier": { "value": "[parameters('mysqlPgresSkuTier')]" }, + "mysqlPgresSkuHwFamily": { "value": "[parameters('mysqlPgresSkuHwFamily')]" }, "mysqlVersion": { "value": "[parameters('mysqlVersion')]" }, "postgresVersion": { "value": "[parameters('postgresVersion')]" }, "fileServerType": { "value": "azurefiles" }, @@ -273,4 +284,4 @@ "value": "[reference('mainTemplate').outputs]" } } -} +} \ No newline at end of file From a174787dc1f582e66fbefe56c0f6d17f408dd310 Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Sat, 23 Jan 2021 22:53:09 +0530 Subject: [PATCH 12/33] fixed scripts to handle existing moodle share in migration flow --- scripts/helper_functions.sh | 24 ++++++++++++++++++++++++ scripts/install_moodle.sh | 12 +++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/scripts/helper_functions.sh b/scripts/helper_functions.sh index 0f1da129..de61a807 100644 --- a/scripts/helper_functions.sh +++ b/scripts/helper_functions.sh @@ -69,6 +69,7 @@ function get_setup_params_from_configs_json export storageAccountType=$(echo $json | jq -r .moodleProfile.storageAccountType) export fileServerDiskSize=$(echo $json | jq -r .fileServerProfile.fileServerDiskSize) export phpVersion=$(echo $json | jq -r .phpProfile.phpVersion) + export isMigration=$(echo $json | jq -r .moodleProfile.isMigration) } function get_php_version { @@ -127,6 +128,29 @@ function create_azure_files_moodle_share --quota $fileServerDiskSize } +function check_azure_files_moodle_share_exists +{ + local storageAccountName=$1 + local storageAccountKey=$2 + + local azResponse=$(az storage share exists --name moodle --account-name $storageAccountName --account-key $storageAccountKey) + if [ $? -ne 0 ];then + echo "Could not check if moodle exists in the storage account ($storageAccountName)" + exit 1 + fi + + echo "az storage share exists command response:" + echo $azResponse + #Sample 'az storage share exists' command response + # { "exists": true } + local exists=$(echo $azResponse | jq -r .exists) + + if [ "$exists" != "true" ];then + echo "File share 'moodle' does not exists in the storage account ($storageAccountName)" + exit 1 + fi +} + function setup_and_mount_gluster_moodle_share { local glusterNode=$1 diff --git a/scripts/install_moodle.sh b/scripts/install_moodle.sh index b454f967..b0afbf6f 100644 --- a/scripts/install_moodle.sh +++ b/scripts/install_moodle.sh @@ -67,6 +67,7 @@ set -ex echo $storageAccountType >>/tmp/vars.txt echo $fileServerDiskSize >>/tmp/vars.txt echo $phpVersion >> /tmp/vars.txt + echo $isMigration >> /tmp/vars.txt check_fileServerType_param $fileServerType @@ -936,9 +937,14 @@ EOF # First rename moodle directory to something else mv /moodle /moodle_old_delete_me - # Then create the moodle share - echo -e '\n\rCreating an Azure Files share for moodle' - create_azure_files_moodle_share $storageAccountName $storageAccountKey /tmp/wabs.log $fileServerDiskSize + # Then create the moodle share if its not migration flow + if [ "$isMigration" = "true" ]; then + echo -e '\n\rIts a migration flow, checking if moodle files share exists' + check_azure_files_moodle_share_exists $storageAccountName $storageAccountKey + else + echo -e '\n\rCreating an Azure Files share for moodle' + create_azure_files_moodle_share $storageAccountName $storageAccountKey /tmp/wabs.log $fileServerDiskSize + fi # Set up and mount Azure Files share. Must be done after nginx is installed because of www-data user/group echo -e '\n\rSetting up and mounting Azure Files share on //'$storageAccountName'.file.core.windows.net/moodle on /moodle\n\r' setup_and_mount_azure_files_moodle_share $storageAccountName $storageAccountKey From 0aeb2785ef6800297daf1de5673149fdb8abfbf4 Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Sun, 24 Jan 2021 01:05:23 +0530 Subject: [PATCH 13/33] minor fixs: tabs to spaces, log sentance corrections --- migration/azuredeploy-migration.json | 4 ++-- scripts/helper_functions.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/azuredeploy-migration.json b/migration/azuredeploy-migration.json index a16677b9..dfb58469 100644 --- a/migration/azuredeploy-migration.json +++ b/migration/azuredeploy-migration.json @@ -7,7 +7,7 @@ "metadata": { "description": "The base URI where artifacts required by this template are located. When the template is deployed using the accompanying scripts, a private location in the subscription will be used and this value will be automatically generated." }, - "defaultValue": "https://raw.githubusercontent.com/venu-sivanadham/Moodle/MigrationDevelop/" + "defaultValue": "https://raw.githubusercontent.com/venu-sivanadham/Moodle/master/" }, "_artifactsLocationSasToken": { "type": "securestring", @@ -247,7 +247,7 @@ "_artifactsLocationSasToken": { "value": "[parameters('_artifactsLocationSasToken')]" }, "redisDeploySwitch": { "value": "[parameters('redisDeploySwitch')]" }, "httpsTermination": { "value": "[parameters('httpsTermination')]"}, - "loadBalancerSku": { "value": "[parameters('loadBalancerSku')]"}, + "loadBalancerSku": { "value": "[parameters('loadBalancerSku')]"}, "siteURL": { "value": "[parameters('siteURL')]"}, "moodleVersion": { "value": "[parameters('moodleVersion')]"}, "sshPublicKey": { "value": "[parameters('sshPublicKey')]" }, diff --git a/scripts/helper_functions.sh b/scripts/helper_functions.sh index de61a807..6cbad822 100644 --- a/scripts/helper_functions.sh +++ b/scripts/helper_functions.sh @@ -135,7 +135,7 @@ function check_azure_files_moodle_share_exists local azResponse=$(az storage share exists --name moodle --account-name $storageAccountName --account-key $storageAccountKey) if [ $? -ne 0 ];then - echo "Could not check if moodle exists in the storage account ($storageAccountName)" + echo "Could not check if moodle file share exists in the storage account ($storageAccountName)" exit 1 fi From b244f89ea26ed0d9d79409f79dfb64786c4c483b Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Mon, 25 Jan 2021 14:44:19 +0530 Subject: [PATCH 14/33] Migration Flow: Moodle DB import functionality --- azuredeploy.json | 20 +++- migration/azuredeploy-migration.json | 16 ++++ scripts/helper_functions.sh | 27 ++++++ scripts/install_moodle.sh | 133 +++++++++++++++++---------- 4 files changed, 145 insertions(+), 51 deletions(-) diff --git a/azuredeploy.json b/azuredeploy.json index 38b1c546..96c0319a 100644 --- a/azuredeploy.json +++ b/azuredeploy.json @@ -217,6 +217,20 @@ }, "type": "string" }, + "moodleDbName": { + "defaultValue": "moodle", + "metadata": { + "description": "Moodle Database name" + }, + "type": "string" + }, + "moodleDbUser": { + "defaultValue": "moodle", + "metadata": { + "description": "Moodle Database username. This user is different from Database admin user." + }, + "type": "string" + }, "mysqlPgresVcores": { "allowedValues": [ 1, @@ -1157,10 +1171,10 @@ "lbPipName": "[concat('lb-pubip-',variables('resourceprefix'))]", "location": "[parameters('location')]", "moodleAdminPass": "[concat(toUpper('xl'), substring(uniqueString(resourceGroup().id, deployment().name), 6, 7),',1*8')]", - "moodleDbName": "moodle", + "moodleDbName": "[parameters('moodleDbName')]", "moodleDbPass": "[concat('9#36^', substring(uniqueString(resourceGroup().id, deployment().name), 5, 8), toUpper('ercq'))]", - "moodleDbUser": "moodle", - "moodleDbUserAzure": "[concat('moodle', '@', parameters('dbServerType'), '-', variables('resourceprefix'))]", + "moodleDbUser": "[parameters('moodleDbUser')]", + "moodleDbUserAzure": "[concat(parameters('moodleDbUser'), '@', parameters('dbServerType'), '-', variables('resourceprefix'))]", "moodleInstallScriptFilename": "install_moodle.sh", "moodleOnAzureConfigsJsonPath": "/var/lib/cloud/instance/moodle_on_azure_configs.json", "moodleVersion": "[parameters('moodleVersion')]", diff --git a/migration/azuredeploy-migration.json b/migration/azuredeploy-migration.json index dfb58469..f1178c56 100644 --- a/migration/azuredeploy-migration.json +++ b/migration/azuredeploy-migration.json @@ -119,6 +119,20 @@ }, "type": "string" }, + "moodleDbName": { + "defaultValue": "moodle", + "metadata": { + "description": "Moodle Database name" + }, + "type": "string" + }, + "moodleDbUser": { + "defaultValue": "moodle", + "metadata": { + "description": "Moodle Database username. This user is different from Database admin user." + }, + "type": "string" + }, "mysqlPgresVcores": { "allowedValues": [ 1, @@ -257,6 +271,8 @@ "autoscaleVmCountMax": { "value": "[parameters('autoscaleVmCountMax')]" }, "dbServerType": { "value": "[parameters('dbServerType')]" }, "dbLogin": { "value": "[parameters('dbLogin')]" }, + "moodleDbName": { "value": "[parameters('moodleDbName')]" }, + "moodleDbUser": { "value": "[parameters('moodleDbUser')]" }, "mysqlPgresVcores": { "value": "[parameters('mysqlPgresVcores')]" }, "mysqlPgresStgSizeGB": { "value": "[parameters('mysqlPgresStgSizeGB')]" }, "mysqlPgresSkuTier": { "value": "[parameters('mysqlPgresSkuTier')]" }, diff --git a/scripts/helper_functions.sh b/scripts/helper_functions.sh index 6cbad822..2e8aee24 100644 --- a/scripts/helper_functions.sh +++ b/scripts/helper_functions.sh @@ -128,6 +128,33 @@ function create_azure_files_moodle_share --quota $fileServerDiskSize } +function replace_config_setting_value +{ + local setting_name=$1 + local setting_value=$2 + local delemeter=$3 + local file_name=$4 + + echo "Replacing $setting_name $delemeter $setting_value in $file_name" + + sed -i "s/^\($setting_name\s*$delemeter\s*\).*\$/\1$setting_value/" $file_name +} + +# This function can replace only single line $CFG setting in moodle/config.php file. +# Supported config setting format: +# $CFG->setting = 'value'; +# Usage: +# replace_moodle_config_value "setting" "value" +function replace_moodle_config_value +{ + local formated_setting_name="\$CFG->$1" + local formated_setting_value="'$2';" + local delemeter="=" + local moodle_config_file=/moodle/html/moodle/config.php + + replace_config_setting_value $formated_setting_name $formated_setting_value $delemeter $moodle_config_file +} + function check_azure_files_moodle_share_exists { local storageAccountName=$1 diff --git a/scripts/install_moodle.sh b/scripts/install_moodle.sh index b0afbf6f..087af5f3 100644 --- a/scripts/install_moodle.sh +++ b/scripts/install_moodle.sh @@ -53,8 +53,8 @@ set -ex echo $dbServerType >> /tmp/vars.txt echo $fileServerType >> /tmp/vars.txt echo $mssqlDbServiceObjectiveName >> /tmp/vars.txt - echo $mssqlDbEdition >> /tmp/vars.txt - echo $mssqlDbSize >> /tmp/vars.txt + echo $mssqlDbEdition >> /tmp/vars.txt + echo $mssqlDbSize >> /tmp/vars.txt echo $installObjectFsSwitch >> /tmp/vars.txt echo $installGdprPluginsSwitch >> /tmp/vars.txt echo $thumbprintSslCert >> /tmp/vars.txt @@ -101,6 +101,17 @@ set -ex # create gluster, nfs or Azure Files mount point mkdir -p /moodle + + # If its a migration flow, then mount the azure file share now. + if [ "$isMigration" = "true" ]; then + # On migration flow, the moodle azure file share must present before running this script. + echo -e '\n\rIts a migration flow, check whether moodle fileshare exists\n\r' + check_azure_files_moodle_share_exists $storageAccountName $storageAccountKey + + # Set up and mount Azure Files share. + echo -e '\n\rSetting up and mounting Azure Files share //'$storageAccountName'.file.core.windows.net/moodle on /moodle\n\r' + setup_and_mount_azure_files_moodle_share $storageAccountName $storageAccountKey + fi export DEBIAN_FRONTEND=noninteractive @@ -127,43 +138,43 @@ set -ex elif [ "$dbServerType" = "postgres" ]; then sudo apt-get -y --force-yes install postgresql-client >> /tmp/apt3.log fi - + if [ "$installObjectFsSwitch" = "true" -o "$fileServerType" = "azurefiles" ]; then - # install azure cli & setup container + # install azure cli & setup container echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ wheezy main" | \ sudo tee /etc/apt/sources.list.d/azure-cli.list curl -L https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - >> /tmp/apt4.log sudo apt-get -y install apt-transport-https >> /tmp/apt4.log sudo apt-get -y update > /dev/null sudo apt-get -y install azure-cli >> /tmp/apt4.log - + # FileStorage accounts can only be used to store Azure file shares; # Premium_LRS will support FileStorage kind # No other storage resources (blob containers, queues, tables, etc.) can be deployed in a FileStorage account. if [ $storageAccountType != "Premium_LRS" ]; then - az storage container create \ - --name objectfs \ - --account-name $storageAccountName \ - --account-key $storageAccountKey \ - --public-access off \ - --fail-on-exist >> /tmp/wabs.log - - az storage container policy create \ - --account-name $storageAccountName \ - --account-key $storageAccountKey \ - --container-name objectfs \ - --name readwrite \ - --start $(date --date="1 day ago" +%F) \ - --expiry $(date --date="2199-01-01" +%F) \ - --permissions rw >> /tmp/wabs.log - - sas=$(az storage container generate-sas \ - --account-name $storageAccountName \ - --account-key $storageAccountKey \ - --name objectfs \ - --policy readwrite \ - --output tsv) - fi + az storage container create \ + --name objectfs \ + --account-name $storageAccountName \ + --account-key $storageAccountKey \ + --public-access off \ + --fail-on-exist >> /tmp/wabs.log + + az storage container policy create \ + --account-name $storageAccountName \ + --account-key $storageAccountKey \ + --container-name objectfs \ + --name readwrite \ + --start $(date --date="1 day ago" +%F) \ + --expiry $(date --date="2199-01-01" +%F) \ + --permissions rw >> /tmp/wabs.log + + sas=$(az storage container generate-sas \ + --account-name $storageAccountName \ + --account-key $storageAccountKey \ + --name objectfs \ + --policy readwrite \ + --output tsv) + fi fi if [ $fileServerType = "gluster" ]; then @@ -290,7 +301,7 @@ worker_processes 2; pid /run/nginx.pid; events { - worker_connections 768; + worker_connections 768; } http { @@ -387,9 +398,9 @@ EOF return 404; } - location / { - try_files \$uri \$uri/index.php?\$query_string; - } + location / { + try_files \$uri \$uri/index.php?\$query_string; + } location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; @@ -794,8 +805,35 @@ EOF siteProtocol="https" fi if [ $dbServerType = "mysql" ]; then - echo -e "cd /tmp; /usr/bin/php /moodle/html/moodle/admin/cli/install.php --chmod=770 --lang=en_us --wwwroot="$siteProtocol"://"$siteFQDN" --dataroot=/moodle/moodledata --dbhost="$mysqlIP" --dbname="$moodledbname" --dbuser="$azuremoodledbuser" --dbpass="$moodledbpass" --dbtype=mysqli --fullname='Moodle LMS' --shortname='Moodle' --adminuser=admin --adminpass="$adminpass" --adminemail=admin@"$siteFQDN" --non-interactive --agree-license --allow-unstable || true " - cd /tmp; /usr/bin/php /moodle/html/moodle/admin/cli/install.php --chmod=770 --lang=en_us --wwwroot=$siteProtocol://$siteFQDN --dataroot=/moodle/moodledata --dbhost=$mysqlIP --dbname=$moodledbname --dbuser=$azuremoodledbuser --dbpass=$moodledbpass --dbtype=mysqli --fullname='Moodle LMS' --shortname='Moodle' --adminuser=admin --adminpass=$adminpass --adminemail=admin@$siteFQDN --non-interactive --agree-license --allow-unstable || true + if [ "$isMigration" = "true" ]; then + echo "Importing database from the mysql dump file" + if [ ! -f /moodle/migration-db-moodle.tar.gz ]; + echo "Migrating moodle DB dump archive file not found." + exit 1 + fi + + tar -xvf /moodle/migration-db-moodle.tar.gz --directly /moodle/ + + if [ ! -f /moodle/migration-db-moodle.sql ]; + echo "Migrating moodle DB dump file not found." + exit 1 + fi + + echo "Importing migration moodle DB." + mysql -h $mysqlIP -u $mysqladminlogin -p${mysqladminpass} ${moodledbname} < /moodle/migration-db-moodle.sql + + echo "Updating moodle db config settings" + replace_moodle_config_value "dbhost" "$mysqlIP" + replace_moodle_config_value "dbuser" "$azuremoodledbuser" + replace_moodle_config_value "dbpass" "$moodledbpass" + + echo "Updating other moodle config settings" + replace_moodle_config_value "dataroot" "/moodle/moodledata" + replace_moodle_config_value "wwwroot" "$siteProtocol://$siteFQDN" + else + echo -e "cd /tmp; /usr/bin/php /moodle/html/moodle/admin/cli/install.php --chmod=770 --lang=en_us --wwwroot="$siteProtocol"://"$siteFQDN" --dataroot=/moodle/moodledata --dbhost="$mysqlIP" --dbname="$moodledbname" --dbuser="$azuremoodledbuser" --dbpass="$moodledbpass" --dbtype=mysqli --fullname='Moodle LMS' --shortname='Moodle' --adminuser=admin --adminpass="$adminpass" --adminemail=admin@"$siteFQDN" --non-interactive --agree-license --allow-unstable || true " + cd /tmp; /usr/bin/php /moodle/html/moodle/admin/cli/install.php --chmod=770 --lang=en_us --wwwroot=$siteProtocol://$siteFQDN --dataroot=/moodle/moodledata --dbhost=$mysqlIP --dbname=$moodledbname --dbuser=$azuremoodledbuser --dbpass=$moodledbpass --dbtype=mysqli --fullname='Moodle LMS' --shortname='Moodle' --adminuser=admin --adminpass=$adminpass --adminemail=admin@$siteFQDN --non-interactive --agree-license --allow-unstable || true + fi if [ "$installObjectFsSwitch" = "true" ]; then mysql -h $mysqlIP -u $mysqladminlogin -p${mysqladminpass} ${moodledbname} -e "INSERT INTO mdl_config_plugins (plugin, name, value) VALUES ('tool_objectfs', 'enabletasks', 1);" @@ -933,25 +971,24 @@ EOF fi if [ $fileServerType = "azurefiles" ]; then - # Delayed copy of moodle installation to the Azure Files share - - # First rename moodle directory to something else - mv /moodle /moodle_old_delete_me - # Then create the moodle share if its not migration flow if [ "$isMigration" = "true" ]; then - echo -e '\n\rIts a migration flow, checking if moodle files share exists' - check_azure_files_moodle_share_exists $storageAccountName $storageAccountKey + echo -e '\n\rIts a migration flow, the moodle content is already on azure file share\n\r' else + # Delayed copy of moodle installation to the Azure Files share + + # First rename moodle directory to something else + mv /moodle /moodle_old_delete_me + # Then create the moodle share echo -e '\n\rCreating an Azure Files share for moodle' create_azure_files_moodle_share $storageAccountName $storageAccountKey /tmp/wabs.log $fileServerDiskSize + # Set up and mount Azure Files share. Must be done after nginx is installed because of www-data user/group + echo -e '\n\rSetting up and mounting Azure Files share on //'$storageAccountName'.file.core.windows.net/moodle on /moodle\n\r' + setup_and_mount_azure_files_moodle_share $storageAccountName $storageAccountKey + # Move the local installation over to the Azure Files + echo -e '\n\rMoving locally installed moodle over to Azure Files' + cp -a /moodle_old_delete_me/* /moodle || true # Ignore case sensitive directory copy failure + rm -rf /moodle_old_delete_me || true # Keep the files just in case fi - # Set up and mount Azure Files share. Must be done after nginx is installed because of www-data user/group - echo -e '\n\rSetting up and mounting Azure Files share on //'$storageAccountName'.file.core.windows.net/moodle on /moodle\n\r' - setup_and_mount_azure_files_moodle_share $storageAccountName $storageAccountKey - # Move the local installation over to the Azure Files - echo -e '\n\rMoving locally installed moodle over to Azure Files' - cp -a /moodle_old_delete_me/* /moodle || true # Ignore case sensitive directory copy failure - rm -rf /moodle_old_delete_me || true # Keep the files just in case fi create_last_modified_time_update_script From e0c209e201e1c358e83ed26ae05ce9fe813bbbda Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Mon, 25 Jan 2021 17:35:46 +0530 Subject: [PATCH 15/33] fixed syntax error --- scripts/install_moodle.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install_moodle.sh b/scripts/install_moodle.sh index 087af5f3..8aabd827 100644 --- a/scripts/install_moodle.sh +++ b/scripts/install_moodle.sh @@ -807,14 +807,14 @@ EOF if [ $dbServerType = "mysql" ]; then if [ "$isMigration" = "true" ]; then echo "Importing database from the mysql dump file" - if [ ! -f /moodle/migration-db-moodle.tar.gz ]; + if [ ! -f /moodle/migration-db-moodle.tar.gz ]; then echo "Migrating moodle DB dump archive file not found." exit 1 fi tar -xvf /moodle/migration-db-moodle.tar.gz --directly /moodle/ - if [ ! -f /moodle/migration-db-moodle.sql ]; + if [ ! -f /moodle/migration-db-moodle.sql ]; then echo "Migrating moodle DB dump file not found." exit 1 fi From e64e1915f88d08aa20e11822a303993699cde989 Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Tue, 26 Jan 2021 01:19:03 +0530 Subject: [PATCH 16/33] added php version input parameter and other minor fixes --- migration/azuredeploy-migration.json | 13 +++++++++++++ scripts/install_moodle.sh | 26 +++++++++++++------------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/migration/azuredeploy-migration.json b/migration/azuredeploy-migration.json index f1178c56..73a445c4 100644 --- a/migration/azuredeploy-migration.json +++ b/migration/azuredeploy-migration.json @@ -101,6 +101,18 @@ }, "type": "int" }, + "phpVersion": { + "allowedValues": [ + "7.2", + "7.3", + "7.4" + ], + "defaultValue": "7.4", + "metadata": { + "description": "php version" + }, + "type": "string" + }, "dbServerType": { "defaultValue": "mysql", "allowedValues": [ @@ -269,6 +281,7 @@ "webServerType": { "value": "[parameters('webServerType')]"}, "autoscaleVmSku": { "value": "[parameters('autoscaleVmSku')]" }, "autoscaleVmCountMax": { "value": "[parameters('autoscaleVmCountMax')]" }, + "phpVersion": { "value": "[parameters('phpVersion')]" }, "dbServerType": { "value": "[parameters('dbServerType')]" }, "dbLogin": { "value": "[parameters('dbLogin')]" }, "moodleDbName": { "value": "[parameters('moodleDbName')]" }, diff --git a/scripts/install_moodle.sh b/scripts/install_moodle.sh index 8aabd827..406a4ca9 100644 --- a/scripts/install_moodle.sh +++ b/scripts/install_moodle.sh @@ -101,17 +101,6 @@ set -ex # create gluster, nfs or Azure Files mount point mkdir -p /moodle - - # If its a migration flow, then mount the azure file share now. - if [ "$isMigration" = "true" ]; then - # On migration flow, the moodle azure file share must present before running this script. - echo -e '\n\rIts a migration flow, check whether moodle fileshare exists\n\r' - check_azure_files_moodle_share_exists $storageAccountName $storageAccountKey - - # Set up and mount Azure Files share. - echo -e '\n\rSetting up and mounting Azure Files share //'$storageAccountName'.file.core.windows.net/moodle on /moodle\n\r' - setup_and_mount_azure_files_moodle_share $storageAccountName $storageAccountKey - fi export DEBIAN_FRONTEND=noninteractive @@ -174,7 +163,18 @@ set -ex --name objectfs \ --policy readwrite \ --output tsv) - fi + fi + + # If its a migration flow, then mount the azure file share now. + if [ "$isMigration" = "true" ]; then + # On migration flow, the moodle azure file share must present before running this script. + echo -e '\n\rIts a migration flow, check whether moodle fileshare exists\n\r' + check_azure_files_moodle_share_exists $storageAccountName $storageAccountKey + + # Set up and mount Azure Files share. + echo -e '\n\rSetting up and mounting Azure Files share //'$storageAccountName'.file.core.windows.net/moodle on /moodle\n\r' + setup_and_mount_azure_files_moodle_share $storageAccountName $storageAccountKey + fi fi if [ $fileServerType = "gluster" ]; then @@ -812,7 +812,7 @@ EOF exit 1 fi - tar -xvf /moodle/migration-db-moodle.tar.gz --directly /moodle/ + tar -xvf /moodle/migration-db-moodle.tar.gz -C /moodle/ if [ ! -f /moodle/migration-db-moodle.sql ]; then echo "Migrating moodle DB dump file not found." From f5484e6a9cc206351dea21b09fecca071c4e4916 Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Tue, 26 Jan 2021 02:21:21 +0530 Subject: [PATCH 17/33] included escape chars for config value replacement --- scripts/install_moodle.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install_moodle.sh b/scripts/install_moodle.sh index 406a4ca9..d0a34e61 100644 --- a/scripts/install_moodle.sh +++ b/scripts/install_moodle.sh @@ -828,8 +828,8 @@ EOF replace_moodle_config_value "dbpass" "$moodledbpass" echo "Updating other moodle config settings" - replace_moodle_config_value "dataroot" "/moodle/moodledata" - replace_moodle_config_value "wwwroot" "$siteProtocol://$siteFQDN" + replace_moodle_config_value "dataroot" "\/moodle\/moodledata" + replace_moodle_config_value "wwwroot" "$siteProtocol:\/\/$siteFQDN" else echo -e "cd /tmp; /usr/bin/php /moodle/html/moodle/admin/cli/install.php --chmod=770 --lang=en_us --wwwroot="$siteProtocol"://"$siteFQDN" --dataroot=/moodle/moodledata --dbhost="$mysqlIP" --dbname="$moodledbname" --dbuser="$azuremoodledbuser" --dbpass="$moodledbpass" --dbtype=mysqli --fullname='Moodle LMS' --shortname='Moodle' --adminuser=admin --adminpass="$adminpass" --adminemail=admin@"$siteFQDN" --non-interactive --agree-license --allow-unstable || true " cd /tmp; /usr/bin/php /moodle/html/moodle/admin/cli/install.php --chmod=770 --lang=en_us --wwwroot=$siteProtocol://$siteFQDN --dataroot=/moodle/moodledata --dbhost=$mysqlIP --dbname=$moodledbname --dbuser=$azuremoodledbuser --dbpass=$moodledbpass --dbtype=mysqli --fullname='Moodle LMS' --shortname='Moodle' --adminuser=admin --adminpass=$adminpass --adminemail=admin@$siteFQDN --non-interactive --agree-license --allow-unstable || true From 345bf7808ffc5b784016644d3e49bbe264381955 Mon Sep 17 00:00:00 2001 From: shishir-msft <55269898+shishir-msft@users.noreply.github.com> Date: Mon, 1 Feb 2021 18:24:26 +0530 Subject: [PATCH 18/33] Fixed sql tarball name in install-moodle.sh (#7) * Update install_moodle.sh * Update azuredeploy-migration.json * reverted moodle base path * . --- scripts/install_moodle.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install_moodle.sh b/scripts/install_moodle.sh index d0a34e61..39ff2012 100644 --- a/scripts/install_moodle.sh +++ b/scripts/install_moodle.sh @@ -807,12 +807,12 @@ EOF if [ $dbServerType = "mysql" ]; then if [ "$isMigration" = "true" ]; then echo "Importing database from the mysql dump file" - if [ ! -f /moodle/migration-db-moodle.tar.gz ]; then + if [ ! -f /moodle/migration-db-moodle.sql.tar.gz ]; then echo "Migrating moodle DB dump archive file not found." exit 1 fi - tar -xvf /moodle/migration-db-moodle.tar.gz -C /moodle/ + tar -xvf /moodle/migration-db-moodle.sql.tar.gz -C /moodle/ if [ ! -f /moodle/migration-db-moodle.sql ]; then echo "Migrating moodle DB dump file not found." From 0f4ff9f7b3146a077900dc98af5003a248e92080 Mon Sep 17 00:00:00 2001 From: shishir-msft <55269898+shishir-msft@users.noreply.github.com> Date: Mon, 22 Feb 2021 14:19:07 +0530 Subject: [PATCH 19/33] Changes for WB compatibility (#8) * removed non-required params * changed all param types to string * change output type to string --- migration/azure-fileshare-sa-deploy.json | 38 ++---- migration/azuredeploy-migration.json | 160 +++++++---------------- 2 files changed, 58 insertions(+), 140 deletions(-) diff --git a/migration/azure-fileshare-sa-deploy.json b/migration/azure-fileshare-sa-deploy.json index 71884f9d..a26c4686 100644 --- a/migration/azure-fileshare-sa-deploy.json +++ b/migration/azure-fileshare-sa-deploy.json @@ -2,20 +2,6 @@ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { - "_artifactsLocation": { - "type": "string", - "metadata": { - "description": "The base URI where artifacts required by this template are located." - }, - "defaultValue": "https://raw.githubusercontent.com/Azure/Moodle/master/" - }, - "_artifactsLocationSasToken": { - "type": "securestring", - "metadata": { - "description": "The sasToken required to access _artifactsLocation. When the template is deployed using the accompanying scripts, a sasToken will be automatically generated." - }, - "defaultValue": "" - }, "storageAccountType": { "defaultValue": "Premium_LRS", "allowedValues": [ @@ -30,18 +16,11 @@ "type": "string" }, "fileServerDiskSize": { - "defaultValue": 100, + "defaultValue": "100", "metadata": { "description": "Size of the azure file share in GB." }, - "type": "int" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]", - "metadata": { - "description": "Azure Location for all resources." - } + "type": "string" } }, "resources": [ @@ -57,7 +36,7 @@ } }, "templateLink": { - "uri": "[concat(variables('moodleCommon').baseTemplateUrl,'storageAccount.json',parameters('_artifactsLocationSasToken'))]" + "uri": "[concat(variables('moodleCommon').baseTemplateUrl,'storageAccount.json',variables('moodleCommon').artifactsSasToken)]" } } }, @@ -85,16 +64,19 @@ "value": "[variables('moodleCommon').storageAccountType]" }, "fileServerDiskSize": { - "type": "int", + "type": "string", "value": "[variables('moodleCommon').fileServerDiskSize]" } }, "variables": { + "_artifactsLocation": "https://raw.githubusercontent.com/Azure/Moodle/master/", + "_artifactsLocationSasToken": "", + "location": "[resourceGroup().location]", "moodleCommon": { - "baseTemplateUrl": "[concat(parameters('_artifactsLocation'), 'nested/')]", - "artifactsSasToken": "[parameters('_artifactsLocationSasToken')]", + "baseTemplateUrl": "[concat(variables('_artifactsLocation'), 'nested/')]", + "artifactsSasToken": "[variables('_artifactsLocationSasToken')]", "fileServerType": "azurefiles", - "location": "[parameters('location')]", + "location": "[variables('location')]", "storageAccountName": "[tolower(concat('abs',variables('resourceprefix')))]", "storageAccountType": "[parameters('storageAccountType')]", "fileServerDiskSize": "[parameters('fileServerDiskSize')]" diff --git a/migration/azuredeploy-migration.json b/migration/azuredeploy-migration.json index 73a445c4..b6574aa6 100644 --- a/migration/azuredeploy-migration.json +++ b/migration/azuredeploy-migration.json @@ -2,26 +2,16 @@ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { - "_artifactsLocation": { - "type": "string", - "metadata": { - "description": "The base URI where artifacts required by this template are located. When the template is deployed using the accompanying scripts, a private location in the subscription will be used and this value will be automatically generated." - }, - "defaultValue": "https://raw.githubusercontent.com/venu-sivanadham/Moodle/master/" - }, - "_artifactsLocationSasToken": { - "type": "securestring", - "metadata": { - "description": "The sasToken required to access _artifactsLocation. When the template is deployed using the accompanying scripts, a sasToken will be automatically generated." - }, - "defaultValue": "" - }, "redisDeploySwitch": { - "defaultValue": false, + "defaultValue": "false", "metadata": { "description": "Switch to deploy a redis cache or not. Note that certain versions of Moodle (e.g., 3.1) don't work well with Redis, so use this only for known well-working Moodle versions (e.g., 3.4)." }, - "type": "bool" + "allowedValues": [ + "true", + "false" + ], + "type": "string" }, "httpsTermination": { "allowedValues": [ @@ -46,12 +36,6 @@ }, "type": "string" }, - "siteURL": { - "metadata": { - "description": "URL for Moodle site" - }, - "type": "string" - }, "moodleVersion": { "allowedValues": [ "MOODLE_39_STABLE", @@ -69,13 +53,6 @@ }, "type": "string" }, - "controllerVmSku": { - "defaultValue": "Standard_DS1_v2", - "metadata": { - "description": "VM size for the controller VM" - }, - "type": "string" - }, "webServerType": { "defaultValue": "nginx", "allowedValues": [ @@ -87,19 +64,19 @@ }, "type": "string" }, - "autoscaleVmSku": { - "defaultValue": "Standard_DS2_v2", - "metadata": { - "description": "VM size for autoscaled web VMs" - }, - "type": "string" - }, - "autoscaleVmCountMax": { - "defaultValue": 10, - "metadata": { - "description": "Maximum number of autoscaled web VMs" - }, - "type": "int" + "autoscaleVmSku": { + "defaultValue": "Standard_DS2_v2", + "metadata": { + "description": "VM size for autoscaled web VMs" + }, + "type": "string" + }, + "autoscaleVmCountMax": { + "defaultValue": "10", + "metadata": { + "description": "Maximum number of autoscaled web VMs" + }, + "type": "string" }, "phpVersion": { "allowedValues": [ @@ -124,13 +101,6 @@ }, "type": "string" }, - "dbLogin": { - "defaultValue": "dbadmin", - "metadata": { - "description": "Database admin username" - }, - "type": "string" - }, "moodleDbName": { "defaultValue": "moodle", "metadata": { @@ -147,27 +117,25 @@ }, "mysqlPgresVcores": { "allowedValues": [ - 1, - 2, - 4, - 8, - 16, - 32 + "1", + "2", + "4", + "8", + "16", + "32" ], - "defaultValue": 2, + "defaultValue": "2", "metadata": { "description": "MySql/Postgresql vCores. For Basic tier, only 1 & 2 are allowed. For GeneralPurpose tier, 2, 4, 8, 16, 32 are allowed. For MemoryOptimized, 2, 4, 8, 16 are allowed." }, - "type": "int" + "type": "string" }, "mysqlPgresStgSizeGB": { - "defaultValue": 125, - "minValue": 5, - "maxValue": 1024, + "defaultValue": "125", "metadata": { "description": "MySql/Postgresql storage size in GB. Minimum 5GB, increase by 1GB, up to 1TB (1024 GB)" }, - "type": "int" + "type": "string" }, "mysqlPgresSkuTier": { "allowedValues": [ @@ -203,47 +171,11 @@ }, "type": "string" }, - "postgresVersion": { - "allowedValues": [ - "9.5", - "9.6" - ], - "defaultValue": "9.6", - "metadata": { - "description": "Postgresql version" - }, - "type": "string" - }, "fileServerDiskSize": { - "defaultValue": 100, + "defaultValue": "100", "metadata": { "description": "Size per disk for gluster nodes or nfs server" }, - "type": "int" - }, - "searchType": { - "defaultValue": "none", - "allowedValues": [ - "none", - "azure" - ], - "metadata": { - "description": "options of moodle global search" - }, - "type": "string" - }, - "azureSearchSku": { - "defaultValue": "basic", - "allowedValues": [ - "free", - "basic", - "standard", - "standard2", - "standard3" - ], - "metadata": { - "description": "the search service level you want to create." - }, "type": "string" }, "vNetAddressSpace": { @@ -261,6 +193,10 @@ "defaultValue": "18.04-LTS" } }, + "variables": { + "_artifactsLocation": "https://raw.githubusercontent.com/venu-sivanadham/Moodle/master/", + "_artifactsLocationSasToken": "" + }, "resources": [ { "type": "Microsoft.Resources/deployments", @@ -269,40 +205,40 @@ "properties": { "mode": "Incremental", "parameters": { - "_artifactsLocation": { "value": "[parameters('_artifactsLocation')]" }, - "_artifactsLocationSasToken": { "value": "[parameters('_artifactsLocationSasToken')]" }, - "redisDeploySwitch": { "value": "[parameters('redisDeploySwitch')]" }, + "_artifactsLocation": { "value": "[variables('_artifactsLocation')]" }, + "_artifactsLocationSasToken": { "value": "[variables('_artifactsLocationSasToken')]" }, + "redisDeploySwitch": { "value": "[bool(parameters('redisDeploySwitch'))]" }, "httpsTermination": { "value": "[parameters('httpsTermination')]"}, "loadBalancerSku": { "value": "[parameters('loadBalancerSku')]"}, - "siteURL": { "value": "[parameters('siteURL')]"}, + "siteURL": { "value": ""}, "moodleVersion": { "value": "[parameters('moodleVersion')]"}, "sshPublicKey": { "value": "[parameters('sshPublicKey')]" }, - "controllerVmSku": { "value": "[parameters('controllerVmSku')]"}, + "controllerVmSku": { "value": "Standard_DS1_v2"}, "webServerType": { "value": "[parameters('webServerType')]"}, "autoscaleVmSku": { "value": "[parameters('autoscaleVmSku')]" }, - "autoscaleVmCountMax": { "value": "[parameters('autoscaleVmCountMax')]" }, + "autoscaleVmCountMax": { "value": "[int(parameters('autoscaleVmCountMax'))]" }, "phpVersion": { "value": "[parameters('phpVersion')]" }, "dbServerType": { "value": "[parameters('dbServerType')]" }, - "dbLogin": { "value": "[parameters('dbLogin')]" }, + "dbLogin": { "value": "dbadmin" }, "moodleDbName": { "value": "[parameters('moodleDbName')]" }, "moodleDbUser": { "value": "[parameters('moodleDbUser')]" }, - "mysqlPgresVcores": { "value": "[parameters('mysqlPgresVcores')]" }, - "mysqlPgresStgSizeGB": { "value": "[parameters('mysqlPgresStgSizeGB')]" }, + "mysqlPgresVcores": { "value": "[int(parameters('mysqlPgresVcores'))]" }, + "mysqlPgresStgSizeGB": { "value": "[int(parameters('mysqlPgresStgSizeGB'))]" }, "mysqlPgresSkuTier": { "value": "[parameters('mysqlPgresSkuTier')]" }, "mysqlPgresSkuHwFamily": { "value": "[parameters('mysqlPgresSkuHwFamily')]" }, "mysqlVersion": { "value": "[parameters('mysqlVersion')]" }, - "postgresVersion": { "value": "[parameters('postgresVersion')]" }, + "postgresVersion": { "value": "9.6" }, "fileServerType": { "value": "azurefiles" }, "storageAccountType": { "value": "Premium_LRS" }, - "fileServerDiskSize": { "value": "[parameters('fileServerDiskSize')]" }, - "searchType": { "value": "[parameters('searchType')]" }, - "azureSearchSku": { "value": "[parameters('azureSearchSku')]" }, + "fileServerDiskSize": { "value": "[int(parameters('fileServerDiskSize'))]" }, + "searchType": { "value": "none" }, + "azureSearchSku": { "value": "basic" }, "vNetAddressSpace": { "value": "[parameters('vNetAddressSpace')]"}, "ubuntuVersion": { "value": "[parameters('ubuntuVersion')]"}, "isMigration": { "value": true } }, "templateLink": { - "uri": "[concat(parameters('_artifactsLocation'), 'azuredeploy.json', parameters('_artifactsLocationSasToken'))]" + "uri": "[concat(variables('_artifactsLocation'), 'azuredeploy.json', variables('_artifactsLocationSasToken'))]" } } } From 63e5e7bd49f0912e0b0b713bcbd69b96c364e3a0 Mon Sep 17 00:00:00 2001 From: shishir-msft <55269898+shishir-msft@users.noreply.github.com> Date: Wed, 24 Feb 2021 23:21:30 +0530 Subject: [PATCH 20/33] Update azure-fileshare-sa-deploy.json Updated artifacts location from 'Azure' repo to 'venu-sivanadham' to make sure nested arm templates are called from same repo. --- migration/azure-fileshare-sa-deploy.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/azure-fileshare-sa-deploy.json b/migration/azure-fileshare-sa-deploy.json index a26c4686..25ea96b3 100644 --- a/migration/azure-fileshare-sa-deploy.json +++ b/migration/azure-fileshare-sa-deploy.json @@ -69,7 +69,7 @@ } }, "variables": { - "_artifactsLocation": "https://raw.githubusercontent.com/Azure/Moodle/master/", + "_artifactsLocation": "https://raw.githubusercontent.com/venu-sivanadham/Moodle/master/", "_artifactsLocationSasToken": "", "location": "[resourceGroup().location]", "moodleCommon": { From a87fd02f0f0e6338ef6d0327634a293a1ff13de9 Mon Sep 17 00:00:00 2001 From: shishir-msft <55269898+shishir-msft@users.noreply.github.com> Date: Wed, 24 Feb 2021 23:37:44 +0530 Subject: [PATCH 21/33] Update storageAccount.json Storage account in eastus2euap doesn't support kind 'FileStorage'. Hence for that, we change the location to westus2. --- nested/storageAccount.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nested/storageAccount.json b/nested/storageAccount.json index bbdbafe8..53eb57f9 100644 --- a/nested/storageAccount.json +++ b/nested/storageAccount.json @@ -14,7 +14,7 @@ "condition": "[not(equals(parameters('moodleCommon').fileServerType, 'azurefiles'))]", "type": "Microsoft.Storage/storageAccounts", "apiVersion": "2019-06-01", - "location": "[parameters('moodleCommon').location]", + "location": "[if(equals(variables('location'), 'eastus2euap'), 'westus2', variables('location'))]", "name": "[concat(parameters('moodleCommon').storageAccountName,'naf')]", "kind": "Storage", "sku": { @@ -45,7 +45,7 @@ "condition": "[equals(parameters('moodleCommon').fileServerType, 'azurefiles')]", "type": "Microsoft.Storage/storageAccounts", "apiVersion": "2019-06-01", - "location": "[parameters('moodleCommon').location]", + "location": "[if(equals(variables('location'), 'eastus2euap'), 'westus2', variables('location'))]", "name": "[concat(parameters('moodleCommon').storageAccountName,'af')]", "kind": "[if(equals(parameters('moodleCommon').storageAccountType, 'Premium_LRS'), 'FileStorage', 'Storage')]", "sku": { @@ -81,7 +81,8 @@ "documentation2": " storageAccountName - name of storage account", "documentation3": " storageAccountType - type of storage account", "storageName": "[concat(parameters('moodleCommon').storageAccountName,if(equals(parameters('moodleCommon').fileServerType, 'azurefiles'), 'af', 'naf'))]", - "storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]" + "storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]", + "location": "[toLower(parameters('moodleCommon').location)]" }, "outputs": { "storageAccountKey": { From c23da44deabe6cd231ef6fc335f9f6b5ff7b7648 Mon Sep 17 00:00:00 2001 From: shishir-msft <55269898+shishir-msft@users.noreply.github.com> Date: Thu, 25 Feb 2021 10:58:37 +0530 Subject: [PATCH 22/33] Fixed mysql import db Space was missing in password argument --- scripts/install_moodle.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_moodle.sh b/scripts/install_moodle.sh index 39ff2012..d257083d 100644 --- a/scripts/install_moodle.sh +++ b/scripts/install_moodle.sh @@ -820,7 +820,7 @@ EOF fi echo "Importing migration moodle DB." - mysql -h $mysqlIP -u $mysqladminlogin -p${mysqladminpass} ${moodledbname} < /moodle/migration-db-moodle.sql + mysql -h $mysqlIP -u $mysqladminlogin -p ${mysqladminpass} ${moodledbname} < /moodle/migration-db-moodle.sql echo "Updating moodle db config settings" replace_moodle_config_value "dbhost" "$mysqlIP" From ce73d9208fed45c955fe2d5aea72abe09f7c4f31 Mon Sep 17 00:00:00 2001 From: shishir-msft <55269898+shishir-msft@users.noreply.github.com> Date: Thu, 25 Feb 2021 15:10:10 +0530 Subject: [PATCH 23/33] Update install_moodle.sh --- scripts/install_moodle.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_moodle.sh b/scripts/install_moodle.sh index d257083d..39ff2012 100644 --- a/scripts/install_moodle.sh +++ b/scripts/install_moodle.sh @@ -820,7 +820,7 @@ EOF fi echo "Importing migration moodle DB." - mysql -h $mysqlIP -u $mysqladminlogin -p ${mysqladminpass} ${moodledbname} < /moodle/migration-db-moodle.sql + mysql -h $mysqlIP -u $mysqladminlogin -p${mysqladminpass} ${moodledbname} < /moodle/migration-db-moodle.sql echo "Updating moodle db config settings" replace_moodle_config_value "dbhost" "$mysqlIP" From 5121752fdead3c6fac1281f276dcce6454ddda49 Mon Sep 17 00:00:00 2001 From: shishir-msft <55269898+shishir-msft@users.noreply.github.com> Date: Thu, 25 Feb 2021 15:15:01 +0530 Subject: [PATCH 24/33] Update storageAccount.json --- nested/storageAccount.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/nested/storageAccount.json b/nested/storageAccount.json index 53eb57f9..0e00f3c8 100644 --- a/nested/storageAccount.json +++ b/nested/storageAccount.json @@ -14,7 +14,7 @@ "condition": "[not(equals(parameters('moodleCommon').fileServerType, 'azurefiles'))]", "type": "Microsoft.Storage/storageAccounts", "apiVersion": "2019-06-01", - "location": "[if(equals(variables('location'), 'eastus2euap'), 'westus2', variables('location'))]", + "location": "[variables('locationNotCanary')]", "name": "[concat(parameters('moodleCommon').storageAccountName,'naf')]", "kind": "Storage", "sku": { @@ -45,7 +45,7 @@ "condition": "[equals(parameters('moodleCommon').fileServerType, 'azurefiles')]", "type": "Microsoft.Storage/storageAccounts", "apiVersion": "2019-06-01", - "location": "[if(equals(variables('location'), 'eastus2euap'), 'westus2', variables('location'))]", + "location": "[variables('locationNotCanary')]", "name": "[concat(parameters('moodleCommon').storageAccountName,'af')]", "kind": "[if(equals(parameters('moodleCommon').storageAccountType, 'Premium_LRS'), 'FileStorage', 'Storage')]", "sku": { @@ -82,7 +82,10 @@ "documentation3": " storageAccountType - type of storage account", "storageName": "[concat(parameters('moodleCommon').storageAccountName,if(equals(parameters('moodleCommon').fileServerType, 'azurefiles'), 'af', 'naf'))]", "storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]", - "location": "[toLower(parameters('moodleCommon').location)]" + + "documentation4": "eastus2euap region doesn't support storageAccount kind 'FileStorage'. Hence using near prod region.", + "location": "[toLower(parameters('moodleCommon').location)]", + "locationNotCanary": "[if(equals(variables('location'), 'eastus2euap'), 'eastus2', variables('location'))]" }, "outputs": { "storageAccountKey": { From 2e9616059880340291df6186695b99907c21f47e Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Fri, 26 Feb 2021 18:07:42 +0530 Subject: [PATCH 25/33] Use nearest prod region if deployment resource group location is eastus2euap --- migration/azure-fileshare-sa-deploy.json | 5 ++++- migration/azuredeploy-migration.json | 7 ++++++- nested/storageAccount.json | 12 ++++-------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/migration/azure-fileshare-sa-deploy.json b/migration/azure-fileshare-sa-deploy.json index 25ea96b3..b5935210 100644 --- a/migration/azure-fileshare-sa-deploy.json +++ b/migration/azure-fileshare-sa-deploy.json @@ -71,7 +71,10 @@ "variables": { "_artifactsLocation": "https://raw.githubusercontent.com/venu-sivanadham/Moodle/master/", "_artifactsLocationSasToken": "", - "location": "[resourceGroup().location]", + "documentationLine1": "'eastus2euap' is an Azure internal test region. It has limited support for many features such as: 'FileStorage' storageAccount kind etc.", + "documentationLine2": "If resource group location is 'eastus2euap' then use nearest prod region i.e 'eastus2' for deployment.", + "rgLocation": "[toLower(resourceGroup().location)]", + "location": "[if(equals(variables('rgLocation'), 'eastus2euap'), 'eastus2', variables('rgLocation'))]", "moodleCommon": { "baseTemplateUrl": "[concat(variables('_artifactsLocation'), 'nested/')]", "artifactsSasToken": "[variables('_artifactsLocationSasToken')]", diff --git a/migration/azuredeploy-migration.json b/migration/azuredeploy-migration.json index b6574aa6..0fe5ffbf 100644 --- a/migration/azuredeploy-migration.json +++ b/migration/azuredeploy-migration.json @@ -195,7 +195,11 @@ }, "variables": { "_artifactsLocation": "https://raw.githubusercontent.com/venu-sivanadham/Moodle/master/", - "_artifactsLocationSasToken": "" + "_artifactsLocationSasToken": "", + "documentationLine1": "'eastus2euap' is an Azure internal test region. It has limited support for many features such as: 'FileStorage' storageAccount kind etc.", + "documentationLine2": "If resource group location is 'eastus2euap' then use nearest prod region i.e 'eastus2' for deployment.", + "rgLocation": "[toLower(resourceGroup().location)]", + "location": "[if(equals(variables('rgLocation'), 'eastus2euap'), 'eastus2', variables('rgLocation'))]" }, "resources": [ { @@ -235,6 +239,7 @@ "azureSearchSku": { "value": "basic" }, "vNetAddressSpace": { "value": "[parameters('vNetAddressSpace')]"}, "ubuntuVersion": { "value": "[parameters('ubuntuVersion')]"}, + "location": { "value": "[variables('location')]" }, "isMigration": { "value": true } }, "templateLink": { diff --git a/nested/storageAccount.json b/nested/storageAccount.json index 0e00f3c8..8bd96845 100644 --- a/nested/storageAccount.json +++ b/nested/storageAccount.json @@ -14,7 +14,7 @@ "condition": "[not(equals(parameters('moodleCommon').fileServerType, 'azurefiles'))]", "type": "Microsoft.Storage/storageAccounts", "apiVersion": "2019-06-01", - "location": "[variables('locationNotCanary')]", + "location": "[parameters('moodleCommon').location]", "name": "[concat(parameters('moodleCommon').storageAccountName,'naf')]", "kind": "Storage", "sku": { @@ -45,7 +45,7 @@ "condition": "[equals(parameters('moodleCommon').fileServerType, 'azurefiles')]", "type": "Microsoft.Storage/storageAccounts", "apiVersion": "2019-06-01", - "location": "[variables('locationNotCanary')]", + "location": "[parameters('moodleCommon').location]", "name": "[concat(parameters('moodleCommon').storageAccountName,'af')]", "kind": "[if(equals(parameters('moodleCommon').storageAccountType, 'Premium_LRS'), 'FileStorage', 'Storage')]", "sku": { @@ -81,11 +81,7 @@ "documentation2": " storageAccountName - name of storage account", "documentation3": " storageAccountType - type of storage account", "storageName": "[concat(parameters('moodleCommon').storageAccountName,if(equals(parameters('moodleCommon').fileServerType, 'azurefiles'), 'af', 'naf'))]", - "storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]", - - "documentation4": "eastus2euap region doesn't support storageAccount kind 'FileStorage'. Hence using near prod region.", - "location": "[toLower(parameters('moodleCommon').location)]", - "locationNotCanary": "[if(equals(variables('location'), 'eastus2euap'), 'eastus2', variables('location'))]" + "storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]" }, "outputs": { "storageAccountKey": { @@ -97,4 +93,4 @@ "type": "string" } } -} +} \ No newline at end of file From 46fc6c0fdc0e6368535f7de3bbd13e0ce33e670c Mon Sep 17 00:00:00 2001 From: shishir-msft <55269898+shishir-msft@users.noreply.github.com> Date: Thu, 4 Mar 2021 17:23:56 +0530 Subject: [PATCH 26/33] Update azuredeploy-migration.json location southeastasia will be used for deployment if RG is located in 'eastus2euap' location. --- migration/azuredeploy-migration.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/azuredeploy-migration.json b/migration/azuredeploy-migration.json index 0fe5ffbf..136ae9ba 100644 --- a/migration/azuredeploy-migration.json +++ b/migration/azuredeploy-migration.json @@ -197,9 +197,9 @@ "_artifactsLocation": "https://raw.githubusercontent.com/venu-sivanadham/Moodle/master/", "_artifactsLocationSasToken": "", "documentationLine1": "'eastus2euap' is an Azure internal test region. It has limited support for many features such as: 'FileStorage' storageAccount kind etc.", - "documentationLine2": "If resource group location is 'eastus2euap' then use nearest prod region i.e 'eastus2' for deployment.", + "documentationLine2": "If resource group location is 'eastus2euap' then use a prod region for deployment.", "rgLocation": "[toLower(resourceGroup().location)]", - "location": "[if(equals(variables('rgLocation'), 'eastus2euap'), 'eastus2', variables('rgLocation'))]" + "location": "[if(equals(variables('rgLocation'), 'eastus2euap'), 'southeastasia', variables('rgLocation'))]" }, "resources": [ { @@ -254,4 +254,4 @@ "value": "[reference('mainTemplate').outputs]" } } -} \ No newline at end of file +} From 5c384fea75f1a673f7951df4f9e587177e5484da Mon Sep 17 00:00:00 2001 From: shishir-msft <55269898+shishir-msft@users.noreply.github.com> Date: Thu, 4 Mar 2021 17:23:58 +0530 Subject: [PATCH 27/33] Update azure-fileshare-sa-deploy.json location southeastasia will be used for deployment if RG is located in 'eastus2euap' location. --- migration/azure-fileshare-sa-deploy.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/azure-fileshare-sa-deploy.json b/migration/azure-fileshare-sa-deploy.json index b5935210..25052d4c 100644 --- a/migration/azure-fileshare-sa-deploy.json +++ b/migration/azure-fileshare-sa-deploy.json @@ -72,9 +72,9 @@ "_artifactsLocation": "https://raw.githubusercontent.com/venu-sivanadham/Moodle/master/", "_artifactsLocationSasToken": "", "documentationLine1": "'eastus2euap' is an Azure internal test region. It has limited support for many features such as: 'FileStorage' storageAccount kind etc.", - "documentationLine2": "If resource group location is 'eastus2euap' then use nearest prod region i.e 'eastus2' for deployment.", + "documentationLine2": "If resource group location is 'eastus2euap' then use a prod region for deployment.", "rgLocation": "[toLower(resourceGroup().location)]", - "location": "[if(equals(variables('rgLocation'), 'eastus2euap'), 'eastus2', variables('rgLocation'))]", + "location": "[if(equals(variables('rgLocation'), 'eastus2euap'), 'southeastasia', variables('rgLocation'))]", "moodleCommon": { "baseTemplateUrl": "[concat(variables('_artifactsLocation'), 'nested/')]", "artifactsSasToken": "[variables('_artifactsLocationSasToken')]", From 9b0bc75a57286fa3ebf573e92a8471bcf627b687 Mon Sep 17 00:00:00 2001 From: shishir-msft <55269898+shishir-msft@users.noreply.github.com> Date: Wed, 10 Mar 2021 18:58:29 +0530 Subject: [PATCH 28/33] Update azuredeploy-migration.json (#10) Added 8.0 as allowed mysqlversion in parameters --- migration/azuredeploy-migration.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migration/azuredeploy-migration.json b/migration/azuredeploy-migration.json index 136ae9ba..1aa6e425 100644 --- a/migration/azuredeploy-migration.json +++ b/migration/azuredeploy-migration.json @@ -163,7 +163,8 @@ "mysqlVersion": { "allowedValues": [ "5.6", - "5.7" + "5.7", + "8.0" ], "defaultValue": "5.7", "metadata": { From 0625f6eeac382938765d6ba75555b46ff96df0e9 Mon Sep 17 00:00:00 2001 From: shishir-msft <55269898+shishir-msft@users.noreply.github.com> Date: Thu, 11 Mar 2021 12:02:19 +0530 Subject: [PATCH 29/33] Revert "Update azuredeploy-migration.json (#10)" (#11) This reverts commit 9b0bc75a57286fa3ebf573e92a8471bcf627b687. --- migration/azuredeploy-migration.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/migration/azuredeploy-migration.json b/migration/azuredeploy-migration.json index 1aa6e425..136ae9ba 100644 --- a/migration/azuredeploy-migration.json +++ b/migration/azuredeploy-migration.json @@ -163,8 +163,7 @@ "mysqlVersion": { "allowedValues": [ "5.6", - "5.7", - "8.0" + "5.7" ], "defaultValue": "5.7", "metadata": { From 3acd658398d7f4d8f5d09765c0cc41a0677a7206 Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Thu, 18 Mar 2021 09:14:02 +0530 Subject: [PATCH 30/33] Mapping unsupported regions to default region 'southeastasia' --- migration/azure-fileshare-sa-deploy.json | 10 +++++++--- migration/azuredeploy-migration.json | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/migration/azure-fileshare-sa-deploy.json b/migration/azure-fileshare-sa-deploy.json index 25052d4c..be7735da 100644 --- a/migration/azure-fileshare-sa-deploy.json +++ b/migration/azure-fileshare-sa-deploy.json @@ -71,10 +71,14 @@ "variables": { "_artifactsLocation": "https://raw.githubusercontent.com/venu-sivanadham/Moodle/master/", "_artifactsLocationSasToken": "", - "documentationLine1": "'eastus2euap' is an Azure internal test region. It has limited support for many features such as: 'FileStorage' storageAccount kind etc.", - "documentationLine2": "If resource group location is 'eastus2euap' then use a prod region for deployment.", + "unsupportedLocations": [ + "eastus2euap", + "westcentralus" + ], + "documentationLine1": "Some of the Azure Services used by moodle migration are not available in few regions. Those regions are declared above.", + "documentationLine2": "If resource group belong to one of those unsupported regions, then use default region 'southeastasia' for deployment.", "rgLocation": "[toLower(resourceGroup().location)]", - "location": "[if(equals(variables('rgLocation'), 'eastus2euap'), 'southeastasia', variables('rgLocation'))]", + "location": "[if(contains(variables('unsupportedLocations'), variables('rgLocation')), 'southeastasia', variables('rgLocation'))]", "moodleCommon": { "baseTemplateUrl": "[concat(variables('_artifactsLocation'), 'nested/')]", "artifactsSasToken": "[variables('_artifactsLocationSasToken')]", diff --git a/migration/azuredeploy-migration.json b/migration/azuredeploy-migration.json index 136ae9ba..45ea4e3e 100644 --- a/migration/azuredeploy-migration.json +++ b/migration/azuredeploy-migration.json @@ -196,10 +196,14 @@ "variables": { "_artifactsLocation": "https://raw.githubusercontent.com/venu-sivanadham/Moodle/master/", "_artifactsLocationSasToken": "", - "documentationLine1": "'eastus2euap' is an Azure internal test region. It has limited support for many features such as: 'FileStorage' storageAccount kind etc.", - "documentationLine2": "If resource group location is 'eastus2euap' then use a prod region for deployment.", + "unsupportedLocations": [ + "eastus2euap", + "westcentralus" + ], + "documentationLine1": "Some of the Azure Services used by moodle migration are not available in few regions. Those regions are declared above.", + "documentationLine2": "If resource group belong to one of those unsupported regions, then use default region 'southeastasia' for deployment.", "rgLocation": "[toLower(resourceGroup().location)]", - "location": "[if(equals(variables('rgLocation'), 'eastus2euap'), 'southeastasia', variables('rgLocation'))]" + "location": "[if(contains(variables('unsupportedLocations'), variables('rgLocation')), 'southeastasia', variables('rgLocation'))]" }, "resources": [ { From e2ec9c8feb6a0ca0c64fe77a32f366b362ec9a95 Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Fri, 26 Mar 2021 10:35:20 +0530 Subject: [PATCH 31/33] Making 'westus' as default location for migration templates --- migration/azure-fileshare-sa-deploy.json | 4 ++-- migration/azuredeploy-migration.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/migration/azure-fileshare-sa-deploy.json b/migration/azure-fileshare-sa-deploy.json index be7735da..50670f26 100644 --- a/migration/azure-fileshare-sa-deploy.json +++ b/migration/azure-fileshare-sa-deploy.json @@ -76,9 +76,9 @@ "westcentralus" ], "documentationLine1": "Some of the Azure Services used by moodle migration are not available in few regions. Those regions are declared above.", - "documentationLine2": "If resource group belong to one of those unsupported regions, then use default region 'southeastasia' for deployment.", + "documentationLine2": "If resource group belong to one of those unsupported regions, then use default region 'westus' for deployment.", "rgLocation": "[toLower(resourceGroup().location)]", - "location": "[if(contains(variables('unsupportedLocations'), variables('rgLocation')), 'southeastasia', variables('rgLocation'))]", + "location": "[if(contains(variables('unsupportedLocations'), variables('rgLocation')), 'westus', variables('rgLocation'))]", "moodleCommon": { "baseTemplateUrl": "[concat(variables('_artifactsLocation'), 'nested/')]", "artifactsSasToken": "[variables('_artifactsLocationSasToken')]", diff --git a/migration/azuredeploy-migration.json b/migration/azuredeploy-migration.json index 45ea4e3e..415a19b3 100644 --- a/migration/azuredeploy-migration.json +++ b/migration/azuredeploy-migration.json @@ -201,9 +201,9 @@ "westcentralus" ], "documentationLine1": "Some of the Azure Services used by moodle migration are not available in few regions. Those regions are declared above.", - "documentationLine2": "If resource group belong to one of those unsupported regions, then use default region 'southeastasia' for deployment.", + "documentationLine2": "If resource group belong to one of those unsupported regions, then use default region 'westus' for deployment.", "rgLocation": "[toLower(resourceGroup().location)]", - "location": "[if(contains(variables('unsupportedLocations'), variables('rgLocation')), 'southeastasia', variables('rgLocation'))]" + "location": "[if(contains(variables('unsupportedLocations'), variables('rgLocation')), 'westus', variables('rgLocation'))]" }, "resources": [ { From c0ce0c80a2550e19ef8bac270500c3765436673e Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Tue, 30 Mar 2021 13:30:38 +0530 Subject: [PATCH 32/33] Changed artifacts location to point to main Azure Moodle branch --- migration/azure-fileshare-sa-deploy.json | 2 +- migration/azuredeploy-migration.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/azure-fileshare-sa-deploy.json b/migration/azure-fileshare-sa-deploy.json index 50670f26..71aba04e 100644 --- a/migration/azure-fileshare-sa-deploy.json +++ b/migration/azure-fileshare-sa-deploy.json @@ -69,7 +69,7 @@ } }, "variables": { - "_artifactsLocation": "https://raw.githubusercontent.com/venu-sivanadham/Moodle/master/", + "_artifactsLocation": "https://raw.githubusercontent.com/Azure/Moodle/master/", "_artifactsLocationSasToken": "", "unsupportedLocations": [ "eastus2euap", diff --git a/migration/azuredeploy-migration.json b/migration/azuredeploy-migration.json index 415a19b3..287367b9 100644 --- a/migration/azuredeploy-migration.json +++ b/migration/azuredeploy-migration.json @@ -194,7 +194,7 @@ } }, "variables": { - "_artifactsLocation": "https://raw.githubusercontent.com/venu-sivanadham/Moodle/master/", + "_artifactsLocation": "https://raw.githubusercontent.com/Azure/Moodle/master/", "_artifactsLocationSasToken": "", "unsupportedLocations": [ "eastus2euap", From 70c6bb471b4b40aa54eef2d1a43638c4dd125a38 Mon Sep 17 00:00:00 2001 From: Venu Shivanadham Date: Thu, 8 Apr 2021 11:27:08 +0530 Subject: [PATCH 33/33] Addressed review comments --- migration/azure-fileshare-sa-deploy.json | 2 +- migration/azuredeploy-migration.json | 2 +- nested/storageAccount.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/azure-fileshare-sa-deploy.json b/migration/azure-fileshare-sa-deploy.json index 71aba04e..9e744cc4 100644 --- a/migration/azure-fileshare-sa-deploy.json +++ b/migration/azure-fileshare-sa-deploy.json @@ -16,7 +16,7 @@ "type": "string" }, "fileServerDiskSize": { - "defaultValue": "100", + "defaultValue": "1024", "metadata": { "description": "Size of the azure file share in GB." }, diff --git a/migration/azuredeploy-migration.json b/migration/azuredeploy-migration.json index 287367b9..a3fc5aa0 100644 --- a/migration/azuredeploy-migration.json +++ b/migration/azuredeploy-migration.json @@ -172,7 +172,7 @@ "type": "string" }, "fileServerDiskSize": { - "defaultValue": "100", + "defaultValue": "1024", "metadata": { "description": "Size per disk for gluster nodes or nfs server" }, diff --git a/nested/storageAccount.json b/nested/storageAccount.json index 8bd96845..bbdbafe8 100644 --- a/nested/storageAccount.json +++ b/nested/storageAccount.json @@ -93,4 +93,4 @@ "type": "string" } } -} \ No newline at end of file +}