Move Moodle autoscale templates to replace older scalable templates

This commit is contained in:
Ross Gardler 2018-01-08 18:08:57 +00:00
Родитель 12b13a9c46
Коммит 6db5dadfe5
41 изменённых файлов: 7768 добавлений и 1794 удалений

185
README.md
Просмотреть файл

@ -1,102 +1,131 @@
# MoodleAzure
High available, high scalable Moodle deployment using Azure Resource Manager Template
# *Autoscaling Moodle stack for Postgres and MySQL databases*
[![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fpateixei%2FMoodleAzure%2Fv2%2Fazuredeploy.json) [![Visualize](https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/1-CONTRIBUTION-GUIDE/images/visualizebutton.png)](http://armviz.io/#/?load=https%3A%2F%2Fraw.githubusercontent.com%2Fpateixei%2FMoodleAzure%2Fv2%2Fazuredeploy.json)
This work is mostly based on Paulo Teixeira's work. It adds several configurable features and switches to a web stack with caching. It also uses Azure resources for Redis, ObjectFS and Databases.
This Azure Resource Manager template creates a clustered, multi-layered moodle environment.
With this template we have three main components being deployed:
- a web application layer with VMSS and auto-scale enabled
- a database layer composed of a MariaDb Galera cluster
- a shared filesystem layer, for the "moodledata" content.
After deploying, these templates will provide you with a new Moodle site with caching for speed and scaling frontends to handle PHP load. The filesystem behind it is mirrored for high availability and optionally backed up through Azure. Filesystem permissions and options have also been tuned to make Moodle more secure than a default install.
Main differences from other existing Moodle templates:
- web layer uses a VMScale Set with auto-scale configured, allowing better usage of resources (02 to 10 web nodes possible)
- database layer was built using MariaDb Galera Cluster, in a high-available setup, providing 99.95% SLA
- filesystem layer (MoodleData) was built on top of VMs with Premium Disks, supporting very intensive IO scenarios; also built on top of GlusterFS, a high scalable storage solution from RedHat (see www.glusterfs.org for details), in a High Available setup (data replication accross cluster nodes, also providing a 99.95% SLA).
- Customer can define the size (small, medium, large) for database and filesystem layers
- Azure Redis Cache is deployed in the solution, to be used as Moodle Session Cache backend (manual setup required in moodle)
- it was built for Moodle 3.x deployments
- Azure Backup can be enabled for VMS hosting MariaDb Database and Moodledata content (very important for DR scenarios)
- Apache is configured with SSL support (using a self-signed certificate), allowing custom certificates with desired.
[![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fmoodle-scalable-cluster-ubuntu%2Fazuredeploy.json) [![Visualize](https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/1-CONTRIBUTION-GUIDE/images/visualizebutton.png)](http://armviz.io/#/?load=https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fmoodle-scalable-cluster-ubuntu%2Fazuredeploy.json)
Summarizing, the following resources will be created during this process:
`Tags: cluster, ha, moodle, autoscale, linux, ubuntu`
- a Virtual Machine Scale Set (up to 10 instances) for the web tier, with auto-scale configured
- 02 nodes Gluster Cluster (2 Premium disks attached, raid0, a gluster brick in each virtual machine), data replicated accross nodes in a HA setup for the filesystem layer
- 02 nodes MariaDb 10 Active-Active Cluster (Galera Cluster), in a HA setup scenario for the database layer
- an Internal Load Balancer in front of the MariaDb cluster
- an public Load Balancer in front of the Virtual Machine Scale Set (web layer)
- a virtual machine used as a JumpBox for the environment, acessible via SSH
- a redis cache to be used for Moodle Session Cache (manual setup required in Moodle)
- a lot of underlying resources need for the environment (virtual network, storage accounts, etc)
## *What this stack will give you*
![Moodle On Azure](./images/moodle-on-azure.jpg)
This template set deploys the following infrastructure:
- Autoscaling web frontend layer (Nginx, php-fpm, Varnish)
- Private virtual network for frontend instances
- Controller instance running cron and handling syslog for the autoscaled site
- Load balancer to balance across the autoscaled instances
- Postgres or MySQL database
- Azure Redis instance for Moodle caching
- ObjectFS in Azure blobs (Moodle sitedata)
- Three Elasticsearch VMs for search indexing in Moodle
- Dual gluster nodes for high availability access to Moodle files
## *Parameters for the deployment*
![network_diagram](images/stack_diagram.jpg "Diagram of deployed stack")
- resourcesPrefix: Prefix for storage account name, network, virtual machines, and so on. Important: must be a unique value in the azure region; if you reach some error during the deployment, please confirm it's not being used by any other deployment (including from other people)
- vNetAddressSpace: Address range for the Moodle virtual network - presumed /16 - further subneting during vnet creation
- moodleVersion: The Moodle version you want to install.
- glusterTshirtSize: VM size for the gluster nodes (please check for more guidance below)
- mariaDbTshirtSize: VM size for the mariadb nodes (please check for more guidance below)
- adminUsername: ssh user name (do not use 'root' or 'administrator', using any of these will cause the deployment to fail)
- adminPassword: ssh password & moodle 'admin' password
- mySqlUserPassword: my sql regular user password
- mySqlRootPassword: my sql root user password (take note of this, would be necessary for database maintenance tasks)
- applyScriptsSwitch: Use '1' ALWAYS; Switch to process or bypass all scripts/extensions; if you use '0' (zero), this template will only create the machines;
- azureBackupSwitch: Switch to configure AzureBackup and enlist VM's; if you use '1', Azure Backup will be configured to backup MariaDb and GlusterFS nodes; highly recommended. The backup schedule can be adjusted later in the portal.
*Accessing Moodle administrative area*
## *Deployment steps*
In order to access Moodle admin console, please use the username 'admin' (without quotes) and the password you provided during the setup in Azure Portal.
You can click the "deploy to Azure" button at the beginning of this document or alternatively perform a deploy from the command line:
## *Sizing the environment*
### *Command line deploys*
Once you've checked out the templates from git, you'll want to use the [Azure CLI tool](https://docs.microsoft.com/en-us/cli/azure/overview?view=azure-cli-latest) to deploy them. First off you'll want to create a group with these:
### Gluster and MariaDb
The setup script will ask you about the 't-shirt size' for database & gluster layers.
Here's an explanation for each one of them:
`az group create --name <stackname> --location <location>`
Gluster t-shirt sizes:
Note that some locations in Azure might not support features or certain VM tiers.
tshirt | VM Size | Disk Count | Disk Size | Total Size
-------|-----------------|------------|-----------|------------
Small | Standard_DS2_v2 | 4 | 127 Gb | 512 Gb
Medium | Standard_DS3_v2 | 2 | 512 Gb | 1 Tb
Large | Standard_DS4_v2 | 2 | 1023 Gb | 2 Tb
Next you'll want to either deploy and enter in all parameters manually:
MariaDb t-shirt sizes:
`az group deployment create --name moodle-autoscale --resource-group <stackname> --template-file azuredeploy.json`
tshirt | VM Size | Disk Count | Disk Size | Total Size
-------|-----------------|------------|-----------|------------
Small | Standard_DS2_v2 | 2 | 127 Gb | 256 Gb
Medium | Standard_DS3_v2 | 2 | 512 Gb | 1 Tb
Large | Standard_DS4_v2 | 2 | 1023 Gb | 2 Tb
Alternatively, you can configure all your variables in the "azuredeploy.parameters.json" file and run:
There's no default rule or recommendation in order to decide which tier use for your deployment.
However, as an initial guidance, remember that:
- Moodle has a strong dependency of database setup; for a high number of simultanous users, consider using medium or large database sizes
- GlusterFS must be dimensioned considering the space requirements (size of your moodledata) + number of IOPS required. A Moodle deployment where students upload lots of content in a small windows of time would require more IOPS during that window, so consider using medium or large tiers in that case;
`az group deployment create --name moodle-autoscale --resource-group <stackname> --template-file azuredeploy.json --parameters azuredeploy.parameters.json`
### The web layer
Note that `siteURL` is a special case in the `azuredeploy.parameters.json` files. If you do not define a value for `siteURL` or if you leave it as the default "www.example.org" this value will be overwritten by the template to be a calculated value for the public load balancers of your deployment. This allows you to experiment with this Moodle template without configuring a new domain name whilst still enabling Moodle to be configured with a production URL when appropriate. See the next section for instructions on retrieving the generated DNS name if necesary.
This script deploys a vm scale set (vmss) for the web layer. It's configured with Standard_DS2_v2 instances, with no data-disks, all connected to the GlusterFS cluster (mounted in the /moodle folder where source code, moodledata and ssl certificates resides).
The VMSS is also configured with auto-scale settings and will run, at minimum 02 instances up to 10 instances of the web application; the trigger for deploying additional instances is based on CPU usage. Those settings can be ajusted in Azure Portal or in the Azure Resources Editor (resources.azure.com).
Depending on what tiers you selected for VMs and the database you will be looking at roughly 1-2 hours for a full deploy. See below for selectable parameters.
## *Updating the source code or Apache SSL certificates*
## *Using the created stack*
There's a jumpbox machine in the deployment that can be used to update Moodle's source code, or SSL certificates in the web layer.
In order to proceed with this kind of update, connect to the machine using the root credentials provided during the template setup.
- Moodle source code is located at /moodle/html/moodle
- Apache SSL certificates are located at /moodle/certs
- Moodledata content is located at /moodle/moodledata
In testing, stacks typically took between 1 and 2 hours to finish, depending on spec. Once this is done you will receive a JSON with outputs needed to continue setup. These outputs are also available by clicking on the deployment for your resource group when it finishes. They are:
## *Step by step video walkthrough*
- moodle-admin-password: The password for the "admin" user in your Moodle install.
- load-balancer-dns: This is the address of your load balancer. You'll need to add a DNS entry for the website URL you entered that CNAMEs to this.
- controller-instance-ip: This is the address of the controller. You will need to SSH into this to make changes to your moodle code or view logs.
- database-dns: This is the public DNS of your database instance. If you wish to set up local backups or access the db directly, you'll need to use this.
- database-admin-username: The master account (not Moodle) username for your database.
- database-admin-password: The master account password for your database.
We also have a [step by step video](http://learningcontentdemo.azurewebsites.net/VideoHowToDemoMoodleOnAzure3) showing us how to deploy this template (Thanks to Ingo Laue for his contribution)
This template is aimed to have constant updates, and would include other improvements in the future.
Hope it helps.
Feedbacks are welcome.
Once moodle has been created, and with DNS pointing to the load balancer, you should be able to load the siteurl you entered and log in with "admin" and the password supplied in the moodle-admin-password output.
### *Updating Moodle code/settings*
Your controller VM has Moodle code and data stored on /moodle. The code is stored in /moodle/html/moodle/. This is also mounted to your autoscaled frontends so all changes are instant. Depending on how large your Gluster disks are sized, it may be helpful to keep multiple older versions (/moodle/html1, /moodle/html2, etc) to roll back if needed.
### *Getting an SQL dump*
A daily sql dump of your database is taken at 02:22 and saved to /moodle/db-backup.sql(.gz). If your database is small enough to fit, you may be able to get a more current SQL dump of your Moodle db by dumping it to /moodle/. Otherwise, you'll want to do this remotely by connecting to the hostname shown in the database-dns output using the database-admin-username and database-admin-password.
While Azure does not currently back up Postgres/MySQL databases, by dumping it to /moodle it is included in the Gluster VM backups should you enable Recovery Services in your parameters.
### *Azure Recovery Services*
If you have set azureBackupSwitch to 1 then Azure will provide VM backups of your Gluster node. This is recommended as it contains both your Moodle code and your sitedata. Restoring a backed up VM is outside the scope of this doc, but Azure's documentation on Recovery Services can be found here: https://docs.microsoft.com/en-us/azure/backup/backup-azure-vms-first-look-arm
### *Resizing your Database*
Note: This involves a lengthy site downtime.
As mentioned above, Azure does not currently support resizing databases. You can, however, create a new database instance and change your config to point to that. To get a different size database you'll need to:
1. Place your Moodle site into maintenance mode. You can do this either via the web interface or the command line on the controller VM.
2. Perform an SQL dump of your database, either to /moodle or remotely to your machine.
3. Create a new Azure database of the size you want inside your existing resource group.
4. Using the details in your /moodle/html/moodle/config.php create a new user and database matching the details in config.php. Make sure to grant all rights on the db to the user.
5. On the controller instance, change the db setting in /moodle/html/moodle/config.php to point to the new database.
6. Take Moodle site out of maintenance mode.
7. Once confirmed working, delete the previous database instance.
How long this takes depends entirely on the size of your database and the speed of your VM tier. It will always be a large enough window to make a noticeable outage.
### *Changing the SSL cert*
The self-signed cert generated by the template is suitable for very basic testing, but a public website will want a real cert. After purchasing a trusted certificate, it can be copied to the following files to be ready immediately:
- /moodle/certs/nginx.key: Your certificate's private key
- /moodle/certs/nginx.crt: Your combined signed certificate and trust chain certificate(s).
Once replaced these changes become effective immediately.
## *Sizing Considerations and Limitations*
Depending on what you're doing with Moodle, there are several considerations to make when configuring. The defaults included produce a cluster that is inexpensive but probably too low spec to use beyond single-user Moodle testing.
It should be noted that as of the time of this writing both Postgres and MySQL databases are in preview at Azure. In the future larger DB sizes or different VM sizes will be available. The templates will allow you to select whatever size you want, but there are restrictions in place (VMs with certain storage types, disk size for database tiers, etc) that may prevent certains selections from working together.
### *Database Sizing*
As of the time of this writing, Azure supports "Basic" and "Standard" tiers for database instances. In addition the skuCapacityDTU defines Compute Units, and the number of those you can use is limited by database tier:
- Basic: 50, 100
- Standard: 100, 200, 400, 800
This value also limits the maximum number of connections, as defined here: https://docs.microsoft.com/en-us/azure/mysql/concepts-limits
As the Moodle database will handle cron processes as well as the website, any public facing website with more than 10 users will likely require upgrading to 100. Once the site reaches 30+ users it will require upgrading to Standard for more compute units. This depends entirely on the individual site. As MySQL databases cannot change (or be restored to a different tier) once deployed it is a good idea to slightly overspec your database.
Standard instances have a minimum storage requirement of 128000MB. All database storage, regardless of tier, has a hard upper limit of 1 terrabyte. After 128GB you gain additional iops for each GB, so if you're expecting a heavy amount of traffic you will want to oversize your storage. The current maximum iops with a 1TB disk is 3000.
### *Controller instance sizing*
The controller handles both syslog and cron duties. Depending on how big your Moodle cron runs are this may not be sufficient. If cron jobs are very delayed and cron processes are building up on the controller then an upgrade in tier is needed.
### *Frontend instances*
In general the frontend instances will not be the source of any bottlenecks unless they are severely undersized versus the rest of the cluster. More powerful instances will be needed should fpm processes spawn and exhaust memory during periods of heavy site load. This can also be mitigated against by increasing the number of VMs but spawning new VMs is slower (and potentially more expensive) than having that capacity already available.
It is worth noting that the memory allowances on these instances allow for more memory than they may be able to provide with lower instance tiers. This is intentional as you can opt to run larger VMs with more memory and not require manual configuration. FPM also allows for a very large number of threads which prevents the system from failing during many small jobs.

Просмотреть файл

@ -1,213 +1,614 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourcesPrefix": { "type": "string", "defaultValue": "changeme", "metadata": {"description": "Prefix of storage account name, network, virtual machines, and so on"} },
"vNetAddressSpace": { "type": "string", "defaultValue": "172.31.0.0", "metadata": {"description": "Address range for the Moodle virtual network - presumed /16 - further subneting during vnet creation"} },
"moodleVersion": { "type": "string", "defaultValue": "MOODLE_32_STABLE", "metadata": {"description": "The Moodle version you want to install."}, "allowedValues": ["MOODLE_33_STABLE","MOODLE_32_STABLE","MOODLE_31_STABLE","MOODLE_30_STABLE","MOODLE_29_STABLE"] },
"glusterTshirtSize": { "type": "string", "defaultValue": "Small", "metadata": {"description": "VM size for the gluster nodes"}, "allowedValues": ["Small","Medium","Large"] },
"mariaDbTshirtSize": { "type": "string", "defaultValue": "Small", "metadata": {"description": "VM size for the mariadb nodes"}, "allowedValues": ["Small","Medium","Large"] },
"adminUsername": { "type": "string", "defaultValue": "azureadmin", "metadata": {"description": "ssh user name"}},
"adminPassword": { "type": "securestring", "metadata": {"description": "ssh password"}},
"mySqlUserPassword": { "type": "securestring", "metadata": {"description": "my sql regular user password"}},
"mySqlRootPassword": { "type": "securestring", "metadata": {"description": "my sql root user password"}},
"applyScriptsSwitch": { "type": "int", "defaultValue": 1, "metadata": {"description": "Switch to process or bypass all scripts/extensions"}, "allowedValues": [ 0,1 ] },
"azureBackupSwitch": { "type": "int", "defaultValue": 0, "metadata": {"description": "Switch to configure AzureBackup and enlist VM's"}, "allowedValues": [ 0,1 ] }
},
"variables": {
"documentation01": "This main-template calls multiple sub-templates to create the moodle system",
"documentation02": " recoveryservices0 - dummy template (see next statement)",
"documentation03": " recoveryservices1 - creates a recovery vault that will be subsequently used by the VM Backup - a paramter swtich controls whethe is is called or bypassed",
"documentation04": " redis - creates a redis cache",
"documentation05": " vnet - creates a virtual network with three subnets",
"documentation06": " gluster - creates a gluster file system on a vm farm",
"documentation07": " mariadbb - creates a mariadb (nosql) on a vm farm",
"documentation08": " webvmss - creates a vm scale set",
"documentation09": " controller - creates a jumpbox and deploys code",
"documentation10": "Three sizing parameters are provided, one each for the gluster system, the mariadb system and one for the jumpbox",
"documentation11": "MariaDb Sizing guidance:",
"documentation12": "Small - 0-2000 simultaneous users",
"documentation13": "Medium - 2001-5000 simultaneous users",
"documentation14": "Large - more than 5001 simultaneous users",
"documentation15": "GlusterFS Sizing guidance",
"documentation16": "Small - small number of courses, low interactiviness in the courses, low IOPSs required",
"documentation17": "Medium - interactive courses, with uploads; medium number of IOPS required",
"documentation18": "Large - very interactive courses, highly concurrent or high number of courses in the same environemnt; burst IOPS required, during certain period of time",
"octets": "[split(parameters('vNetAddressSpace'), '.')]",
"rpfx": "[tolower(parameters('resourcesPrefix'))]",
"moodleCommon": {
"baseTemplateUrl": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/moodle-scalable-cluster-ubuntu/nested/",
"scriptLocation": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/moodle-scalable-cluster-ubuntu/scripts/",
"computeApi": "2016-04-30-preview",
"mariaDbScriptFilename" : "install_mariadb.sh", "mariadbVmCount": 2,
"glusterScriptFilename" : "install_gluster.sh", "glusterVmCount": 2,
"moodleInstallScriptFilename": "install_moodle.sh",
"moodleSetupScriptFilename" : "setup_moodle.sh",
"osType": { "publisher": "Canonical", "offer": "UbuntuServer", "sku": "14.04.4-LTS", "version": "latest" },
"resourcesPrefix": "[ variables('rpfx')]",
"vNetAddressSpace": "[parameters('vNetAddressSpace')]",
"subnetWebRange": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),0)), '.0/24' ) ]", "subnetWebPrefix": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),0))) ]",
"subnetSanRange": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),1)), '.0/24' ) ]", "subnetSanPrefix": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),1))) ]",
"subnetDbRange": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),2)), '.0/24' ) ]", "subnetDbPrefix": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),2))) ]", "StaticIpMariaDb": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),2)),'.250') ]",
"moodleVersion": "[parameters('moodleVersion')]",
"glusterTshirtSize": "[parameters('glusterTshirtSize')]",
"mariaDbTshirtSize": "[parameters('mariaDbTshirtSize')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]",
"mySqlUserPassword": "[parameters('mySqlUserPassword')]",
"mySqlRootPassword": "[parameters('mySqlRootPassword')]",
"applyScriptsSwitch": "[parameters('applyScriptsSwitch')]",
"azureBackupSwitch": "[parameters( 'azureBackupSwitch')]",
"vnetName": "[concat( variables('rpfx'),'-vnet') ]",
"subnetWeb": "[concat( 'web-',variables('rpfx'),'-subnet')]",
"subnetSan": "[concat( 'san-',variables('rpfx'),'-subnet')]",
"subnetDb": "[concat('data-',variables('rpfx'),'-subnet')]",
"lbName": "[concat( 'lb-',variables('rpfx'))]",
"extFeName": "[concat( 'lb-',variables('rpfx'),'-FE')]",
"extBeName": "[concat( 'lb-',variables('rpfx'),'-BE')]",
"extProbe": "[concat( 'lb-',variables('rpfx'),'-Probe')]",
"extNatPool": "[concat( 'lb-',variables('rpfx'),'-NatPool')]",
"lbPipName": "[concat( 'lb-',variables('rpfx'),'-ip')]",
"lbDnsName": "[concat( 'lb-',variables('rpfx'))]",
"gfxAvailabilitySetName": "[concat( 'gfs-',variables('rpfx'),'-as')]",
"gfsNameRoot": "[concat( 'gfs' ,variables('rpfx'), 'vm')]",
"dbAvailabilitySetName": "[concat( 'db-',variables('rpfx'),'-as')]",
"dbNameRoot": "[concat( 'db' ,variables('rpfx'), 'vm')]",
"dbLoadBalancerName": "[concat( 'db-',variables('rpfx'),'-lb')]",
"dbFeName": "[concat( 'db-',variables('rpfx'),'-FE')]",
"dbBeName": "[concat( 'db-',variables('rpfx'),'-BE')]",
"dbProbe": "[concat( 'db-',variables('rpfx'),'-Probe')]",
"jboxPipName": "[concat('jbox',variables('rpfx'))]",
"jboxNicName": "[concat('jbox',variables('rpfx'),'vm-nic')]",
"jboxNsgName": "[concat('jbox',variables('rpfx'),'-nsg')]",
"jboxVmName": "[concat('jbox',variables('rpfx'),'vm')]",
"vmssName": "[concat('vmss',variables('rpfx') )]",
"vmssdStorageAccounttName": "[concat('vmss',uniqueString(resourceGroup().id) )]",
"vaultName": "[concat( variables('rpfx'),'-vault' )]",
"policyName": "[concat( variables('rpfx'),'-policy' )]",
"redisCacheName": "[concat( variables('rpfx'),'-redis' )]"
}
"applyScriptsSwitch": {
"allowedValues": [
0,
1
],
"defaultValue": 1,
"metadata": {
"description": "Switch to process or bypass all scripts/extensions"
},
"type": "int"
},
"azureBackupSwitch": {
"allowedValues": [
0,
1
],
"defaultValue": 0,
"metadata": {
"description": "Switch to configure AzureBackup and enlist VM's"
},
"type": "int"
},
"blobStorageAccountType": {
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS",
"Standard_ZRS",
"Premium_LRS"
],
"metadata": {
"description": "Blob Storage Account type"
},
"type": "string"
},
"dbServerType": {
"defaultValue": "postgres",
"allowedValues": [
"postgres",
"mysql"
],
"metadata": {
"description": "Database type"
},
"type": "string"
},
"controllerVmSku": {
"defaultValue": "Standard_DS1_v2",
"metadata": {
"description": "VM size for the controller node"
},
"type": "string"
},
"autoscaleVmSku": {
"defaultValue": "Standard_DS2_v2",
"metadata": {
"description": "VM size for autoscaled nodes"
},
"type": "string"
},
"autoscaleVmCount": {
"defaultValue": 10,
"metadata": {
"description": "Maximum number of autoscaled nodes"
},
"type": "int"
},
"elasticVmSku": {
"defaultValue": "Standard_DS2_v2",
"metadata": {
"description": "VM size for the elastic search nodes"
},
"type": "string"
},
"firewallRuleName": {
"defaultValue": "open-to-the-world",
"metadata": {
"description": "Database firewall rule name"
},
"type": "string"
},
"gatewaySubnet": {
"allowedValues": [
"GatewaySubnet"
],
"defaultValue": "GatewaySubnet",
"metadata": {
"description": "name for Virtual network gateway subnet"
},
"type": "string"
},
"gatewayType": {
"allowedValues": [
"Vpn",
"ER"
],
"defaultValue": "Vpn",
"metadata": {
"description": "Virtual network gateway type"
},
"type": "string"
},
"glusterVmSku": {
"defaultValue": "Standard_DS2_v2",
"metadata": {
"description": "VM size for the gluster nodes"
},
"type": "string"
},
"glusterDiskSize": {
"defaultValue": 127,
"metadata": {
"description": "Size per disk for gluster nodes"
},
"type": "int"
},
"glusterDiskCount": {
"defaultValue": 4,
"metadata": {
"description": "Number of disks in raid0 per gluster node"
},
"type": "int"
},
"moodleVersion": {
"allowedValues": [
"MOODLE_34_STABLE",
"MOODLE_33_STABLE",
"MOODLE_32_STABLE",
"MOODLE_31_STABLE",
"MOODLE_30_STABLE",
"MOODLE_29_STABLE"
],
"defaultValue": "MOODLE_34_STABLE",
"metadata": {
"description": "The Moodle version you want to install."
},
"type": "string"
},
"dbLogin": {
"defaultValue": "dbadmin",
"metadata": {
"description": "Database admin username"
},
"type": "string"
},
"siteURL": {
"defaultValue": "www.example.org",
"metadata": {
"description": "URL for Moodle site"
},
"type": "string"
},
"skuCapacityDTU": {
"allowedValues": [
50,
100,
200,
400,
800
],
"defaultValue": 50,
"metadata": {
"description": "Postgresql database trasaction units"
},
"type": "int"
},
"skuFamily": {
"allowedValues": [
"SkuFamily"
],
"defaultValue": "SkuFamily",
"metadata": {
"description": "Postgresql sku family"
},
"type": "string"
},
"skuName": {
"allowedValues": [
"PGSQLB50",
"PGSQLB100",
"PGSQLS100",
"PGSQLS200",
"PGSQLS400",
"PGSQLS800",
"MYSQLB50",
"MYSQLB100",
"MYSQLS100",
"MYSQLS200",
"MYSQLS400",
"MYSQLS800"
],
"defaultValue": "PGSQLB50",
"metadata": {
"description": "Postgresql sku name"
},
"type": "string"
},
"skuSizeMB": {
"defaultValue": 51200,
"metadata": {
"description": "Postgresql sku size in mb"
},
"type": "int"
},
"skuTier": {
"allowedValues": [
"Basic",
"Standard"
],
"defaultValue": "Basic",
"metadata": {
"description": "Postgresql sku tier"
},
"type": "string"
},
"sshPublicKey": {
"metadata": {
"description": "ssh public key"
},
"type": "string"
},
"sshUsername": {
"defaultValue": "azureadmin",
"metadata": {
"description": "ssh user name"
},
"type": "string"
},
"sslEnforcement": {
"allowedValues": [
"Disabled",
"Enabled"
],
"defaultValue": "Disabled",
"metadata": {
"description": "Postgresql SSL connection"
},
"type": "string"
},
"postgresVersion": {
"allowedValues": [
"9.5",
"9.6"
],
"defaultValue": "9.6",
"metadata": {
"description": "Postgresql version"
},
"type": "string"
},
"mysqlVersion": {
"allowedValues": [
"5.6",
"5.7"
],
"defaultValue": "5.7",
"metadata": {
"description": "Mysql version"
},
"type": "string"
},
"vNetAddressSpace": {
"defaultValue": "172.31.0.0",
"metadata": {
"description": "Address range for the Moodle virtual network - presumed /16 - further subneting during vnet creation"
},
"type": "string"
},
"vpnType": {
"allowedValues": [
"RouteBased",
"PolicyBased"
],
"defaultValue": "RouteBased",
"metadata": {
"description": "Virtual network gateway vpn type"
},
"type": "string"
}
},
"resources": [
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"name" : "recoveryTemplate",
{
"apiVersion": "2015-01-01",
"name": "dbTemplate",
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[variables('moodleCommon')]"
}
},
"templateLink": {
"uri": "[concat(variables('moodleCommon').baseTemplateUrl, parameters('dbServerType'), '.json')]"
}
},
"type": "Microsoft.Resources/deployments"
},
{
"apiVersion": "2015-01-01",
"name": "recoveryTemplate",
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[variables('moodleCommon')]"
}
},
"templateLink": {
"uri": "[concat(variables('moodleCommon').baseTemplateUrl,'recoveryservices',variables('moodleCommon').azureBackupSwitch,'.json')]"
}
},
"type": "Microsoft.Resources/deployments"
},
{
"apiVersion": "2015-01-01",
"name": "redisTemplate",
"dependsOn": [
"Microsoft.Resources/deployments/networkTemplate"
],
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[variables('moodleCommon')]"
}
},
"templateLink": {
"uri": "[concat(variables('moodleCommon').baseTemplateUrl,'redis.json')]"
}
},
"type": "Microsoft.Resources/deployments"
},
{
"apiVersion": "2015-01-01",
"name": "networkTemplate",
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[variables('moodleCommon')]"
}
},
"templateLink": {
"uri": "[concat(variables('moodleCommon').baseTemplateUrl,'network.json')]"
}
},
"type": "Microsoft.Resources/deployments"
},
{
"apiVersion": "2015-01-01",
"dependsOn": [
"Microsoft.Resources/deployments/networkTemplate",
"Microsoft.Resources/deployments/recoveryTemplate"
],
"name": "elasticTemplate",
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[variables('moodleCommon')]"
}
},
"templateLink": {
"uri": "[concat(variables('moodleCommon').baseTemplateUrl,'elastic.json')]"
}
},
"type": "Microsoft.Resources/deployments"
},
{
"apiVersion": "2015-01-01",
"dependsOn": [
"Microsoft.Resources/deployments/networkTemplate",
"Microsoft.Resources/deployments/recoveryTemplate"
],
"name": "glusterTemplate",
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[variables('moodleCommon')]"
}
},
"templateLink": {
"uri": "[concat(variables('moodleCommon').baseTemplateUrl,'gluster.json')]"
}
},
"type": "Microsoft.Resources/deployments"
},
{
"apiVersion": "2015-01-01",
"dependsOn": [
"Microsoft.Resources/deployments/elasticTemplate",
"Microsoft.Resources/deployments/glusterTemplate",
"Microsoft.Resources/deployments/recoveryTemplate",
"Microsoft.Resources/deployments/redisTemplate",
"Microsoft.Resources/deployments/blobStorageAccountTemplate"
],
"name": "controllerTemplate",
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[variables('moodleCommon')]"
},
"blobStorageAccountKey": {
"value": "[reference('blobStorageAccountTemplate').outputs.blobStorageAccountKey.value]"
},
"redisPrimaryKey": {
"value": "[reference('redisTemplate').outputs.redisPrimaryKey.value]"
}
},
"templateLink": {
"uri": "[concat(variables('moodleCommon').baseTemplateUrl,'controller.json')]"
}
},
"type": "Microsoft.Resources/deployments"
},
{
"apiVersion": "2015-01-01",
"dependsOn": [
"Microsoft.Resources/deployments/controllerTemplate",
"Microsoft.Resources/deployments/redisTemplate",
"Microsoft.Resources/deployments/dbTemplate"
],
"name": "scaleSetTemplate",
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[variables('moodleCommon')]"
}
},
"templateLink": {
"uri": "[concat(variables('moodleCommon').baseTemplateUrl,'webvmss.json')]"
}
},
"type": "Microsoft.Resources/deployments"
},
{
"apiVersion": "2015-01-01",
"name": "blobStorageAccountTemplate",
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[variables('moodleCommon')]"
}
},
"templateLink": {
"uri": "[concat(variables('moodleCommon').baseTemplateUrl,'blobStorageAccount.json')]"
}
},
"type": "Microsoft.Resources/deployments"
}
],
"outputs": {
"siteURL": {
"type": "string",
"value": "[variables('moodleCommon').siteURL]"
},
"controller-instance-ip": {
"type": "string",
"value": "[reference('controllerTemplate').outputs.controllerIP.value]"
},
"database-dns": {
"type": "string",
"value": "[concat(variables('moodleCommon').dbServerType, '-', variables('moodleCommon').resourcesPrefix, '.', variables('moodleCommon').dbServerType, '.database.azure.com')]"
},
"database-admin-username": {
"type": "string",
"value": "[variables('moodleCommon').dbUsername]"
},
"database-admin-password": {
"type": "string",
"value": "[variables('moodleCommon').dbLoginPassword]"
},
"first-frontend-vm-ip": {
"type": "string",
"value": "[reference('scaleSetTemplate').outputs.webvm1IP.value]"
},
"moodle-admin-password": {
"type": "string",
"value": "[variables('moodleCommon').moodleAdminPass]"
},
"load-balancer-dns": {
"type": "string",
"value": "[variables('moodleCommon').lbDns]"
}
},
"variables": {
"documentation01": "This main-template calls multiple sub-templates to create the moodle system",
"documentation02": " recoveryservices0 - dummy template (see next statement)",
"documentation03": " recoveryservices1 - creates a recovery vault that will be subsequently used by the VM Backup - a paramter swtich controls whethe is is called or bypassed",
"documentation04": " redis - creates a redis cache",
"documentation05": " postgres / mysql - creates a postgresql / mysql server",
"documentation06": " vnet - creates a virtual network with three subnets",
"documentation07": " elastic - creates a elastic search cluster on a vm farm",
"documentation08": " gluster - creates a gluster file system on a vm farm",
"documentation09": " webvmss - creates a vm scale set",
"documentation10": " controller - creates a jumpbox and deploys code",
"documentation11": "GlusterFS Sizing guidance",
"moodleCommon": {
"baseTemplateUrl": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/moodle-scalable-cluster-ubuntu/nested/",
"scriptLocation": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/moodle-scalable-cluster-ubuntu/scripts/",
"properties": {
"mode": "Incremental",
"templateLink": { "uri": "[concat( variables('moodleCommon').baseTemplateUrl,'recoveryservices',variables('moodleCommon').azureBackupSwitch,'.json')]" },
"parameters": { "moodleCommon": { "value": "[variables('moodleCommon')]" } }
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"name" : "redisTemplate",
"properties": {
"mode": "Incremental",
"templateLink": { "uri": "[concat( variables('moodleCommon').baseTemplateUrl,'redis.json')]" },
"parameters": { "moodleCommon": { "value": "[variables('moodleCommon')]" } }
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"name" : "networkTemplate",
"properties": {
"mode": "Incremental",
"templateLink": { "uri": "[concat( variables('moodleCommon').baseTemplateUrl,'network.json')]" },
"parameters": { "moodleCommon": { "value": "[variables('moodleCommon')]" } }
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"name" : "glusterTemplate",
"dependsOn": [ "Microsoft.Resources/deployments/networkTemplate", "Microsoft.Resources/deployments/recoveryTemplate" ],
"properties": {
"mode": "Incremental",
"templateLink": { "uri": "[concat( variables('moodleCommon').baseTemplateUrl,'gluster.json')]" },
"parameters": { "moodleCommon": { "value": "[variables('moodleCommon')]" } }
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"name" : "MariaDbTemplate",
"dependsOn": [ "Microsoft.Resources/deployments/networkTemplate", "Microsoft.Resources/deployments/recoveryTemplate" ],
"properties": {
"mode": "Incremental",
"templateLink": { "uri": "[concat( variables('moodleCommon').baseTemplateUrl,'mariadb.json')]" },
"parameters": { "moodleCommon": { "value": "[variables('moodleCommon')]" } }
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"name" : "ControllerTemplate",
"dependsOn": [ "Microsoft.Resources/deployments/glusterTemplate", "Microsoft.Resources/deployments/recoveryTemplate" ],
"properties": {
"mode": "Incremental",
"templateLink": { "uri": "[concat( variables('moodleCommon').baseTemplateUrl,'controller.json')]" },
"parameters": { "moodleCommon": { "value": "[variables('moodleCommon')]" } }
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"name" : "ScaleSetTemplate",
"dependsOn": [ "Microsoft.Resources/deployments/controllerTemplate","Microsoft.Resources/deployments/redisTemplate" ],
"properties": {
"mode": "Incremental",
"templateLink": { "uri": "[concat( variables('moodleCommon').baseTemplateUrl,'webvmss.json')]" },
"parameters": { "moodleCommon": { "value": "[variables('moodleCommon')]" } }
}
}
]
}
"applyScriptsSwitch": "[parameters('applyScriptsSwitch')]",
"autoscaleVmCount": "[parameters('autoscaleVmCount')]",
"autoscaleVmSku": "[parameters('autoscaleVmSku')]",
"azureBackupSwitch": "[parameters( 'azureBackupSwitch')]",
"blobStorageAccountName": "[tolower(concat('abs',variables('resourceprefix')))]",
"blobStorageAccountType": "[parameters('blobStorageAccountType')]",
"computeApi": "2016-04-30-preview",
"controllerVmSku": "[parameters('controllerVmSku')]",
"dbLogin": "[parameters('dbLogin')]",
"dbLoginPassword": "[concat(substring(uniqueString(resourceGroup().id, deployment().name), 2, 11), '*7', toUpper('pfiwb'))]",
"dbServerType": "[parameters('dbServerType')]",
"dbUsername": "[concat(parameters('dbLogin'), '@', parameters('dbServerType'), '-', variables('resourceprefix'))]",
"elasticVmSku": "[parameters('elasticVmSku')]",
"elasticAvailabilitySetName": "[concat('elastic-avset-',variables('resourceprefix'))]",
"elasticClusterName": "[concat('es-cluster-',variables('resourceprefix'))]",
"elasticNicName1": "[concat('elastic-vm-nic-01-',variables('resourceprefix'))]",
"elasticNicName2": "[concat('elastic-vm-nic-02-',variables('resourceprefix'))]",
"elasticNicName3": "[concat('elastic-vm-nic-03-',variables('resourceprefix'))]",
"elasticScriptFilename": "install_elastic.sh",
"elasticVm1IP": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),4)), '.20')]",
"elasticVm2IP": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),4)), '.21')]",
"elasticVm3IP": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),4)), '.22')]",
"elasticVmName": "[concat('elastic-vm-',variables('resourceprefix'))]",
"elasticVmName1": "[concat('elastic-vm-01-',variables('resourceprefix'))]",
"elasticVmName2": "[concat('elastic-vm-02-',variables('resourceprefix'))]",
"elasticVmName3": "[concat('elastic-vm-03-',variables('resourceprefix'))]",
"extBeName": "[concat('lb-backend-',variables('resourceprefix'))]",
"extFeName": "[concat('lb-frontend-',variables('resourceprefix'))]",
"extNatPool": "[concat('lb-natpool-',variables('resourceprefix'))]",
"extProbe": "[concat('lb-probe-',variables('resourceprefix'))]",
"firewallRuleName": "[parameters('firewallRuleName')]",
"gatewayName": "[concat('vnet-gateway-',variables('resourceprefix'))]",
"gatewayPublicIPName": "[concat('vnet-gw-ip-',variables('resourceprefix'))]",
"gatewaySubnet": "[parameters('gatewaySubnet')]",
"gatewaySubnetPrefix": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),2)))]",
"gatewaySubnetRange": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),2)), '.0/24')]",
"gatewayType": "[parameters('gatewayType')]",
"gfsNameRoot": "[concat('gluster-vm-',variables('resourceprefix'))]",
"gfxAvailabilitySetName": "[concat('gluster-avset-',variables('resourceprefix'))]",
"glusterDiskCount": "[parameters('glusterDiskCount')]",
"glusterDiskSize": "[parameters('glusterDiskSize')]",
"glusterScriptFilename": "install_gluster.sh",
"glusterVmCount": 2,
"glusterVmSku": "[parameters('glusterVmSku')]",
"jboxNicName": "[concat('jumpbox-vm-nic-',variables('resourceprefix'))]",
"jboxNsgName": "[concat('jumpbox-nsg-',variables('resourceprefix'))]",
"jboxPipName": "[concat('jumpbox-pubip-',variables('resourceprefix'))]",
"jboxVmName": "[concat('jumpbox-vm-',variables('resourceprefix'))]",
"lbDns": "[concat('lb-',variables('resourceprefix'),'.',resourceGroup().location,'.cloudapp.azure.com')]",
"lbName": "[concat('lb-',variables('resourceprefix'))]",
"lbPipName": "[concat('lb-pubip-',variables('resourceprefix'))]",
"moodleAdminPass": "[concat(toUpper('xl'), substring(uniqueString(resourceGroup().id, deployment().name), 6, 7),'<,!1*8')]",
"moodleDbName": "moodle",
"moodleDbPass": "[concat('9(#36^', substring(uniqueString(resourceGroup().id, deployment().name), 5, 8), toUpper('ercq'))]",
"moodleDbUser": "moodle",
"moodleDbUserAzure": "[concat('moodle', '@', parameters('dbServerType'), '-', variables('resourceprefix'))]",
"moodleInstallScriptFilename": "[concat(parameters('dbServerType'), '_', 'install_moodle.sh')]",
"moodleSetupScriptFilename": "setup_moodle.sh",
"moodleVersion": "[parameters('moodleVersion')]",
"mysqlVersion": "[parameters('mysqlVersion')]",
"osType": {
"offer": "UbuntuServer",
"publisher": "Canonical",
"sku": "16.04-LTS",
"version": "latest"
},
"policyName": "[concat('policy-',variables('resourceprefix'))]",
"postgresVersion": "[parameters('postgresVersion')]",
"redisCacheName": "[concat('redis-',variables('resourceprefix'))]",
"redisDns": "[concat('redis-',variables('resourceprefix'),'.redis.cache.windows.net')]",
"resourcesPrefix": "[variables('resourceprefix')]",
"serverName": "[concat(parameters('dbServerType'), '-',variables('resourceprefix'))]",
"siteURL": "[if(or(empty(parameters('siteURL')), equals(parameters('siteURL'), 'www.example.org')), concat('lb-',variables('resourceprefix'),'.',resourceGroup().location,'.cloudapp.azure.com'), parameters('siteURL'))]",
"skuCapacityDTU": "[parameters('skuCapacityDTU')]",
"skuFamily": "[parameters('skuFamily')]",
"skuName": "[parameters('skuName')]",
"skuSizeMB": "[parameters('skuSizeMB')]",
"skuTier": "[parameters('skuTier')]",
"sshPassword": "[concat(toUpper('ds'), substring(uniqueString(resourceGroup().id, deployment().name), 4, 9), '2@%5')]",
"sshPublicKey": "[parameters('sshPublicKey')]",
"sshUsername": "[parameters('sshUsername')]",
"sslEnforcement": "[parameters('sslEnforcement')]",
"subnetElastic": "[concat('elastic-subnet-',variables('resourceprefix'))]",
"subnetElasticPrefix": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),4)))]",
"subnetElasticRange": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),4)), '.0/24')]",
"subnetRedis": "[concat('redis-subnet-',variables('resourceprefix'))]",
"subnetRedisPrefix": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),3)))]",
"subnetRedisRange": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),3)), '.0/24')]",
"subnetSan": "[concat('san-subnet-',variables('resourceprefix'))]",
"subnetSanPrefix": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),1)))]",
"subnetSanRange": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),1)), '.0/24')]",
"subnetWeb": "[concat('web-subnet-',variables('resourceprefix'))]",
"subnetWebPrefix": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),0)))]",
"subnetWebRange": "[concat( variables('octets')[0], '.', variables('octets')[1], '.', string(add(int(variables('octets')[2]),0)), '.0/24')]",
"vNetAddressSpace": "[parameters('vNetAddressSpace')]",
"vaultName": "[concat('vault-',variables('resourceprefix'))]",
"vmssName": "[concat('vmss-',variables('resourceprefix'))]",
"vmssdStorageAccounttName": "[concat('vmss',uniqueString(resourceGroup().id))]",
"vnetName": "[concat('vnet-',variables('resourceprefix'))]",
"vpnType": "[parameters('vpnType')]"
},
"octets": "[split(parameters('vNetAddressSpace'), '.')]",
"resourceprefix": "[substring(uniqueString(resourceGroup().id, deployment().name), 3, 6)]"
}
}

Просмотреть файл

@ -1,14 +1,27 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourcesPrefix": { "value": "GEN-UNIQUE-4"},
"moodleVersion": { "value": "MOODLE_32_STABLE" },
"adminPassword": { "value": "Sw!mmingP00l" },
"mySqlUserPassword": { "value": "Sw!mmingP00l" },
"mySqlRootPassword": { "value": "Sw!mmingP00l" },
"applyScriptsSwitch": { "value": 1 },
"azureBackupSwitch": { "value": 0 }
}
"parameters": {
"applyScriptsSwitch": { "value": 1 },
"autoscaleVmCount": { "value": 10 },
"autoscaleVmSku": { "value": "Standard_DS2_v2" },
"azureBackupSwitch": { "value": 0 },
"blobStorageAccountType": { "value": "Standard_LRS"},
"controllerVmSku": { "value": "Standard_DS1_v2" },
"dbServerType": { "value": "postgres" },
"elasticVmSku": { "value": "Standard_DS2_v2" },
"glusterDiskCount": { "value": 4 },
"glusterDiskSize": { "value": 127 },
"glusterVmSku": { "value": "Standard_DS2_v2" },
"moodleVersion": { "value": "MOODLE_34_STABLE" },
"mysqlVersion": { "value": "5.7" },
"postgresVersion": { "value": "9.6" },
"siteURL": { "value": "www.example.org" },
"skuCapacityDTU": { "value": 50 },
"skuName": { "value": "PGSQLB50" },
"skuSizeMB": { "value": 51200 },
"skuTier": { "value": "Basic" },
"vNetAddressSpace": { "value": "172.31.0.0" },
"sshPublicKey": { "value": "GEN-SSH-PUB-KEY" }
}
}

Двоичные данные
images/moodle-on-azure.jpg

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 76 KiB

Двоичные данные
images/stack_diagram.jpg Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 222 KiB

Просмотреть файл

@ -1,7 +1,7 @@
{
"itemDisplayName": "Moodle LMS on Azure IaaS",
"description": "This template deploys a scalable architecture for running Moodle Learning Management System on top of Azure IaaS VMs. It creates a VMScaleSet (Ubuntu Linux 14.04 based) running Apache+PHP 5.6 for Moodle. It also deploys a MariaDb 10.1 Active-Active cluster (Galera) for the database and a GlusterFS cluster for hosting the Application Code and the MOODLEDATA folder shared accross all the nodes of the VMSS. Additional Info: *** Azure Backup can be enable in the relevant VMs. *** Moodle version can be selected for installation. *** Application files are installed in the /moodle/html/moodle folder. *** MOODLEDATA folder is mount at /moodle/moodledata; *** SSL valid certificates can be installed at /moodle/certs and will be recognized by Apache. *** An Azure Redis Cache is also deployed and can be used within Moodle for it's Application and Session Cache.",
"summary": "Scalable architecture for Moodle running in Azure VM/VMSS",
"githubUsername": "pateixei",
"dateUpdated": "2017-06-05"
}
"itemDisplayName": "Moodle autoscale with db/redis",
"description": "Deploys an autoscaling Moodle cluster with objectfs storage, Azure redis, Azure MySQL/Postgres, and Elasticsearch. Can be configured for very small or very large sites. Deploys frontend components to a private network with a jumphost to access nodes. Requires keyed SSH access.",
"summary": "Moodle autoscale with redis/db/elasticsearch",
"githubUsername": "CatalystAUInf",
"dateUpdated": "2017-12-28"
}

Просмотреть файл

@ -0,0 +1,58 @@
{
"$schema": "https://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": [
{
"kind": "BlobStorage",
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').blobStorageAccountName]",
"apiVersion": "2017-06-01",
"sku": {
"name": "[parameters('moodleCommon').blobStorageAccountType]"
},
"properties": {
"accessTier": "Hot",
"encryption": {
"keySource": "Microsoft.Storage",
"services": {
"blob": {
"enabled": true
},
"file": {
"enabled": true
}
}
},
"networkAcls": {
"bypass": "AzureServices",
"defaultAction": "Allow",
"ipRules": [],
"virtualNetworkRules": []
},
"supportsHttpsTrafficOnly": true
},
"type": "Microsoft.Storage/storageAccounts"
}
],
"variables": {
"documentation1": "This sub-template creates a blob storage account. It expects certain values in the 'common' datastructure.",
"documentation2": " blobStorageAccountName - name of storage account",
"documentation3": " blobStorageAccountType - type of storage account",
"scriptUri": "[concat(parameters('moodleCommon').ScriptLocation,parameters('moodleCommon').moodleInstallScriptFilename)]",
"blobStorageAccountId": "[concat(resourceGroup().id,'/providers/Microsoft.Storage/storageAccounts/', parameters('moodleCommon').blobStorageAccountName)]"
},
"outputs": {
"blobStorageAccountKey": {
"value": "[listKeys(variables('blobStorageAccountId'), '2017-06-01').keys[0].value]",
"type": "string"
}
}
}

Просмотреть файл

@ -1,131 +1,232 @@
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.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"
},
"blobStorageAccountKey": {
"metadata": {
"description": "Key used to create a storage container"
},
"type": "string"
},
"redisPrimaryKey": {
"metadata": {
"description": "Key used for Redis authentication"
},
"type": "string"
}
},
"resources": [
{
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').jboxPipName]",
"properties": {
"dnsSettings": {
"domainNameLabel": "[parameters('moodleCommon').jboxPipName]"
},
"publicIPAllocationMethod": "Static"
},
"tags": {
"displayName": "jboxpip"
},
"type": "Microsoft.Network/publicIPAddresses"
},
{
"apiVersion": "2016-03-30",
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').jboxNsgName]",
"properties": {
"securityRules": [
{
"name": "Allow_SSH",
"properties": {
"access": "Allow",
"destinationAddressPrefix": "*",
"destinationPortRange": "22",
"direction": "Inbound",
"priority": 1000,
"protocol": "Tcp",
"sourceAddressPrefix": "*",
"sourcePortRange": "*"
}
},
{
"name": "Allow_http",
"properties": {
"access": "Allow",
"destinationAddressPrefix": "*",
"destinationPortRange": "80",
"direction": "Inbound",
"priority": 1005,
"protocol": "Tcp",
"sourceAddressPrefix": "*",
"sourcePortRange": "*"
}
}
]
},
"tags": {
"displayName": "JumpBox NSG"
},
"type": "Microsoft.Network/networkSecurityGroups"
},
{
"apiVersion": "2015-06-15",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', parameters('moodleCommon').jboxPipName)]"
],
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').jboxNicName]",
"properties": {
"ipConfigurations": [
{
"name": "ipcfgjbox",
"networkSecurityGroup": {
"id": "[variables('nsgRef')]"
},
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[variables('pipRef')]"
},
"subnet": {
"id": "[variables('subnetWebRef')]"
}
}
}
]
},
"tags": {
"displayName": "jboxNic"
},
"type": "Microsoft.Network/networkInterfaces"
},
{
"apiVersion": "[parameters('moodleCommon').computeApi]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', parameters('moodleCommon').jboxNicName)]"
],
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').jboxVmName]",
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('moodleCommon').controllerVmSku]"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[variables('nicRef')]"
}
]
},
"osProfile": {
"adminUsername": "[parameters('moodleCommon').sshUsername]",
"computerName": "[parameters('moodleCommon').jboxVmName]",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"path": "[concat('/home/', parameters('moodleCommon').sshUsername, '/.ssh/authorized_keys')]",
"keyData": "[parameters('moodleCommon').sshPublicKey]"
}
]
}
}
},
"storageProfile": {
"dataDisks": [],
"imageReference": "[parameters('moodleCommon').osType]",
"osDisk": {
"createOption": "fromImage",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"name": "[parameters('moodleCommon').jboxVmName]"
}
}
},
"tags": {
"displayName": "Gluster Virtual Machine"
},
"type": "Microsoft.Compute/virtualMachines"
},
{
"apiVersion": "2015-01-01",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('moodleCommon').jboxVmName)]"
],
"name": "[concat(parameters('moodleCommon').jboxVmName,'-ScriptProcessor')]",
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[parameters('moodleCommon')]"
},
"blobStorageAccountKey": {
"value": "[parameters('blobStorageAccountKey')]"
},
"redisPrimaryKey": {
"value": "[parameters('redisPrimaryKey')]"
}
"parameters": { "moodleCommon": { "type": "object", "metadata": { "description": "Common Moodle values" } } },
"variables": {
"documentation01": "This sub-template drives the controller/jump-box which is used as the access-point for other moodle VM's ",
"documentation02": "It expects certain values in the 'common' datastructure.",
"documentation03": " vnetName - name of virtual network",
"documentation04": " subnetWeb - name of subnet for controller (and vm scale set)",
"documentation05": " computeApi - the 'managed' resources need to all use this value",
"documentation06": " jboxPipName - name of Public IP address for the jumpbox (note that none of the other VM's get a PIP - just the jumpbox",
"documentation07": " jboxNicName - name of the network interface (all VM's must hae a nic) to crate, tied to the public IP address",
"documentation08": " jboxNsgName - name of the network security group, regulating access to/from the jumpbox",
"documentation09": "This sub-template calls other sub-templates",
"documentation10": " controllerconfig - conditionally applies post-deployment script on the VM",
"documentation18": " recoveryservicesEnlist - conditionally enlists the VM into the backup regimen",
"subnetWebRef": "[concat(resourceId('Microsoft.Network/virtualNetworks', parameters('moodleCommon').vnetName), '/subnets/',parameters('moodleCommon').subnetWeb)]",
"pipRef": "[ resourceId('Microsoft.Network/publicIPAddresses', parameters('moodleCommon').jboxPipName)]",
"nicRef": "[ resourceId('Microsoft.Network/networkInterfaces', parameters('moodleCommon').jboxNicName)]",
"nsgRef": "[ resourceId('Microsoft.Network/networkSecurityGroups', parameters('moodleCommon').jboxNsgName)]"
},
"resources": [
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2015-06-15",
"name": "[parameters('moodleCommon').jboxPipName]",
"location": "[resourceGroup().location]",
"tags": { "displayName": "jboxpip" },
"properties": { "publicIPAllocationMethod": "Dynamic", "dnsSettings": { "domainNameLabel": "[parameters('moodleCommon').jboxPipName]" } }
},
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2016-03-30",
"name": "[parameters('moodleCommon').jboxNsgName]",
"location": "[resourceGroup().location]",
"tags": { "displayName": "JumpBox NSG" },
"properties": {
"securityRules": [
{ "name": "Allow_SSH", "properties": { "priority": 1000, "access": "Allow", "direction": "Inbound", "protocol": "Tcp", "sourcePortRange": "*", "destinationPortRange": "22", "sourceAddressPrefix": "*", "destinationAddressPrefix": "*" } },
{ "name": "Allow_http", "properties": { "priority": 1005, "access": "Allow", "direction": "Inbound", "protocol": "Tcp", "sourcePortRange": "*", "destinationPortRange": "80", "sourceAddressPrefix": "*", "destinationAddressPrefix": "*" } } ]
}
},
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2015-06-15",
"name": "[parameters('moodleCommon').jboxNicName]",
"location": "[resourceGroup().location]",
"dependsOn": [ "[concat('Microsoft.Network/publicIPAddresses/', parameters('moodleCommon').jboxPipName)]" ],
"tags": { "displayName": "jboxNic" },
"properties": {
"ipConfigurations": [
{
"name": "ipcfgjbox",
"properties": { "privateIPAllocationMethod": "Dynamic", "subnet": { "id": "[variables('subnetWebRef')]" }, "publicIPAddress": { "id":"[variables('pipRef')]" } },
"networkSecurityGroup": { "id": "[variables('nsgRef')]" }
}
]
}
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "[parameters('moodleCommon').computeApi]",
"name": "[parameters('moodleCommon').jboxVmName]",
"location": "[resourceGroup().location]",
"tags": { "displayName": "Gluster Virtual Machine" },
"dependsOn": [ "[concat('Microsoft.Network/networkInterfaces/', parameters('moodleCommon').jboxNicName)]" ],
"properties": {
"networkProfile": { "networkInterfaces": [ { "id": "[variables('nicRef')]" } ] },
"hardwareProfile": { "vmSize": "Standard_D1" },
"osProfile": { "computerName": "[parameters('moodleCommon').jboxVmName]", "adminUsername": "[parameters('moodleCommon').adminUsername]", "adminPassword": "[parameters('moodleCommon').adminPassword]" },
"storageProfile": { "imageReference": "[parameters('moodleCommon').osType]",
"osDisk": { "name": "[parameters('moodleCommon').jboxVmName]", "createOption": "fromImage", "managedDisk": { "storageAccountType": "Standard_LRS" } },
"dataDisks": [ ] }
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"name": "[concat(parameters('moodleCommon').jboxVmName,'-ScriptProcessor')]",
"dependsOn": [ "[concat('Microsoft.Compute/virtualMachines/', parameters('moodleCommon').jboxVmName)]" ],
"properties": {
"mode": "Incremental",
"templateLink": { "uri": "[concat( parameters('moodleCommon').baseTemplateUrl,'controllerconfig',parameters('moodleCommon').applyScriptsSwitch,'.json')]" },
"parameters": { "moodleCommon": { "value": "[parameters('moodleCommon')]" } }
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"name": "[concat(parameters('moodleCommon').jboxVmName,'-Backup')]",
"dependsOn": [ "[concat('Microsoft.Compute/virtualMachines/',parameters('moodleCommon').jboxVmName)]" ],
"properties": {
"mode": "Incremental",
"templateLink": { "uri": "[concat( parameters('moodleCommon').baseTemplateUrl,'recoveryservicesEnlist',parameters('moodleCommon').azureBackupSwitch,'.json')]" },
"parameters": { "moodleCommon": { "value": "[parameters('moodleCommon')]" }, "vmName": { "value": "[parameters('moodleCommon').jboxVmName]"} }
}
}
]
},
"templateLink": {
"uri": "[concat( parameters('moodleCommon').baseTemplateUrl,'controllerconfig',parameters('moodleCommon').applyScriptsSwitch,'.json')]"
}
},
"type": "Microsoft.Resources/deployments"
},
{
"apiVersion": "2015-01-01",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/',parameters('moodleCommon').jboxVmName)]"
],
"name": "[concat(parameters('moodleCommon').jboxVmName,'-Backup')]",
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[parameters('moodleCommon')]"
},
"vmName": {
"value": "[parameters('moodleCommon').jboxVmName]"
}
},
"templateLink": {
"uri": "[concat( parameters('moodleCommon').baseTemplateUrl,'recoveryservicesEnlist',parameters('moodleCommon').azureBackupSwitch,'.json')]"
}
},
"type": "Microsoft.Resources/deployments"
}
],
"variables": {
"documentation01": "This sub-template drives the controller/jump-box which is used as the access-point for other moodle VM's ",
"documentation02": "It expects certain values in the 'common' datastructure.",
"documentation03": " vnetName - name of virtual network",
"documentation04": " subnetWeb - name of subnet for controller (and vm scale set)",
"documentation05": " computeApi - the 'managed' resources need to all use this value",
"documentation06": " jboxPipName - name of Public IP address for the jumpbox (note that none of the other VM's get a PIP - just the jumpbox",
"documentation07": " jboxNicName - name of the network interface (all VM's must hae a nic) to crate, tied to the public IP address",
"documentation08": " jboxNsgName - name of the network security group, regulating access to/from the jumpbox",
"documentation09": "This sub-template calls other sub-templates",
"documentation10": " controllerconfig - conditionally applies post-deployment script on the VM",
"documentation18": " recoveryservicesEnlist - conditionally enlists the VM into the backup regimen",
"nicRef": "[resourceId('Microsoft.Network/networkInterfaces', parameters('moodleCommon').jboxNicName)]",
"nsgRef": "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('moodleCommon').jboxNsgName)]",
"pipRef": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('moodleCommon').jboxPipName)]",
"subnetWebRef": "[concat(resourceId('Microsoft.Network/virtualNetworks', parameters('moodleCommon').vnetName), '/subnets/',parameters('moodleCommon').subnetWeb)]"
},
"outputs": {
"controllerIP": {
"value": "[reference(resourceId('Microsoft.Network/publicIPAddresses', parameters('moodleCommon').jboxPipName), '2015-06-15').ipAddress]",
"type": "string"
}
}
}

Просмотреть файл

@ -1,14 +1,30 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { "moodleCommon": { "type": "object", "metadata": { "description": "Common Moodle values" } } },
"variables": {
"documentation1": "This sub-template intentionally blank - a blank template allows for an optional exectuion strategy",
"documentation2": "",
"documentation3": "You should look for a template of the same name, but with a 1 instead of a 0 (at the end)"
},
"resources": []
}
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"moodleCommon": {
"metadata": {
"description": "Common Moodle values"
},
"type": "object"
},
"blobStorageAccountKey": {
"metadata": {
"description": "Key used to create a storage container"
},
"type": "string"
},
"redisPrimaryKey": {
"metadata": {
"description": "Key used for Redis authentication"
},
"type": "string"
}
},
"resources": [],
"variables": {
"documentation1": "This sub-template intentionally blank - a blank template allows for an optional exectuion strategy",
"documentation2": "",
"documentation3": "You should look for a template of the same name, but with a 1 instead of a 0 (at the end)"
}
}

Просмотреть файл

@ -1,43 +1,63 @@
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { "moodleCommon": { "type": "object", "metadata": { "description": "Common Moodle values" } } },
"variables": {
"documentation01": "This sub-template applies a specific post-deployment script to the controller vm",
"documentation02": "It expects certain values in the 'common' datastructure.",
"documentation03": " ScriptLocation - partial web URI (equivalent to folder)(",
"documentation04": " moodleInstallScriptFilename - name of script file",
"documentation05": " lbDnsName - name of the dns entry for the vmscalse set",
"documentation06": " gfsNameRoot - nameroot of gluster farm - note that the code applies a 0 to get to the first node",
"documentation07": " mySqlUserPassword - database (mariadb) password",
"documentation08": " jboxVmName - name of the controller/jumpb ox VM",
"dns": "[concat(parameters('moodleCommon').lbDnsName,'.',resourceGroup().location,'.cloudapp.azure.com')]",
"scriptUri": "[concat(parameters('moodleCommon').ScriptLocation,parameters('moodleCommon').moodleInstallScriptFilename)]",
"cmdExec": "[concat('sh ', parameters('moodleCommon').moodleInstallScriptFilename, ' ', parameters('moodleCommon').moodleVersion, ' ', concat(parameters('moodleCommon').gfsNameRoot, '0'), ' ', 'data', ' ', variables('dns'), ' ', parameters('moodleCommon').StaticIpMariaDb, ' ', 'moodle', ' ', 'moodledba', ' ', parameters('moodleCommon').mySqlUserPassword,' ', parameters('moodleCommon').adminPassword)]"
},
"resources": [
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2015-06-15",
"name": "[concat(parameters('moodleCommon').jboxVmName,'/','install_moodle')]",
"location": "[resourceGroup().location]",
"tags": { "displayName": "install_moodle" },
"properties": {
"publisher": "Microsoft.OSTCExtensions",
"type": "CustomScriptForLinux",
"typeHandlerVersion": "1.4",
"autoUpgradeMinorVersion": true,
"settings": { "fileUris": [ "[variables('scriptUri')]" ], "commandToExecute": "[variables('cmdExec')]" }
}
}
]
"$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"
},
"blobStorageAccountKey": {
"metadata": {
"description": "Key used to create a storage container"
},
"type": "string"
},
"redisPrimaryKey": {
"metadata": {
"description": "Key used for Redis authentication"
},
"type": "string"
}
},
"resources": [
{
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"name": "[concat(parameters('moodleCommon').jboxVmName,'/','install_moodle')]",
"properties": {
"autoUpgradeMinorVersion": true,
"publisher": "Microsoft.OSTCExtensions",
"settings": {
"commandToExecute": "[variables('cmdExec')]",
"fileUris": [
"[variables('scriptUri')]"
]
},
"type": "CustomScriptForLinux",
"typeHandlerVersion": "1.4"
},
"tags": {
"displayName": "install_moodle"
},
"type": "Microsoft.Compute/virtualMachines/extensions"
}
],
"variables": {
"cmdExec": "[concat('sh ', parameters('moodleCommon').moodleInstallScriptFilename, ' ', parameters('moodleCommon').moodleVersion, ' ', concat(parameters('moodleCommon').gfsNameRoot, '0'), ' ', 'data', ' ', parameters('moodleCommon').siteURL, ' ', concat(parameters('moodleCommon').dbServerType, '-', parameters('moodleCommon').resourcesPrefix, '.', parameters('moodleCommon').dbServerType, '.database.azure.com'), ' ', parameters('moodleCommon').moodleDbName, ' ', parameters('moodleCommon').moodleDbUser, ' ', parameters('moodleCommon').moodleDbPass, ' ', parameters('moodleCommon').moodleAdminPass, ' ', concat(parameters('moodleCommon').dbLogin, '@', parameters('moodleCommon').dbServerType, '-', parameters('moodleCommon').resourcesPrefix), ' ', parameters('moodleCommon').dbLoginPassword, ' ', parameters('moodleCommon').blobStorageAccountName, ' ', parameters('blobStorageAccountKey'), ' ', parameters('moodleCommon').moodleDbUserAzure, ' ', parameters('moodleCommon').redisDns, ' ', parameters('redisPrimaryKey'), ' ', parameters('moodleCommon').elasticVm1IP)]",
"documentation01": "This sub-template applies a specific post-deployment script to the controller vm",
"documentation02": "It expects certain values in the 'common' datastructure.",
"documentation03": " ScriptLocation - web URI",
"documentation04": " moodleInstallScriptFilename - name of script file",
"documentation05": " siteURL - URL of the website",
"documentation06": " gfsNameRoot - nameroot of gluster farm - note that the code applies a 0 to get to the first node",
"documentation07": " jboxVmName - name of the controller/jumpb ox VM",
"documentation08": " dbServerType - postgres or mysql",
"documentation09": " moodleDbName - database name for moodle",
"documentation10": " moodleDbUser - database user for moodle",
"documentation11": " moodleDbPass - database password for moodleDbUser",
"documentation11": " moodleAdminPass - password for moodle admin user",
"scriptUri": "[concat(parameters('moodleCommon').ScriptLocation,parameters('moodleCommon').moodleInstallScriptFilename)]"
}
}

Просмотреть файл

@ -1,31 +1,92 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": { "type": "string" },
"vmDiskCount": { "type": "int", "minValue": 2, "maxValue": 8 }
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"outputs": {
"dataDiskArray": {
"type": "array",
"value": "[take(variables('diskArray'),parameters('vmDiskCount'))]"
}
},
"variables": {
"documentation01": "This sub-template provides a way to return a flexible number of drive configurations",
"documentation02": " vmName - used as apart of the naming of the disk(s)",
"documentation03": " vmDiskCount - used to limit the nubmer of configuraitons returned (via the TAKE function) ",
"diskArray": [
{ "lun": 0, "managedDisk": { "id": "[resourceId('Microsoft.Compute/disks', concat(parameters('vmName'),'-datadisk1'))]" },"caching": "None", "createOption": "Attach" },
{ "lun": 1, "managedDisk": { "id": "[resourceId('Microsoft.Compute/disks', concat(parameters('vmName'),'-datadisk2'))]" },"caching": "None", "createOption": "Attach" },
{ "lun": 2, "managedDisk": { "id": "[resourceId('Microsoft.Compute/disks', concat(parameters('vmName'),'-datadisk3'))]" },"caching": "None", "createOption": "Attach" },
{ "lun": 3, "managedDisk": { "id": "[resourceId('Microsoft.Compute/disks', concat(parameters('vmName'),'-datadisk4'))]" },"caching": "None", "createOption": "Attach" },
{ "lun": 4, "managedDisk": { "id": "[resourceId('Microsoft.Compute/disks', concat(parameters('vmName'),'-datadisk5'))]" },"caching": "None", "createOption": "Attach" },
{ "lun": 5, "managedDisk": { "id": "[resourceId('Microsoft.Compute/disks', concat(parameters('vmName'),'-datadisk6'))]" },"caching": "None", "createOption": "Attach" },
{ "lun": 6, "managedDisk": { "id": "[resourceId('Microsoft.Compute/disks', concat(parameters('vmName'),'-datadisk7'))]" },"caching": "None", "createOption": "Attach" },
{ "lun": 7, "managedDisk": { "id": "[resourceId('Microsoft.Compute/disks', concat(parameters('vmName'),'-datadisk8'))]" },"caching": "None", "createOption": "Attach" }
]
},
"resources": [],
"outputs": { "dataDiskArray": { "type": "array", "value": "[take(variables('diskArray'),parameters('vmDiskCount'))]" } }
}
"parameters": {
"vmDiskCount": {
"maxValue": 8,
"minValue": 2,
"type": "int"
},
"vmName": {
"type": "string"
}
},
"resources": [],
"variables": {
"diskArray": [
{
"caching": "None",
"createOption": "Attach",
"lun": 0,
"managedDisk": {
"id": "[resourceId('Microsoft.Compute/disks', concat(parameters('vmName'),'-datadisk1'))]"
}
},
{
"caching": "None",
"createOption": "Attach",
"lun": 1,
"managedDisk": {
"id": "[resourceId('Microsoft.Compute/disks', concat(parameters('vmName'),'-datadisk2'))]"
}
},
{
"caching": "None",
"createOption": "Attach",
"lun": 2,
"managedDisk": {
"id": "[resourceId('Microsoft.Compute/disks', concat(parameters('vmName'),'-datadisk3'))]"
}
},
{
"caching": "None",
"createOption": "Attach",
"lun": 3,
"managedDisk": {
"id": "[resourceId('Microsoft.Compute/disks', concat(parameters('vmName'),'-datadisk4'))]"
}
},
{
"caching": "None",
"createOption": "Attach",
"lun": 4,
"managedDisk": {
"id": "[resourceId('Microsoft.Compute/disks', concat(parameters('vmName'),'-datadisk5'))]"
}
},
{
"caching": "None",
"createOption": "Attach",
"lun": 5,
"managedDisk": {
"id": "[resourceId('Microsoft.Compute/disks', concat(parameters('vmName'),'-datadisk6'))]"
}
},
{
"caching": "None",
"createOption": "Attach",
"lun": 6,
"managedDisk": {
"id": "[resourceId('Microsoft.Compute/disks', concat(parameters('vmName'),'-datadisk7'))]"
}
},
{
"caching": "None",
"createOption": "Attach",
"lun": 7,
"managedDisk": {
"id": "[resourceId('Microsoft.Compute/disks', concat(parameters('vmName'),'-datadisk8'))]"
}
}
],
"documentation01": "This sub-template provides a way to return a flexible number of drive configurations",
"documentation02": " vmName - used as apart of the naming of the disk(s)",
"documentation03": " vmDiskCount - used to limit the nubmer of configuraitons returned (via the TAKE function) "
}
}

362
nested/elastic.json Normal file
Просмотреть файл

@ -0,0 +1,362 @@
{
"$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": [
{
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').elasticNicName1]",
"properties": {
"ipConfigurations": [
{
"name": "ipcfg-elastic1",
"properties": {
"privateIPAllocationMethod": "Static",
"privateIPAddress": "[parameters('moodleCommon').elasticVm1IP]",
"subnet": {
"id": "[variables('subnetElasticRef')]"
}
}
}
]
},
"tags": {
"displayName": "Elastic NIC 1"
},
"type": "Microsoft.Network/networkInterfaces"
},
{
"apiVersion": "[parameters('moodleCommon').computeApi]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', parameters('moodleCommon').elasticNicName1)]"
],
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').elasticVmName1]",
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('moodleCommon').elasticVmSku]"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[variables('nicRef1')]"
}
]
},
"osProfile": {
"adminUsername": "[parameters('moodleCommon').sshUsername]",
"computerName": "[parameters('moodleCommon').elasticVmName1]",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"path": "[concat('/home/', parameters('moodleCommon').sshUsername, '/.ssh/authorized_keys')]",
"keyData": "[parameters('moodleCommon').sshPublicKey]"
}
]
}
}
},
"storageProfile": {
"dataDisks": [],
"imageReference": "[parameters('moodleCommon').osType]",
"osDisk": {
"createOption": "fromImage",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"name": "[parameters('moodleCommon').elasticVmName1]"
}
}
},
"tags": {
"displayName": "Elastic Search Virtual Machine"
},
"type": "Microsoft.Compute/virtualMachines"
},
{
"apiVersion": "2015-01-01",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('moodleCommon').elasticVmName1)]"
],
"name": "[concat(parameters('moodleCommon').elasticVmName1,'-ScriptProcessor')]",
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[parameters('moodleCommon')]"
}
},
"templateLink": {
"uri": "[concat(parameters('moodleCommon').baseTemplateUrl,'elasticconfig',parameters('moodleCommon').applyScriptsSwitch,'.json')]"
}
},
"type": "Microsoft.Resources/deployments"
},
{
"apiVersion": "2015-01-01",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/',parameters('moodleCommon').elasticVmName1)]"
],
"name": "[concat(parameters('moodleCommon').elasticVmName1,'-Backup')]",
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[parameters('moodleCommon')]"
},
"vmName": {
"value": "[parameters('moodleCommon').elasticVmName1]"
}
},
"templateLink": {
"uri": "[concat(parameters('moodleCommon').baseTemplateUrl,'recoveryservicesEnlist',parameters('moodleCommon').azureBackupSwitch,'.json')]"
}
},
"type": "Microsoft.Resources/deployments"
},
{
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').elasticNicName2]",
"properties": {
"ipConfigurations": [
{
"name": "ipcfg-elastic2",
"properties": {
"privateIPAllocationMethod": "Static",
"privateIPAddress": "[parameters('moodleCommon').elasticVm2IP]",
"subnet": {
"id": "[variables('subnetElasticRef')]"
}
}
}
]
},
"tags": {
"displayName": "Elastic NIC 2"
},
"type": "Microsoft.Network/networkInterfaces"
},
{
"apiVersion": "[parameters('moodleCommon').computeApi]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', parameters('moodleCommon').elasticNicName2)]"
],
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').elasticVmName2]",
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('moodleCommon').elasticVmSku]"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[variables('nicRef2')]"
}
]
},
"osProfile": {
"adminPassword": "[parameters('moodleCommon').sshPassword]",
"adminUsername": "[parameters('moodleCommon').sshUsername]",
"computerName": "[parameters('moodleCommon').elasticVmName2]"
},
"storageProfile": {
"dataDisks": [],
"imageReference": "[parameters('moodleCommon').osType]",
"osDisk": {
"createOption": "fromImage",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"name": "[parameters('moodleCommon').elasticVmName2]"
}
}
},
"tags": {
"displayName": "Elastic Search Virtual Machine"
},
"type": "Microsoft.Compute/virtualMachines"
},
{
"apiVersion": "2015-01-01",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('moodleCommon').elasticVmName2)]"
],
"name": "[concat(parameters('moodleCommon').elasticVmName2,'-ScriptProcessor')]",
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[parameters('moodleCommon')]"
}
},
"templateLink": {
"uri": "[concat(parameters('moodleCommon').baseTemplateUrl,'elasticconfig',parameters('moodleCommon').applyScriptsSwitch,'.json')]"
}
},
"type": "Microsoft.Resources/deployments"
},
{
"apiVersion": "2015-01-01",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/',parameters('moodleCommon').elasticVmName2)]"
],
"name": "[concat(parameters('moodleCommon').elasticVmName2,'-Backup')]",
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[parameters('moodleCommon')]"
},
"vmName": {
"value": "[parameters('moodleCommon').elasticVmName2]"
}
},
"templateLink": {
"uri": "[concat(parameters('moodleCommon').baseTemplateUrl,'recoveryservicesEnlist',parameters('moodleCommon').azureBackupSwitch,'.json')]"
}
},
"type": "Microsoft.Resources/deployments"
},
{
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').elasticNicName3]",
"properties": {
"ipConfigurations": [
{
"name": "ipcfg-elastic3",
"properties": {
"privateIPAllocationMethod": "Static",
"privateIPAddress": "[parameters('moodleCommon').elasticVm3IP]",
"subnet": {
"id": "[variables('subnetElasticRef')]"
}
}
}
]
},
"tags": {
"displayName": "Elastic NIC 2"
},
"type": "Microsoft.Network/networkInterfaces"
},
{
"apiVersion": "[parameters('moodleCommon').computeApi]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', parameters('moodleCommon').elasticNicName3)]"
],
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').elasticVmName3]",
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('moodleCommon').elasticVmSku]"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[variables('nicRef3')]"
}
]
},
"osProfile": {
"adminPassword": "[parameters('moodleCommon').sshPassword]",
"adminUsername": "[parameters('moodleCommon').sshUsername]",
"computerName": "[parameters('moodleCommon').elasticVmName3]"
},
"storageProfile": {
"dataDisks": [],
"imageReference": "[parameters('moodleCommon').osType]",
"osDisk": {
"createOption": "fromImage",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"name": "[parameters('moodleCommon').elasticVmName3]"
}
}
},
"tags": {
"displayName": "Elastic Search Virtual Machine"
},
"type": "Microsoft.Compute/virtualMachines"
},
{
"apiVersion": "2015-01-01",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('moodleCommon').elasticVmName3)]"
],
"name": "[concat(parameters('moodleCommon').elasticVmName3,'-ScriptProcessor')]",
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[parameters('moodleCommon')]"
}
},
"templateLink": {
"uri": "[concat(parameters('moodleCommon').baseTemplateUrl,'elasticconfig',parameters('moodleCommon').applyScriptsSwitch,'.json')]"
}
},
"type": "Microsoft.Resources/deployments"
},
{
"apiVersion": "2015-01-01",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/',parameters('moodleCommon').elasticVmName3)]"
],
"name": "[concat(parameters('moodleCommon').elasticVmName3,'-Backup')]",
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[parameters('moodleCommon')]"
},
"vmName": {
"value": "[parameters('moodleCommon').elasticVmName3]"
}
},
"templateLink": {
"uri": "[concat(parameters('moodleCommon').baseTemplateUrl,'recoveryservicesEnlist',parameters('moodleCommon').azureBackupSwitch,'.json')]"
}
},
"type": "Microsoft.Resources/deployments"
}
],
"variables": {
"documentation01": "This sub-template drives the elastic which is used as the access-point for other moodle VM's ",
"documentation02": "It expects certain values in the 'common' datastructure.",
"documentation03": " vnetName - name of the virtual network",
"documentation04": " subnetElastic - name of subnet for elastic (and vm scale set)",
"documentation05": " computeApi - the 'managed' resources need to all use this value",
"documentation06": " elasticNicName1 - name of the eastlic vm 1 network interface",
"documentation07": " elasticNicName2 - name of the eastlic vm 2 network interface",
"documentation08": " elasticNicName3 - name of the eastlic vm 3 network interface",
"documentation09": " elasticVmName1 - name of the eastlic vm 1",
"documentation10": " elasticVmName2 - name of the eastlic vm 2",
"documentation11": " elasticVmName3 - name of the eastlic vm 3",
"documentation09": " elasticVm1IP - IP of the eastlic vm 1",
"documentation10": " elasticVm2IP - IP of the eastlic vm 2",
"documentation11": " elasticVm3IP - IP of the eastlic vm 3",
"documentation12": "This sub-template calls other sub-templates",
"documentation13": " elasticconfig - conditionally applies post-deployment script on the VM",
"documentation14": " recoveryservicesEnlist - conditionally enlists the VM into the backup regimen",
"nicRef1": "[resourceId('Microsoft.Network/networkInterfaces', parameters('moodleCommon').elasticNicName1)]",
"nicRef2": "[resourceId('Microsoft.Network/networkInterfaces', parameters('moodleCommon').elasticNicName2)]",
"nicRef3": "[resourceId('Microsoft.Network/networkInterfaces', parameters('moodleCommon').elasticNicName3)]",
"subnetElasticRef": "[concat(resourceId('Microsoft.Network/virtualNetworks', parameters('moodleCommon').vnetName), '/subnets/',parameters('moodleCommon').subnetElastic)]"
}
}

Просмотреть файл

@ -0,0 +1,18 @@
{
"$schema": "https://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": [],
"variables": {
"documentation1": "This sub-template intentionally blank - a blank template allows for an optional exectuion strategy",
"documentation2": "",
"documentation3": "You should look for a template of the same name, but with a 1 instead of a 0 (at the end)"
}
}

Просмотреть файл

@ -0,0 +1,86 @@
{
"$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": [
{
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"name": "[concat(parameters('moodleCommon').elasticVmName1,'/','install_elastic')]",
"properties": {
"autoUpgradeMinorVersion": true,
"publisher": "Microsoft.OSTCExtensions",
"settings": {
"commandToExecute": "[variables('cmdExec')]",
"fileUris": [
"[variables('scriptUri')]"
]
},
"type": "CustomScriptForLinux",
"typeHandlerVersion": "1.4"
},
"tags": {
"displayName": "install_elastic"
},
"type": "Microsoft.Compute/virtualMachines/extensions"
},
{
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"name": "[concat(parameters('moodleCommon').elasticVmName2,'/','install_elastic')]",
"properties": {
"autoUpgradeMinorVersion": true,
"publisher": "Microsoft.OSTCExtensions",
"settings": {
"commandToExecute": "[variables('cmdExec')]",
"fileUris": [
"[variables('scriptUri')]"
]
},
"type": "CustomScriptForLinux",
"typeHandlerVersion": "1.4"
},
"tags": {
"displayName": "install_elastic"
},
"type": "Microsoft.Compute/virtualMachines/extensions"
},
{
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"name": "[concat(parameters('moodleCommon').elasticVmName3,'/','install_elastic')]",
"properties": {
"autoUpgradeMinorVersion": true,
"publisher": "Microsoft.OSTCExtensions",
"settings": {
"commandToExecute": "[variables('cmdExec')]",
"fileUris": [
"[variables('scriptUri')]"
]
},
"type": "CustomScriptForLinux",
"typeHandlerVersion": "1.4"
},
"tags": {
"displayName": "install_elastic"
},
"type": "Microsoft.Compute/virtualMachines/extensions"
}
],
"variables": {
"cmdExec": "[concat('bash ', parameters('moodleCommon').elasticScriptFilename, ' ', parameters('moodleCommon').elasticClusterName, ' ', parameters('moodleCommon').elasticVm1IP, ' ', parameters('moodleCommon').elasticVm2IP, ' ', parameters('moodleCommon').elasticVm3IP)]",
"documentation01": "This sub-template applies a specific post-deployment script to the controller vm",
"documentation02": "It expects certain values in the 'common' datastructure.",
"documentation03": " ScriptLocation - web URI",
"documentation04": " elasticScriptFilename - name of script file",
"documentation05": " elasticVmName - name of the elastic search vm generic name",
"scriptUri": "[concat(parameters('moodleCommon').ScriptLocation,parameters('moodleCommon').elasticScriptFilename)]"
}
}

Просмотреть файл

@ -1,48 +1,63 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { "moodleCommon": { "type": "object", "metadata": { "description": "Common Moodle values" } } },
"variables": {
"documentation1": "This sub-template drives the gluster (scale-out network-attached storage file system) creation process.",
"documentation2": "It expects certain values in the 'common' datastructure.",
"documentation3": " computeApi - the 'managed' resources need to all use this value",
"documentation4": " gfxAvailabilitySetName - name of availability set for the gluster farm",
"documentation5": " glusterVmCount - number of nodes to create",
"documentation6": "This sub-template calls other sub-templates",
"documentation7": " glustervm - number of nodes in the gluster farm"
},
"resources": [
{
"type": "Microsoft.Compute/availabilitySets",
"apiVersion": "[parameters('moodleCommon').computeApi]",
"name": "[parameters('moodleCommon').gfxAvailabilitySetName]",
"location": "[resourceGroup().location]",
"tags": { "displayName": "Gluster Availability Set" },
"properties": { "platformUpdateDomainCount": 5, "platformFaultDomainCount": 2, "managed": "true" }
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"name" : "[concat('glustervm',copyindex())]",
"dependsOn": [ "[concat('Microsoft.Compute/availabilitySets/',parameters('moodleCommon').gfxAvailabilitySetName)]" ],
"copy": { "name": "vmloop", "count": "[parameters('moodleCommon').glusterVmCount]" },
"properties": {
"mode": "Incremental",
"templateLink": { "uri": "[concat( parameters('moodleCommon').baseTemplateUrl,'glustervm.json')]" },
"parameters": { "moodleCommon": { "value": "[parameters('moodleCommon')]" },
"counter": { "value": "[copyindex()]" } }
}
}
]
}
"contentVersion": "1.0.0.0",
"parameters": {
"moodleCommon": {
"metadata": {
"description": "Common Moodle values"
},
"type": "object"
}
},
"resources": [
{
"apiVersion": "[parameters('moodleCommon').computeApi]",
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').gfxAvailabilitySetName]",
"properties": {
"managed": true,
"platformFaultDomainCount": 2,
"platformUpdateDomainCount": 5
},
"tags": {
"displayName": "Gluster Availability Set"
},
"type": "Microsoft.Compute/availabilitySets"
},
{
"apiVersion": "2015-01-01",
"copy": {
"count": "[parameters('moodleCommon').glusterVmCount]",
"name": "vmloop"
},
"dependsOn": [
"[concat('Microsoft.Compute/availabilitySets/',parameters('moodleCommon').gfxAvailabilitySetName)]"
],
"name": "[concat('glustervm',copyindex())]",
"properties": {
"mode": "Incremental",
"parameters": {
"counter": {
"value": "[copyindex()]"
},
"moodleCommon": {
"value": "[parameters('moodleCommon')]"
}
},
"templateLink": {
"uri": "[concat( parameters('moodleCommon').baseTemplateUrl,'glustervm.json')]"
}
},
"type": "Microsoft.Resources/deployments"
}
],
"variables": {
"documentation1": "This sub-template drives the gluster (scale-out network-attached storage file system) creation process.",
"documentation2": "It expects certain values in the 'common' datastructure.",
"documentation3": " computeApi - the 'managed' resources need to all use this value",
"documentation4": " gfxAvailabilitySetName - name of availability set for the gluster farm",
"documentation5": " glusterVmCount - number of nodes to create",
"documentation6": "This sub-template calls other sub-templates",
"documentation7": " glustervm - number of nodes in the gluster farm"
}
}

Просмотреть файл

@ -1,140 +1,210 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"moodleCommon": { "type": "object", "metadata": { "description": "Common Moodle values" } },
"counter": { "type": "int", "metadata": { "description": "from the copyindex function of calling template" } }
},
"variables": {
"documentation01": "This sub-template create the nodes of the gluster farm",
"documentation02": "It expects certain values in the 'common' datastructure.",
"documentation03": " computeApi - the 'managed' resources need to all use this value",
"documentation04": " gfxAvailabilitySetName - name of availability set for the gluster farm",
"documentation05": " vnetName - name of virtual network",
"documentation06": " subnetSan - name of subnet for gluster",
"documentation07": " gfsNameRoot - nameroot for the gluster nodes - combined with counter to get actual name of each node - disk and nic follow the naming scheme",
"documentation08": " glusterTshirtSize - supports flexible sizing - translates to a CPU/MEM/DISK details",
"documentation09": " adminUsername - OS accountusername",
"documentation10": " adminPassword - OS account password",
"documentation11": " osType - an array of value that specifies the type of VM",
"documentation15": "This sub-template calls other sub-templates",
"documentation16": " diskSelection - returns an arry of disk names - for flexible sizing",
"documentation17": " glustervmconfig - conditionally applies post-deployment script on the VM",
"documentation18": " recoveryservicesEnlist - conditionally enlists the VM into the backup regimen",
"subnetSanRef": "[concat(resourceId('Microsoft.Network/virtualNetworks', parameters('moodleCommon').vnetName), '/subnets/',parameters('moodleCommon').subnetSan)]",
"asRef": "[ resourceId('Microsoft.Compute/availabilitySets', parameters('moodleCommon').gfxAvailabilitySetName)]",
"nicRef": "[ resourceId('Microsoft.Network/networkInterfaces', variables('nicName') )]",
"vmName": "[concat(parameters('moodleCommon').gfsNameRoot,parameters('counter'))]",
"nicName": "[concat(variables('vmName'),'-nic')]",
"diskLoop": "[concat(variables('vmName'),'-disk')]",
"GlusterSizeSmall": { "vmSku": "Standard_DS2_v2", "diskCount": 4, "diskSize": 127 },
"GlusterSizeMedium": { "vmSku": "Standard_DS3_v2", "diskCount": 2, "diskSize": 512 },
"GlusterSizeLarge": { "vmSku": "Standard_DS4_v2", "diskCount": 2, "diskSize": 1023 },
"GlusterTshirt" : "[variables(concat('GlusterSize', parameters('moodleCommon').glusterTshirtSize))]"
},
"resources": [
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2015-05-01-preview",
"name": "[variables('nicName')]",
"location": "[resourceGroup().location]",
"tags": { "displayName": "Gluster VM NIC" },
"properties": { "ipConfigurations": [ { "name": "ipcfggfs", "properties": { "privateIPAllocationMethod": "Dynamic", "subnet": { "id": "[variables('subnetSanRef')]" } } } ] }
},
{
"type": "Microsoft.Compute/disks",
"apiVersion": "[parameters('moodleCommon').computeApi]",
"name": "[concat(variables('vmName'),'-datadisk',copyIndex(1))]",
"location": "[resourceGroup().location]",
"tags": { "displayName": "Gluster VM Data Disk" },
"copy": { "name": "[variables('diskLoop')]", "count": "[variables('GlusterTshirt').diskCount]" },
"properties": { "creationData": { "createOption": "Empty" }, "accountType": "Premium_LRS", "diskSizeGB": "[variables('GlusterTshirt').diskSize]" }
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"name": "[concat(variables('vmName'),'-diskSelection')]",
"dependsOn": [ "[variables('diskLoop')]" ],
"properties": {
"mode": "Incremental",
"templateLink": { "uri": "[concat(parameters('moodleCommon').baseTemplateUrl,'diskSelection.json')]" },
"parameters": { "vmName": { "value": "[variables('vmName')]" },
"vmDiskCount": { "value": "[variables('GlusterTshirt').diskCount]" } }
}
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "[parameters('moodleCommon').computeApi]",
"name": "[variables('vmName')]",
"location": "[resourceGroup().location]",
"tags": { "displayName": "Gluster Virtual Machine" },
"dependsOn": [ "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]", "[concat('Microsoft.Resources/deployments/',concat(variables('vmName'),'-diskSelection'))]" ],
"properties": {
"availabilitySet": { "id": "[variables( 'asRef')]" },
"networkProfile": { "networkInterfaces": [ { "id": "[variables('nicRef')]" } ] },
"hardwareProfile": { "vmSize": "[variables('GlusterTshirt').vmSku]" },
"osProfile": { "computerName": "[variables('vmName')]", "adminUsername": "[parameters('moodleCommon').adminUsername]", "adminPassword": "[parameters('moodleCommon').adminPassword]" },
"storageProfile": { "imageReference": "[parameters('moodleCommon').osType]",
"osDisk": { "name": "[variables('vmName')]", "createOption": "fromImage", "managedDisk": { "storageAccountType": "Premium_LRS" } },
"dataDisks": "[reference(concat(variables('vmName'),'-diskSelection')).outputs.dataDiskArray.value]"
}
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"name": "[concat(variables('vmName'),'-ScriptProcessor')]",
"dependsOn": [ "[concat('Microsoft.Compute/virtualMachines/',variables('vmName'))]" ],
"properties": {
"mode": "Incremental",
"templateLink": { "uri": "[concat( parameters('moodleCommon').baseTemplateUrl,'glustervmconfig',parameters('moodleCommon').applyScriptsSwitch,'.json')]" },
"parameters": { "moodleCommon": { "value": "[parameters('moodleCommon')]" },
"vmName": { "value": "[ variables('vmName')]" }, "vmNumber": { "value": "[parameters('counter')]" } }
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"name": "[concat(variables('vmName'),'-Backup')]",
"dependsOn": [ "[concat('Microsoft.Compute/virtualMachines/',variables('vmName'))]" ],
"properties": {
"mode": "Incremental",
"templateLink": { "uri": "[concat( parameters('moodleCommon').baseTemplateUrl,'recoveryservicesEnlist',parameters('moodleCommon').azureBackupSwitch,'.json')]" },
"parameters": { "moodleCommon": { "value": "[parameters('moodleCommon')]" }, "vmName": { "value": "[variables('vmName')]"} }
}
}
]
}
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"counter": {
"metadata": {
"description": "from the copyindex function of calling template"
},
"type": "int"
},
"moodleCommon": {
"metadata": {
"description": "Common Moodle values"
},
"type": "object"
}
},
"resources": [
{
"apiVersion": "2015-05-01-preview",
"location": "[resourceGroup().location]",
"name": "[variables('nicName')]",
"properties": {
"ipConfigurations": [
{
"name": "ipcfggfs",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[variables('subnetSanRef')]"
}
}
}
]
},
"tags": {
"displayName": "Gluster VM NIC"
},
"type": "Microsoft.Network/networkInterfaces"
},
{
"apiVersion": "[parameters('moodleCommon').computeApi]",
"copy": {
"count": "[parameters('moodleCommon').glusterDiskCount]",
"name": "[variables('diskLoop')]"
},
"location": "[resourceGroup().location]",
"name": "[concat(variables('vmName'),'-datadisk',copyIndex(1))]",
"properties": {
"accountType": "Premium_LRS",
"creationData": {
"createOption": "Empty"
},
"diskSizeGB": "[parameters('moodleCommon').glusterDiskSize]"
},
"tags": {
"displayName": "Gluster VM Data Disk"
},
"type": "Microsoft.Compute/disks"
},
{
"apiVersion": "2015-01-01",
"dependsOn": [
"[variables('diskLoop')]"
],
"name": "[concat(variables('vmName'),'-diskSelection')]",
"properties": {
"mode": "Incremental",
"parameters": {
"vmDiskCount": {
"value": "[parameters('moodleCommon').glusterDiskCount]"
},
"vmName": {
"value": "[variables('vmName')]"
}
},
"templateLink": {
"uri": "[concat(parameters('moodleCommon').baseTemplateUrl,'diskSelection.json')]"
}
},
"type": "Microsoft.Resources/deployments"
},
{
"apiVersion": "[parameters('moodleCommon').computeApi]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]",
"[concat('Microsoft.Resources/deployments/',concat(variables('vmName'),'-diskSelection'))]"
],
"location": "[resourceGroup().location]",
"name": "[variables('vmName')]",
"properties": {
"availabilitySet": {
"id": "[variables( 'asRef')]"
},
"hardwareProfile": {
"vmSize": "[parameters('moodleCommon').glusterVmSku]"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[variables('nicRef')]"
}
]
},
"osProfile": {
"adminUsername": "[parameters('moodleCommon').sshUsername]",
"computerName": "[variables('vmName')]",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"path": "[concat('/home/', parameters('moodleCommon').sshUsername, '/.ssh/authorized_keys')]",
"keyData": "[parameters('moodleCommon').sshPublicKey]"
}
]
}
}
},
"storageProfile": {
"dataDisks": "[reference(concat(variables('vmName'),'-diskSelection')).outputs.dataDiskArray.value]",
"imageReference": "[parameters('moodleCommon').osType]",
"osDisk": {
"createOption": "fromImage",
"managedDisk": {
"storageAccountType": "Premium_LRS"
},
"name": "[variables('vmName')]"
}
}
},
"tags": {
"displayName": "Gluster Virtual Machine"
},
"type": "Microsoft.Compute/virtualMachines"
},
{
"apiVersion": "2015-01-01",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/',variables('vmName'))]"
],
"name": "[concat(variables('vmName'),'-ScriptProcessor')]",
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[parameters('moodleCommon')]"
},
"vmName": {
"value": "[ variables('vmName')]"
},
"vmNumber": {
"value": "[parameters('counter')]"
}
},
"templateLink": {
"uri": "[concat( parameters('moodleCommon').baseTemplateUrl,'glustervmconfig',parameters('moodleCommon').applyScriptsSwitch,'.json')]"
}
},
"type": "Microsoft.Resources/deployments"
},
{
"apiVersion": "2015-01-01",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/',variables('vmName'))]"
],
"name": "[concat(variables('vmName'),'-Backup')]",
"properties": {
"mode": "Incremental",
"parameters": {
"moodleCommon": {
"value": "[parameters('moodleCommon')]"
},
"vmName": {
"value": "[variables('vmName')]"
}
},
"templateLink": {
"uri": "[concat( parameters('moodleCommon').baseTemplateUrl,'recoveryservicesEnlist',parameters('moodleCommon').azureBackupSwitch,'.json')]"
}
},
"type": "Microsoft.Resources/deployments"
}
],
"variables": {
"asRef": "[ resourceId('Microsoft.Compute/availabilitySets', parameters('moodleCommon').gfxAvailabilitySetName)]",
"diskLoop": "[concat(variables('vmName'),'-disk')]",
"documentation01": "This sub-template create the nodes of the gluster farm",
"documentation02": "It expects certain values in the 'common' datastructure.",
"documentation03": " computeApi - the 'managed' resources need to all use this value",
"documentation04": " gfxAvailabilitySetName - name of availability set for the gluster farm",
"documentation05": " vnetName - name of virtual network",
"documentation06": " subnetSan - name of subnet for gluster",
"documentation07": " gfsNameRoot - nameroot for the gluster nodes - combined with counter to get actual name of each node - disk and nic follow the naming scheme",
"documentation08": " glusterVmSku - VM instance size for gluster nodes",
"documentation09": " sshUsername - OS accountusername",
"documentation10": " sshPassword - OS account password",
"documentation11": " osType - an array of value that specifies the type of VM",
"documentation15": "This sub-template calls other sub-templates",
"documentation16": " diskSelection - returns an arry of disk names - for flexible sizing",
"documentation17": " glustervmconfig - conditionally applies post-deployment script on the VM",
"documentation18": " recoveryservicesEnlist - conditionally enlists the VM into the backup regimen",
"documentation19": " glusterDiskCount - Number of disks to raid0 for the gluster mount",
"documentation20": " glusterDiskSize - Size per disk for gluster",
"nicName": "[concat(variables('vmName'),'-nic')]",
"nicRef": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]",
"subnetSanRef": "[concat(resourceId('Microsoft.Network/virtualNetworks', parameters('moodleCommon').vnetName), '/subnets/',parameters('moodleCommon').subnetSan)]",
"vmName": "[concat(parameters('moodleCommon').gfsNameRoot,parameters('counter'))]"
}
}

Просмотреть файл

@ -1,18 +1,30 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"moodleCommon": { "type": "object", "metadata": { "description": "Common Moodle values" } },
"vmName": { "type": "string", "metadata": { "description": "Name of VM to process script" } },
"vmNumber": { "type": "int", "metadata": { "description": "Number of the VM in the pool" } }
},
"variables": {
"documentation1": "This sub-template intentionally blank - a blank template allows for an optional exectuion strategy",
"documentation2": "",
"documentation3": "You should look for a template of the same name, but with a 1 instead of a 0 (at the end)"
},
"resources": []
}
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"moodleCommon": {
"metadata": {
"description": "Common Moodle values"
},
"type": "object"
},
"vmName": {
"metadata": {
"description": "Name of VM to process script"
},
"type": "string"
},
"vmNumber": {
"metadata": {
"description": "Number of the VM in the pool"
},
"type": "int"
}
},
"resources": [],
"variables": {
"documentation1": "This sub-template intentionally blank - a blank template allows for an optional exectuion strategy",
"documentation2": "",
"documentation3": "You should look for a template of the same name, but with a 1 instead of a 0 (at the end)"
}
}

Просмотреть файл

@ -1,41 +1,56 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"moodleCommon": { "type": "object", "metadata": { "description": "Common Moodle values" } },
"vmName": { "type": "string", "metadata": { "description": "Name of VM to process script - not actually used" } },
"vmNumber": { "type": "int", "metadata": { "description": "Number of the VM in the pool" } }
},
"variables": {
"documentation01": "This sub-template applies a specific post-deployment script to the gluster vms",
"documentation02": "It expects certain values in the 'common' datastructure.",
"documentation03": " ScriptLocation - partial web URI (equivalent to folder)(",
"documentation04": " glusterScriptFilename - name of script file",
"documentation06": " gfsNameRoot - nameroot of gluster farm - note that the code applies a vmNumber to get to the specific node",
"documentation07": " glusterVmCount - database (mariadb) password",
"scriptUri": "[concat(parameters('moodleCommon').ScriptLocation,parameters('moodleCommon').glusterScriptFilename)]",
"cmdExec": "[concat('bash ', parameters('moodleCommon').glusterScriptFilename, ' ', parameters('moodleCommon').gfsNameRoot, ' ', parameters('moodleCommon').subnetSanPrefix, ' data ', parameters('vmNumber'), ' ', parameters('moodleCommon').glusterVmCount)]"
},
"resources": [
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2015-05-01-preview",
"name": "[concat(parameters('vmName'),'/','install_gluster')]",
"location": "[resourceGroup().location]",
"tags": { "displayName": "GfsVmExtension" },
"properties": {
"publisher": "Microsoft.OSTCExtensions",
"type": "CustomScriptForLinux",
"typeHandlerVersion": "1.3",
"settings": { "fileUris": [ "[variables('scriptUri')]" ], "commandToExecute": "[variables('cmdExec')]"
}
}
}
]
}
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"moodleCommon": {
"metadata": {
"description": "Common Moodle values"
},
"type": "object"
},
"vmName": {
"metadata": {
"description": "Name of VM to process script - not actually used"
},
"type": "string"
},
"vmNumber": {
"metadata": {
"description": "Number of the VM in the pool"
},
"type": "int"
}
},
"resources": [
{
"apiVersion": "2015-05-01-preview",
"location": "[resourceGroup().location]",
"name": "[concat(parameters('vmName'),'/','install_gluster')]",
"properties": {
"publisher": "Microsoft.OSTCExtensions",
"settings": {
"commandToExecute": "[variables('cmdExec')]",
"fileUris": [
"[variables('scriptUri')]"
]
},
"type": "CustomScriptForLinux",
"typeHandlerVersion": "1.3"
},
"tags": {
"displayName": "GfsVmExtension"
},
"type": "Microsoft.Compute/virtualMachines/extensions"
}
],
"variables": {
"cmdExec": "[concat('bash ', parameters('moodleCommon').glusterScriptFilename, ' ', parameters('moodleCommon').gfsNameRoot, ' ', parameters('moodleCommon').subnetSanPrefix, ' data ', parameters('vmNumber'), ' ', parameters('moodleCommon').glusterVmCount)]",
"documentation01": "This sub-template applies a specific post-deployment script to the gluster vms",
"documentation02": "It expects certain values in the 'common' datastructure.",
"documentation03": " ScriptLocation - partial web URI (equivalent to folder)",
"documentation04": " glusterScriptFilename - name of script file",
"documentation06": " gfsNameRoot - nameroot of gluster farm - note that the code applies a vmNumber to get to the specific node",
"documentation07": " glusterVmCount - database (mariadb) password",
"scriptUri": "[concat(parameters('moodleCommon').ScriptLocation,parameters('moodleCommon').glusterScriptFilename)]"
}
}

Просмотреть файл

@ -1,90 +0,0 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { "moodleCommon": { "type": "object", "metadata": { "description": "Common Moodle values" } } },
"variables": {
"documentation01": "This sub-template drives the mariadb (similar to NoSQL) creation process.",
"documentation02": "It expects certain values in the 'common' datastructure.",
"documentation03": " computeApi - the 'managed' resources need to all use this value",
"documentation04": " dbAvailabilitySetName - name of availability set for the mariadb farm",
"documentation05": " dbLoadBalancerName - name of load-balnacer for the mariadb farm - drives the naming of several LB components",
"documentation06": " vnetName - name of virtual network",
"documentation07": " subnetDb - name of subnet for mariadb",
"documentation08": " dbAvailabilitySetName - name of availability set for the gluster farm",
"documentation9": "This sub-template calls other sub-templates",
"documentation10": " mariadbvm - creates each node (in a loop based on VM Count)",
"subnetDbRef": "[concat(resourceId('Microsoft.Network/virtualNetworks',parameters('moodleCommon').vnetName),'/subnets/',parameters('moodleCommon').subnetDb)]",
"feID": "[concat(resourceId('Microsoft.Network/loadBalancers',parameters('moodleCommon').dbLoadBalancerName),'/frontendIPConfigurations/', parameters('moodleCommon').dbFeName)]",
"beID": "[concat(resourceId('Microsoft.Network/loadBalancers',parameters('moodleCommon').dbLoadBalancerName),'/backendAddressPools/', parameters('moodleCommon').dbBeName)]",
"PRID": "[concat(resourceId('Microsoft.Network/loadBalancers',parameters('moodleCommon').dbLoadBalancerName),'/probes/', parameters('moodleCommon').dbProbe)]"
},
"resources": [
{
"type": "Microsoft.Compute/availabilitySets",
"apiVersion": "[parameters('moodleCommon').computeApi]",
"name": "[parameters('moodleCommon').dbAvailabilitySetName]",
"location": "[resourceGroup().location]",
"tags": { "displayName": "MariaDb Availability Set" },
"properties": { "platformUpdateDomainCount": 5, "platformFaultDomainCount": 2, "managed": "true" }
},
{
"type": "Microsoft.Network/loadBalancers",
"apiVersion": "2015-06-15",
"name": "[parameters('moodleCommon').dbLoadBalancerName]",
"location": "[resourceGroup().location]",
"tags": { "displayName": "MariaDb Internal Load Balancer" },
"properties": {
"frontendIPConfigurations": [ { "name": "[parameters('moodleCommon').dbFeName]", "properties": {"privateIPAllocationMethod": "Static", "privateIPAddress": "[parameters('moodleCommon').StaticIpMariaDb]", "subnet": { "id": "[variables('subnetDbRef')]" } } } ],
"backendAddressPools": [ { "name": "[parameters('moodleCommon').dbBeName]" } ],
"loadBalancingRules": [ { "name": "MariaDbListener", "properties": { "backendAddressPool": { "id": "[variables('beID')]" }, "frontendIPConfiguration": { "id": "[variables('feID')]" }, "probe": { "id": "[variables('prID')]" }, "protocol": "tcp", "frontendPort": 3306, "backendPort": 3306, "enableFloatingIP": false } } ],
"probes": [ { "name": "[parameters('moodleCommon').dbProbe]", "properties": { "protocol": "tcp", "port": 3306, "intervalInSeconds": "5", "numberOfProbes": "6" } } ]
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"name": "mariadbVmNaming",
"properties": {
"mode": "Incremental",
"templateLink": { "uri": "[concat(parameters('moodleCommon').baseTemplateUrl,'vmNameListSelecter.json')]" },
"parameters": { "vmNameRoot": { "value": "[parameters('moodleCommon').dbNameRoot]" },
"vmCount": { "value": "[parameters('moodleCommon').mariadbVmCount]" } }
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"name" : "[concat('mariadbvm',copyindex())]",
"dependsOn": [ "[concat('Microsoft.Compute/availabilitySets/',parameters('moodleCommon').dbAvailabilitySetName)]",
"[concat('Microsoft.Network/LoadBalancers/', parameters('moodleCommon').dbLoadBalancerName)]",
"Microsoft.Resources/deployments/mariadbVmNaming" ],
"copy": { "name": "vmloop", "count": "[parameters('moodleCommon').mariadbVmCount]" },
"properties": {
"mode": "Incremental",
"templateLink": { "uri": "[concat( parameters('moodleCommon').baseTemplateUrl,'mariadbvm.json')]" },
"parameters": { "moodleCommon": { "value": "[parameters('moodleCommon')]" },
"counter": { "value": "[copyindex()]" },
"vmNameList": { "value": "[replace(replace(reference('mariadbVmNaming').outputs.vmNameArray.value,'[',''),']','')]" } }
}
}
]
}

Просмотреть файл

@ -1,134 +0,0 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"moodleCommon": { "type": "object", "metadata": { "description": "Common Moodle values" } },
"counter": { "type": "int", "metadata": { "description": "from the copyindex function of calling template" } },
"vmNameList": { "type": "string", "metadata": { "description": "list of all names in the Maria DB cluster" } }
},
"variables": {
"documentation01": "This sub-template create the nodes of the mariadb farm",
"documentation02": "It expects certain values in the 'common' datastructure.",
"documentation03": " computeApi - the 'managed' resources need to all use this value",
"documentation04": " dbAvailabilitySetName - name of availability set for the db farm",
"documentation05": " vnetName - name of virtual network",
"documentation06": " subnetDb - name of subnet for mariadb",
"documentation07": " dbNameRoot - nameroot for the mariadb nodes - combined with counter to get actual name of each node - disk and nic follow the naming scheme",
"documentation08": " mariaDbTshirtSize - supports flexible sizing - translates to a CPU/MEM/DISK details",
"documentation09": " adminUsername - OS accountusername",
"documentation10": " adminPassword - OS account password",
"documentation11": " osType - an array of value that specifies the type of VM",
"documentation15": "This sub-template calls other sub-templates",
"documentation16": " mariadbvmconfig - conditionally applies post-deployment script on the VM",
"documentation17": " recoveryservicesEnlist - conditionally enlists the VM into the backup regimen",
"subnetDbRef": "[concat(resourceId('Microsoft.Network/virtualNetworks', parameters('moodleCommon').vnetName),'/subnets/',parameters('moodleCommon').subnetDb)]",
"asRef": "[ resourceId('Microsoft.Compute/availabilitySets', parameters('moodleCommon').dbAvailabilitySetName)]",
"nicRef": "[ resourceId('Microsoft.Network/networkInterfaces', variables('nicName') )]",
"feID": "[concat(resourceId('Microsoft.Network/loadBalancers',parameters('moodleCommon').dbLoadBalancerName),'/frontendIPConfigurations/', parameters('moodleCommon').dbFeName)]",
"beID": "[concat(resourceId('Microsoft.Network/loadBalancers',parameters('moodleCommon').dbLoadBalancerName),'/backendAddressPools/', parameters('moodleCommon').dbBeName)]",
"PRID": "[concat(resourceId('Microsoft.Network/loadBalancers',parameters('moodleCommon').dbLoadBalancerName),'/probes/', parameters('moodleCommon').dbProbe)]",
"vmName": "[concat(parameters('moodleCommon').dbNameRoot,parameters('counter'))]",
"nicName": "[concat(variables('vmName'),'-nic')]",
"diskLoop": "[concat(variables('vmName'),'-disk')]",
"MariadbSizeSmall": { "vmSku": "Standard_DS2_v2", "diskCount": 2, "diskSize": "256" },
"MariadbSizeMedium": { "vmSku": "Standard_DS3_v2", "diskCount": 2, "diskSize": "512" },
"MariadbSizeLarge": { "vmSku": "Standard_DS4_v2", "diskCount": 2, "diskSize": "1023" },
"MariadbTshirt" : "[variables(concat('MariadbSize', parameters('moodleCommon').mariaDbTshirtSize))]"
},
"resources": [
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2015-05-01-preview",
"name": "[variables('nicName')]",
"location": "[resourceGroup().location]",
"tags": { "displayName": "MariaDb VM NIC" },
"properties": { "ipConfigurations": [ { "name": "ipcfgdb", "properties": { "privateIPAllocationMethod": "Dynamic", "subnet": { "id": "[variables('subnetDbRef')]" }, "loadBalancerBackendAddressPools": [ { "id": "[variables('beID')]" } ] } } ] }
},
{
"type": "Microsoft.Compute/disks",
"apiVersion": "[parameters('moodleCommon').computeApi]",
"name": "[concat(variables('vmName'),'-datadisk',copyIndex(1))]",
"location": "[resourceGroup().location]",
"tags": { "displayName": "MariaDb VM Data Disk" },
"copy": { "name": "[variables('diskLoop')]", "count": "[variables('MariadbTshirt').diskCount]" },
"properties": { "creationData": { "createOption": "Empty" }, "accountType": "Premium_LRS", "diskSizeGB": "[variables('MariadbTshirt').diskSize]" }
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "[parameters('moodleCommon').computeApi]",
"name": "[variables('vmName')]",
"location": "[resourceGroup().location]",
"tags": { "displayName": "MariaDb Virtual Machine" },
"dependsOn": [ "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]", "[variables('diskLoop')]" ],
"properties": {
"availabilitySet": { "id": "[variables( 'asRef')]" },
"networkProfile": { "networkInterfaces": [ { "id": "[variables('nicRef')]" } ] },
"hardwareProfile": { "vmSize": "[variables('MariaDbTshirt').vmSku]" },
"osProfile": { "computerName": "[variables('vmName')]", "adminUsername": "[parameters('moodleCommon').adminUsername]", "adminPassword": "[parameters('moodleCommon').adminPassword]" },
"storageProfile": { "imageReference": "[parameters('moodleCommon').osType]",
"osDisk": { "name": "[variables('vmName')]", "createOption": "fromImage", "managedDisk": { "storageAccountType": "Premium_LRS" } },
"dataDisks": [ { "lun": 0, "managedDisk": { "id": "[resourceId('Microsoft.Compute/disks', concat(variables('vmName'),'-datadisk1'))]" }, "caching": "None", "createOption": "Attach" },
{ "lun": 1, "managedDisk": { "id": "[resourceId('Microsoft.Compute/disks', concat(variables('vmName'),'-datadisk2'))]" }, "caching": "None", "createOption": "Attach" } ] }
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"name": "[concat(variables('vmName'),'-ScriptProcessor')]",
"dependsOn": [ "[concat('Microsoft.Compute/virtualMachines/',variables('vmName'))]" ],
"properties": {
"mode": "Incremental",
"templateLink": { "uri": "[concat( parameters('moodleCommon').baseTemplateUrl,'mariadbvmconfig',parameters('moodleCommon').applyScriptsSwitch,'.json')]" },
"parameters": { "moodleCommon": { "value": "[parameters('moodleCommon')]" },
"vmNameList": { "value": "[parameters('vmNameList')]" },
"vmName": { "value": "[ variables('vmName')]" },
"vmNumber": { "value": "[parameters('counter')]" }
}
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"name": "[concat(variables('vmName'),'-Backup')]",
"dependsOn": [ "[concat('Microsoft.Compute/virtualMachines/',variables('vmName'))]" ],
"properties": {
"mode": "Incremental",
"templateLink": { "uri": "[concat( parameters('moodleCommon').baseTemplateUrl,'recoveryservicesEnlist',parameters('moodleCommon').azureBackupSwitch,'.json')]" },
"parameters": { "moodleCommon": { "value": "[parameters('moodleCommon')]" }, "vmName": { "value": "[variables('vmName')]"} }
}
}
]
}

Просмотреть файл

@ -1,18 +0,0 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"moodleCommon": { "type": "object", "metadata": { "description": "Common Moodle values" } },
"vmName": { "type": "string", "metadata": { "description": "Name of VM to process script" } },
"vmNumber": { "type": "int", "metadata": { "description": "Number of the VM in the pool" } }
},
"variables": {
"documentation1": "This sub-template intentionally blank - a blank template allows for an optional exectuion strategy",
"documentation2": "",
"documentation3": "You should look for a template of the same name, but with a 1 instead of a 0 (at the end)"
},
"resources": []
}

Просмотреть файл

@ -1,35 +0,0 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"moodleCommon": { "type": "object", "metadata": { "description": "Common Moodle values" } },
"vmNameList": { "type": "string", "metadata": { "description": "list of all names in the Maria DB cluster" } },
"vmName": { "type": "string", "metadata": { "description": "Name of VM to process script" } },
"vmNumber": { "type": "int", "metadata": { "description": "Number of the VM in the pool" } }
},
"variables": {
"scriptUri": "[concat(parameters('moodleCommon').ScriptLocation,parameters('moodleCommon').mariaDbScriptFilename)]",
"cmdExec": "[concat('bash ', parameters('moodleCommon').mariaDbScriptFilename,' ', parameters('vmNumber'), ' ', parameters('moodleCommon').mariadbVmCount, ' ', parameters('vmNameList'), ' ', parameters('moodleCommon').mySqlUserPassword )]"
},
"resources": [
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2015-06-15",
"name": "[concat(parameters('vmName'),'/','install_mariadb')]",
"location": "[resourceGroup().location]",
"tags": { "displayName": "install_mariadb" },
"properties": {
"publisher": "Microsoft.OSTCExtensions",
"type": "CustomScriptForLinux",
"typeHandlerVersion": "1.4",
"autoUpgradeMinorVersion": true,
"settings": { "fileUris": [ "[variables('scriptUri')]" ], "commandToExecute": "[variables('cmdExec')]" }
}
}
]
}

63
nested/mysql.json Normal file
Просмотреть файл

@ -0,0 +1,63 @@
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"moodleCommon": {
"metadata": {
"description": "Common Moodle values"
},
"type": "object"
}
},
"resources": [
{
"apiVersion": "2017-04-30-preview",
"kind": "",
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').serverName]",
"properties": {
"administratorLogin": "[parameters('moodleCommon').dbLogin]",
"administratorLoginPassword": "[parameters('moodleCommon').dbLoginPassword]",
"sslEnforcement": "[parameters('moodleCommon').sslEnforcement]",
"storageMB": "[parameters('moodleCommon').skuSizeMB]",
"version": "[parameters('moodleCommon').mysqlVersion]"
},
"resources": [
{
"apiVersion": "2016-02-01-privatepreview",
"dependsOn": [
"[concat('Microsoft.DBforMySQL/servers/', parameters('moodleCommon').serverName)]"
],
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').firewallRuleName]",
"properties": {
"startIpAddress": "0.0.0.0",
"endIpAddress": "255.255.255.255"
},
"type": "firewallrules"
}
],
"sku": {
"capacity": "[parameters('moodleCommon').skuCapacityDTU]",
"family": "[parameters('moodleCommon').skuFamily]",
"name": "[parameters('moodleCommon').skuName]",
"size": "[parameters('moodleCommon').skuSizeMB]",
"tier": "[parameters('moodleCommon').skuTier]"
},
"type": "Microsoft.DBforMySQL/servers"
}
],
"variables": {
"documentation1": "This sub-template creates a mysql server. It expects certain values in the 'common' datastructure.",
"documentation10": " serverName - Mysql server name",
"documentation11": " mysqlVersion - Mysql version",
"documentation2": " administratorLogin - mysql admin username",
"documentation3": " administratorLoginPassword - mysql admin password",
"documentation4": " location - Mysql server location",
"documentation5": " skuCapacityDTU - Mysql database trasaction units",
"documentation6": " skuFamily - Mysql sku family",
"documentation7": " skuName - Mysql sku name",
"documentation8": " skuSizeMB - Mysql sku size in mb",
"documentation9": " skuTier - Mysql sku tier"
}
}

Просмотреть файл

@ -1,83 +1,229 @@
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { "moodleCommon": { "type": "object", "metadata": { "description": "Common Moodle values" } } },
"variables": {
"documentation01": "This sub-template creates a virtual network with three subnets and then creates the moodle load-balancer with public IP/dns",
"documentation02": "It expects certain values in the 'common' datastructure.",
"documentation03": " vnetName - name of virtual network",
"documentation04": " vNetAddressSpace - base of address of 16 bit address range",
"documentation05": " subnetWeb - name of subnet inside virtual network - will be assigned the .0.0/24 range",
"documentation06": " subnetSan - name of subnet inside virtual network - will be assigned the .1.0/24 range",
"documentation07": " subnetDb - name of subnet inside virtual network - will be assigned the .2.0/24 range",
"documentation08": " lbPipName - name of public IP",
"documentation09": " lbDnsName - DNS entry for public consumption",
"documentation10": " lbName - name of Moodl load balancer",
"pipID": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('moodleCommon').lbPipName)]",
"extLbID": "[resourceId('Microsoft.Network/loadBalancers', parameters('moodleCommon').lbName)]",
"extFeID": "[concat(variables('extLbID'),'/frontendIPConfigurations/', parameters('moodleCommon').extFeName )]",
"extBeID": "[concat(variables('extLbID'),'/backendAddressPools/', parameters('moodleCommon').extBeName )]",
"extProbeID": "[concat(variables('extLbID'),'/probes/', parameters('moodleCommon').extProbe )]",
"extNatPoolID": "[concat(variables('extLbID'),'/inboundNatPools/', parameters('moodleCommon').extNatPool)]"
},
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2015-06-15",
"name": "[parameters('moodleCommon').vnetName]",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": { "addressPrefixes": [ "[concat(parameters('moodleCommon').vNetAddressSpace,'/16')]" ] },
"subnets": [
{ "name": "[parameters('moodleCommon').subnetWeb]", "properties": { "addressPrefix": "[parameters('moodleCommon').subnetWebRange]" } },
{ "name": "[parameters('moodleCommon').subnetSan]", "properties": { "addressPrefix": "[parameters('moodleCommon').subnetSanRange]" } },
{ "name": "[parameters('moodleCommon').subnetDb]", "properties": { "addressPrefix": "[parameters('moodleCommon').subnetDbRange]" } } ]
}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2015-06-15",
"name": "[parameters('moodleCommon').lbPipName]",
"location": "[resourceGroup().location]",
"tags": { "displayName": "Load Balancer Public IP" },
"properties": { "publicIPAllocationMethod": "Dynamic", "dnsSettings": { "domainNameLabel": "[parameters('moodleCommon').lbDnsName]" } }
},
"$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.Network/loadBalancers",
"apiVersion": "2016-03-30",
"name": "[parameters('moodleCommon').lbName]",
"location": "[resourceGroup().location]",
"dependsOn": [ "[concat('Microsoft.Network/publicIPAddresses/',parameters('moodleCommon').lbPipName)]" ],
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').vnetName]",
"properties": {
"frontendIPConfigurations": [ { "name": "[parameters('moodleCommon').extFeName ]", "properties": { "publicIPAddress": { "id": "[variables('pipID')]" } } } ],
"backendAddressPools": [ { "name": "[parameters('moodleCommon').extBeName ]" } ],
"probes": [ { "name": "[parameters('moodleCommon').extProbe ]", "properties": {"protocol": "tcp", "port": 80, "intervalInSeconds": "5", "numberOfProbes": "3"} } ],
"inboundNatPools": [ { "name": "[parameters('moodleCommon').extNatPool]", "properties": { "frontendIPConfiguration": { "id": "[variables('extFeID')]" }, "protocol": "tcp", "frontendPortRangeStart": 50000, "frontendPortRangeEnd": 50119, "backendPort": 22 } } ],
"loadBalancingRules": [
{ "name": "Http", "properties": { "frontendIPConfiguration": { "id": "[variables('extFeID')]" },
"backendAddressPool": { "id": "[variables('extBeID')]" },
"probe": { "id": "[variables('extProbeID')]" },
"protocol": "tcp", "frontendPort": 80, "backendPort": 80, "enableFloatingIP": false, "idleTimeoutInMinutes": 5 } },
{ "name": "Https", "properties": { "frontendIPConfiguration": { "id": "[variables('extFeID')]" },
"backendAddressPool": { "id": "[variables('extBeID')]" },
"probe": { "id": "[variables('extProbeID')]" },
"protocol": "tcp", "frontendPort": 443, "backendPort": 443, "enableFloatingIP": false, "idleTimeoutInMinutes": 5 } } ]
}
}
]
}
"addressSpace": {
"addressPrefixes": [
"[concat(parameters('moodleCommon').vNetAddressSpace,'/16')]"
]
},
"subnets": [
{
"name": "[parameters('moodleCommon').subnetWeb]",
"properties": {
"addressPrefix": "[parameters('moodleCommon').subnetWebRange]"
}
},
{
"name": "[parameters('moodleCommon').subnetSan]",
"properties": {
"addressPrefix": "[parameters('moodleCommon').subnetSanRange]"
}
},
{
"name": "[parameters('moodleCommon').subnetRedis]",
"properties": {
"addressPrefix": "[parameters('moodleCommon').subnetRedisRange]"
}
},
{
"name": "[parameters('moodleCommon').subnetElastic]",
"properties": {
"addressPrefix": "[parameters('moodleCommon').subnetElasticRange]"
}
},
{
"name": "[parameters('moodleCommon').gatewaySubnet]",
"properties": {
"addressPrefix": "[parameters('moodleCommon').gatewaySubnetRange]"
}
}
]
},
"type": "Microsoft.Network/virtualNetworks"
},
{
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').gatewayPublicIPName]",
"properties": {
"publicIPAllocationMethod": "Dynamic"
},
"tags": {
"displayName": "Virtual network gateway Public IP"
},
"type": "Microsoft.Network/publicIPAddresses"
},
{
"apiVersion": "2015-06-15",
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks', parameters('moodleCommon').vnetName)]"
],
"name": "[concat(parameters('moodleCommon').vnetName, '/', parameters('moodleCommon').gatewaySubnet)]",
"properties": {
"addressPrefix": "[parameters('moodleCommon').gatewaySubnetRange]"
},
"type": "Microsoft.Network/virtualNetworks/subnets"
},
{
"apiVersion": "2015-06-15",
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', parameters('moodleCommon').gatewayPublicIPName)]",
"[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('moodleCommon').vnetName, parameters('moodleCommon').gatewaySubnet)]"
],
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').gatewayName]",
"properties": {
"activeActive": false,
"enableBgp": false,
"gatewayType": "[parameters('moodleCommon').gatewayType]",
"ipConfigurations": [
{
"name": "vnet-Gateway-Config",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('moodleCommon').gatewayPublicIPName)]"
},
"subnet": {
"id": "[variables('gatewaySubnetRef')]"
}
}
}
],
"sku": {
"name": "VpnGw1",
"tier": "VpnGw1",
"capacity": 2
},
"vpnType": "[parameters('moodleCommon').vpnType]"
},
"type": "Microsoft.Network/virtualNetworkGateways"
},
{
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').lbPipName]",
"properties": {
"dnsSettings": {
"domainNameLabel": "[parameters('moodleCommon').lbName]"
},
"publicIPAllocationMethod": "Static"
},
"tags": {
"displayName": "Load Balancer Public IP"
},
"type": "Microsoft.Network/publicIPAddresses"
},
{
"apiVersion": "2016-03-30",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/',parameters('moodleCommon').lbPipName)]"
],
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').lbName]",
"properties": {
"backendAddressPools": [
{
"name": "[parameters('moodleCommon').extBeName ]"
}
],
"frontendIPConfigurations": [
{
"name": "[parameters('moodleCommon').extFeName ]",
"properties": {
"publicIPAddress": {
"id": "[variables('pipID')]"
}
}
}
],
"loadBalancingRules": [
{
"name": "Http",
"properties": {
"backendAddressPool": {
"id": "[variables('extBeID')]"
},
"backendPort": 80,
"enableFloatingIP": false,
"frontendIPConfiguration": {
"id": "[variables('extFeID')]"
},
"frontendPort": 80,
"idleTimeoutInMinutes": 5,
"probe": {
"id": "[variables('extProbeID')]"
},
"protocol": "tcp"
}
},
{
"name": "Https",
"properties": {
"backendAddressPool": {
"id": "[variables('extBeID')]"
},
"backendPort": 443,
"enableFloatingIP": false,
"frontendIPConfiguration": {
"id": "[variables('extFeID')]"
},
"frontendPort": 443,
"idleTimeoutInMinutes": 5,
"probe": {
"id": "[variables('extProbeID')]"
},
"protocol": "tcp"
}
}
],
"probes": [
{
"name": "[parameters('moodleCommon').extProbe ]",
"properties": {
"intervalInSeconds": "5",
"numberOfProbes": "3",
"port": 80,
"protocol": "tcp"
}
}
]
},
"type": "Microsoft.Network/loadBalancers"
}
],
"variables": {
"documentation01": "This sub-template creates a virtual network with three subnets and then creates the moodle load-balancer with public IP/dns",
"documentation02": "It expects certain values in the 'common' datastructure.",
"documentation03": " vnetName - name of virtual network",
"documentation04": " vNetAddressSpace - base of address of 16 bit address range",
"documentation05": " subnetWeb - name of subnet inside virtual network - will be assigned the .0.0/24 range",
"documentation06": " subnetSan - name of subnet inside virtual network - will be assigned the .1.0/24 range",
"documentation07": " subnetRedis - name of subnet inside virtual network - will be assigned the .3.0/24 range",
"documentation08": " subnetElastic - name of subnet inside virtual network - will be assigned the .4.0/24 range",
"documentation09": " gatewaySubnet - name of subnet inside virtual network - will be assigned the .2.0/24 range",
"documentation10": " lbPipName - name of public IP",
"documentation11": " lbName - name of Moodl load balancer",
"extBeID": "[concat(variables('extLbID'),'/backendAddressPools/',parameters('moodleCommon').extBeName)]",
"extFeID": "[concat(variables('extLbID'),'/frontendIPConfigurations/',parameters('moodleCommon').extFeName)]",
"extLbID": "[resourceId('Microsoft.Network/loadBalancers',parameters('moodleCommon').lbName)]",
"extNatPoolID": "[concat(variables('extLbID'),'/inboundNatPools/',parameters('moodleCommon').extNatPool)]",
"extProbeID": "[concat(variables('extLbID'),'/probes/',parameters('moodleCommon').extProbe)]",
"gatewaySubnetRef": "[concat(resourceId('Microsoft.Network/virtualNetworks', parameters('moodleCommon').vnetName),'/subnets/',parameters('moodleCommon').gatewaySubnet)]",
"pipID": "[resourceId('Microsoft.Network/publicIPAddresses',parameters('moodleCommon').lbPipName)]"
}
}

63
nested/postgres.json Normal file
Просмотреть файл

@ -0,0 +1,63 @@
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"moodleCommon": {
"metadata": {
"description": "Common Moodle values"
},
"type": "object"
}
},
"resources": [
{
"apiVersion": "2016-02-01-privatepreview",
"kind": "",
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').serverName]",
"properties": {
"administratorLogin": "[parameters('moodleCommon').dbLogin]",
"administratorLoginPassword": "[parameters('moodleCommon').dbLoginPassword]",
"sslEnforcement": "[parameters('moodleCommon').sslEnforcement]",
"storageMB": "[parameters('moodleCommon').skuSizeMB]",
"version": "[parameters('moodleCommon').postgresVersion]"
},
"resources": [
{
"apiVersion": "2016-02-01-privatepreview",
"dependsOn": [
"[concat('Microsoft.DBforPostgreSQL/servers/', parameters('moodleCommon').serverName)]"
],
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').firewallRuleName]",
"properties": {
"startIpAddress": "0.0.0.0",
"endIpAddress": "255.255.255.255"
},
"type": "firewallrules"
}
],
"sku": {
"capacity": "[parameters('moodleCommon').skuCapacityDTU]",
"family": "[parameters('moodleCommon').skuFamily]",
"name": "[parameters('moodleCommon').skuName]",
"size": "[parameters('moodleCommon').skuSizeMB]",
"tier": "[parameters('moodleCommon').skuTier]"
},
"type": "Microsoft.DBforPostgreSQL/servers"
}
],
"variables": {
"documentation1": "This sub-template creates a postgresql server. It expects certain values in the 'common' datastructure.",
"documentation10": " serverName - Postgresql server name",
"documentation11": " postgresVersion - Postgresql version",
"documentation2": " administratorLogin - postgresql admin username",
"documentation3": " administratorLoginPassword - postgresql admin password",
"documentation4": " location - Postgresql server location",
"documentation5": " skuCapacityDTU - Postgresql database trasaction units",
"documentation6": " skuFamily - Postgresql sku family",
"documentation7": " skuName - Postgresql sku name",
"documentation8": " skuSizeMB - Postgresql sku size in mb",
"documentation9": " skuTier - Postgresql sku tier"
}
}

Просмотреть файл

@ -1,14 +1,18 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { "moodleCommon": { "type": "object", "metadata": { "description": "Common Moodle values" } } },
"variables": {
"documentation1": "This sub-template intentionally blank - a blank template allows for an optional exectuion strategy",
"documentation2": "",
"documentation3": "You should look for a template of the same name, but with a 1 instead of a 0 (at the end)"
},
"resources": []
}
"$schema": "https://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": [],
"variables": {
"documentation1": "This sub-template intentionally blank - a blank template allows for an optional exectuion strategy",
"documentation2": "",
"documentation3": "You should look for a template of the same name, but with a 1 instead of a 0 (at the end)"
}
}

Просмотреть файл

@ -1,57 +1,97 @@
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { "moodleCommon": { "type": "object", "metadata": { "description": "Common Moodle values" } } },
"variables": {
"documentation1": "This sub-template creates a recovery services vault. It expects certain values in the 'common' datastructure.",
"documentation2": " vaultName - name of virtual network",
"documentation3": " policyName - name of backup policy inside vault",
"documentation4": "",
"documentation5": "The policy will create a daily backup with the following retentions",
"documentation6": " Daily - keep last 7 daily",
"documentation7": " Weekly - keep last 4 Sundays",
"documentation8": " Monthly - keep last 6 1st-of-the-month",
"scheduleRunTimes": [ "2017-01-01T22:30:00Z" ],
"dailyRetentionDurationCount": 7,
"daysOfTheWeek": [ "Sunday" ],
"weeklyRetentionDurationCount": 4,
"monthlyRetentionDurationCount": 6
},
"resources": [
{
"type": "Microsoft.RecoveryServices/vaults",
"apiVersion": "2015-11-10",
"name": "[parameters('moodleCommon').vaultName]",
"location": "[resourceGroup().location]",
"sku": { "name": "RS0", "tier": "Standard" },
"properties": { }
},
{
"type": "Microsoft.RecoveryServices/vaults/backupPolicies",
"apiVersion": "2015-11-10",
"name": "[concat(parameters('moodleCommon').vaultName, '/', parameters('moodleCommon').policyName)]",
"location": "[resourceGroup().location]",
"dependsOn": [ "[concat('Microsoft.RecoveryServices/vaults/', parameters('moodleCommon').vaultName)]" ],
"properties": { "backupManagementType": "AzureIaasVM",
"schedulePolicy": { "scheduleRunFrequency": "Daily","scheduleRunDays": null, "scheduleRunTimes": "[variables('scheduleRunTimes')]", "schedulePolicyType": "SimpleSchedulePolicy" },
"retentionPolicy": {
"dailySchedule": { "retentionTimes": "[variables('scheduleRunTimes')]", "retentionDuration": { "count": "[variables( 'dailyRetentionDurationCount')]", "durationType": "Days" } },
"weeklySchedule": { "daysOfTheWeek": "[variables('daysOfTheWeek')]", "retentionTimes": "[variables('scheduleRunTimes')]", "retentionDuration": { "count": "[variables( 'weeklyRetentionDurationCount')]", "durationType": "Weeks" } },
"monthlySchedule": { "retentionScheduleFormatType": "Daily", "retentionScheduleDaily": { "daysOfTheMonth": [ { "date": 1, "isLast": false } ] }, "retentionScheduleWeekly": null, "retentionTimes": "[variables('scheduleRunTimes')]", "retentionDuration": { "count": "[variables('monthlyRetentionDurationCount')]", "durationType": "Months" } },
"retentionPolicyType": "LongTermRetentionPolicy"
}
}
}
]
"$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": [
{
"apiVersion": "2015-11-10",
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').vaultName]",
"properties": {},
"sku": {
"name": "RS0",
"tier": "Standard"
},
"type": "Microsoft.RecoveryServices/vaults"
},
{
"apiVersion": "2015-11-10",
"dependsOn": [
"[concat('Microsoft.RecoveryServices/vaults/', parameters('moodleCommon').vaultName)]"
],
"location": "[resourceGroup().location]",
"name": "[concat(parameters('moodleCommon').vaultName, '/', parameters('moodleCommon').policyName)]",
"properties": {
"backupManagementType": "AzureIaasVM",
"retentionPolicy": {
"dailySchedule": {
"retentionDuration": {
"count": "[variables( 'dailyRetentionDurationCount')]",
"durationType": "Days"
},
"retentionTimes": "[variables('scheduleRunTimes')]"
},
"monthlySchedule": {
"retentionDuration": {
"count": "[variables('monthlyRetentionDurationCount')]",
"durationType": "Months"
},
"retentionScheduleDaily": {
"daysOfTheMonth": [
{
"date": 1,
"isLast": false
}
]
},
"retentionScheduleFormatType": "Daily",
"retentionScheduleWeekly": null,
"retentionTimes": "[variables('scheduleRunTimes')]"
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": "[variables('daysOfTheWeek')]",
"retentionDuration": {
"count": "[variables( 'weeklyRetentionDurationCount')]",
"durationType": "Weeks"
},
"retentionTimes": "[variables('scheduleRunTimes')]"
}
},
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunDays": null,
"scheduleRunFrequency": "Daily",
"scheduleRunTimes": "[variables('scheduleRunTimes')]"
}
},
"type": "Microsoft.RecoveryServices/vaults/backupPolicies"
}
],
"variables": {
"dailyRetentionDurationCount": 7,
"daysOfTheWeek": [
"Sunday"
],
"documentation1": "This sub-template creates a recovery services vault. It expects certain values in the 'common' datastructure.",
"documentation2": " vaultName - name of virtual network",
"documentation3": " policyName - name of backup policy inside vault",
"documentation4": "",
"documentation5": "The policy will create a daily backup with the following retentions",
"documentation6": " Daily - keep last 7 daily",
"documentation7": " Weekly - keep last 4 Sundays",
"documentation8": " Monthly - keep last 6 1st-of-the-month",
"monthlyRetentionDurationCount": 6,
"scheduleRunTimes": [
"2017-01-01T22:30:00Z"
],
"weeklyRetentionDurationCount": 4
}
}

Просмотреть файл

@ -1,17 +1,24 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"moodleCommon": { "type": "object", "metadata": { "description": "Common Moodle values" } },
"vmName": { "type": "string", "metadata": { "description": "Name of VM to enlist in AzureBackup" } }
},
"variables": {
"documentation1": "This sub-template intentionally blank - a blank template allows for an optional exectuion strategy",
"documentation2": "",
"documentation3": "You should look for a template of the same name, but with a 1 instead of a 0 (at the end)"
},
"resources": []
}
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"moodleCommon": {
"metadata": {
"description": "Common Moodle values"
},
"type": "object"
},
"vmName": {
"metadata": {
"description": "Name of VM to enlist in AzureBackup"
},
"type": "string"
}
},
"resources": [],
"variables": {
"documentation1": "This sub-template intentionally blank - a blank template allows for an optional exectuion strategy",
"documentation2": "",
"documentation3": "You should look for a template of the same name, but with a 1 instead of a 0 (at the end)"
}
}

Просмотреть файл

@ -1,38 +1,41 @@
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"moodleCommon": { "type": "object", "metadata": { "description": "Common Moodle values" } },
"vmName": { "type": "string", "metadata": { "description": "Name of VM to enlist in AzureBackup" } }
},
"variables": {
"documentation1": "This sub-template adds a VM to the recovery services vault. It expects certain values in the 'common' datastructure.",
"documentation2": " vaultName - name of virtual network",
"documentation3": " policyName - name of backup policy inside vault",
"documentation4": "",
"backupFabric": "Azure",
"v2VmType": "Microsoft.Compute/virtualMachines",
"v2VmContainer": "iaasvmcontainer;iaasvmcontainerv2;",
"v2Vm": "vm;iaasvmcontainerv2;"
},
"resources": [
{
"type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems",
"apiVersion": "2016-06-01",
"name": "[concat(parameters('moodleCommon').vaultName, '/', variables('backupFabric'), '/', variables('v2VmContainer'), concat(resourceGroup().name,';',parameters('vmName')), '/', variables('v2Vm'), concat(resourceGroup().name,';',parameters('vmName')))]",
"location": "[resourceGroup().location]",
"properties": {
"protectedItemType": "[variables('v2VmType')]",
"policyId": "[resourceId('Microsoft.RecoveryServices/vaults/backupPolicies',parameters('moodleCommon').vaultName,parameters('moodleCommon').policyName )]",
"sourceResourceId": "[resourceId(subscription().subscriptionId,resourceGroup().name,'Microsoft.Compute/virtualMachines',parameters('vmName'))]"
}
}
]
"$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"
},
"vmName": {
"metadata": {
"description": "Name of VM to enlist in AzureBackup"
},
"type": "string"
}
},
"resources": [
{
"apiVersion": "2016-06-01",
"location": "[resourceGroup().location]",
"name": "[concat(parameters('moodleCommon').vaultName, '/', variables('backupFabric'), '/', variables('v2VmContainer'), concat(resourceGroup().name,';',parameters('vmName')), '/', variables('v2Vm'), concat(resourceGroup().name,';',parameters('vmName')))]",
"properties": {
"policyId": "[resourceId('Microsoft.RecoveryServices/vaults/backupPolicies',parameters('moodleCommon').vaultName,parameters('moodleCommon').policyName )]",
"protectedItemType": "[variables('v2VmType')]",
"sourceResourceId": "[resourceId(subscription().subscriptionId,resourceGroup().name,'Microsoft.Compute/virtualMachines',parameters('vmName'))]"
},
"type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems"
}
],
"variables": {
"backupFabric": "Azure",
"documentation1": "This sub-template adds a VM to the recovery services vault. It expects certain values in the 'common' datastructure.",
"documentation2": " vaultName - name of virtual network",
"documentation3": " policyName - name of backup policy inside vault",
"documentation4": "",
"v2Vm": "vm;iaasvmcontainerv2;",
"v2VmContainer": "iaasvmcontainer;iaasvmcontainerv2;",
"v2VmType": "Microsoft.Compute/virtualMachines"
}
}

Просмотреть файл

@ -1,22 +1,40 @@
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": { "moodleCommon": { "type": "object", "metadata": { "description": "Common Moodle values" } } },
"variables": {
"documentation1": "This sub-template creates a redis cache. It expects certain values in the 'common' datastructure.",
"documentation2": " redisCacheName - name of cache"
},
"resources": [
{
"type": "Microsoft.Cache/Redis",
"apiVersion": "2015-08-01",
"name": "[parameters('moodleCommon').redisCacheName]",
"location": "[resourceGroup().location]",
"properties": { "enableNonSslPort": false, "sku": { "name": "Basic", "capacity": 1, "family": "C" } }
}
]
}
"$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": [
{
"apiVersion": "2016-04-01",
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').redisCacheName]",
"properties": {
"enableNonSslPort": true,
"sku": {
"capacity": 1,
"family": "P",
"name": "Premium"
},
"subnetId": "[concat(resourceId('Microsoft.Network/virtualNetworks', parameters('moodleCommon').vnetName), '/subnets/', parameters('moodleCommon').subnetRedis)]"
},
"type": "Microsoft.Cache/Redis"
}
],
"variables": {
"documentation1": "This sub-template creates a redis cache. It expects certain values in the 'common' datastructure.",
"documentation2": " redisCacheName - name of cache",
"redisResourceId": "[concat(resourceGroup().id,'/providers/Microsoft.Cache/Redis/', parameters('moodleCommon').redisCacheName)]"
},
"outputs": {
"redisPrimaryKey": {
"value": "[listKeys(variables('redisResourceId'), '2016-04-01').primaryKey]",
"type": "string"
}
}
}

Просмотреть файл

@ -1,25 +1,36 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmNameRoot": { "type": "string" },
"vmCount": { "type": "int", "minValue": 2, "maxValue": 8 }
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"outputs": {
"vmNameArray": {
"type": "string",
"value": "[string(take(variables('diskArray'),parameters('vmCount')))]"
}
},
"variables": {
"documentation01": "This sub-template provides a way to return a flexible number of vmNames",
"documentation02": " vmNameRoot - used as apart of the naming of the VM(s)",
"documentation03": " vmCount - used to limit the nubmer of names returned (via the TAKE function) ",
"diskArray": [
"[concat(parameters('vmNameRoot'),'0')]", "[concat(parameters('vmNameRoot'),'1')]", "[concat(parameters('vmNameRoot'),'2')]", "[concat(parameters('vmNameRoot'),'3')]",
"[concat(parameters('vmNameRoot'),'4')]", "[concat(parameters('vmNameRoot'),'5')]", "[concat(parameters('vmNameRoot'),'6')]", "[concat(parameters('vmNameRoot'),'7')]"
]
},
"resources": [],
"outputs": { "vmNameArray": { "type": "string", "value": "[string(take(variables('diskArray'),parameters('vmCount')))]" } }
}
"parameters": {
"vmCount": {
"maxValue": 8,
"minValue": 2,
"type": "int"
},
"vmNameRoot": {
"type": "string"
}
},
"resources": [],
"variables": {
"diskArray": [
"[concat(parameters('vmNameRoot'),'0')]",
"[concat(parameters('vmNameRoot'),'1')]",
"[concat(parameters('vmNameRoot'),'2')]",
"[concat(parameters('vmNameRoot'),'3')]",
"[concat(parameters('vmNameRoot'),'4')]",
"[concat(parameters('vmNameRoot'),'5')]",
"[concat(parameters('vmNameRoot'),'6')]",
"[concat(parameters('vmNameRoot'),'7')]"
],
"documentation01": "This sub-template provides a way to return a flexible number of vmNames",
"documentation02": " vmNameRoot - used as apart of the naming of the VM(s)",
"documentation03": " vmCount - used to limit the nubmer of names returned (via the TAKE function) "
}
}

Просмотреть файл

@ -1,91 +1,223 @@
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { "moodleCommon": { "type": "object", "metadata": { "description": "Common Moodle values" } } },
"variables": {
"subnetWebRef": "[concat(resourceId('Microsoft.Network/virtualNetworks', parameters('moodleCommon').vnetName),'/subnets/',parameters('moodleCommon').subnetWeb)]",
"vmssID": "[ resourceId('Microsoft.Compute/virtualMachineScaleSets',parameters('moodleCommon').vmssName)]",
"dstorID": "[ resourceId('Microsoft.Storage/storageAccounts', parameters('moodleCommon').vmssdStorageAccounttName)]",
"pipID": "[ resourceId('Microsoft.Network/publicIPAddresses', parameters('moodleCommon').lbPipName)]",
"extLbID": "[ resourceId('Microsoft.Network/loadBalancers', parameters('moodleCommon').lbName)]",
"extFeID": "[concat(variables('extLbID'),'/frontendIPConfigurations/', parameters('moodleCommon').extFeName )]",
"extBeID": "[concat(variables('extLbID'),'/backendAddressPools/', parameters('moodleCommon').extBeName )]",
"extProbeID": "[concat(variables('extLbID'),'/probes/', parameters('moodleCommon').extProbe )]",
"extNatPoolID": "[concat(variables('extLbID'),'/inboundNatPools/', parameters('moodleCommon').extNatPool)]",
"storageApiVersion": "2015-06-15",
"wadLogs": "<WadCfg><DiagnosticMonitorConfiguration>",
"wadPerfCounter": "<PerformanceCounters scheduledTransferPeriod=\"PT1M\"><PerformanceCounterConfiguration counterSpecifier=\"\\Processor\\PercentProcessorTime\" sampleRate=\"PT15S\" unit=\"Percent\"><annotation displayName=\"CPU percentage guest OS\" locale=\"en-us\"/></PerformanceCounterConfiguration></PerformanceCounters>",
"wadCfgxStart": "[concat(variables('wadLogs'),variables('wadPerfCounter'),'<Metrics resourceId=\"')]",
"wadCfgxEnd": "[concat('\"><MetricAggregation scheduledTransferPeriod=\"PT1H\"/><MetricAggregation scheduledTransferPeriod=\"PT1M\"/></Metrics></DiagnosticMonitorConfiguration></WadCfg>')]",
"scriptUri": "[concat(parameters('moodleCommon').ScriptLocation,parameters('moodleCommon').moodleSetupScriptFilename)]",
"cmdExec": "[concat('bash ', parameters('moodleCommon').moodleSetupScriptFilename,' ',parameters('moodleCommon').gfsNameRoot,'0', ' ','data' )]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "[variables('storageApiVersion')]",
"name": "[parameters('moodleCommon').vmssdStorageAccounttName]",
"location": "[resourceGroup().location]",
"properties": { "accountType": "Standard_LRS" }
},
{
"type": "Microsoft.Compute/virtualMachineScaleSets",
"apiVersion": "2016-04-30-preview",
"name": "[parameters('moodleCommon').vmssName]",
"location": "[resourceGroup().location]",
"tags": { "displayName": "webfarm" },
"dependsOn": [ "[concat('Microsoft.Storage/storageAccounts/', parameters('moodleCommon').vmssdStorageAccounttName)]" ],
"sku": { "capacity": 3, "name": "Standard_D2", "tier": "Standard" },
"properties": { "overprovision": "true", "upgradePolicy": { "mode": "Manual" },
"virtualMachineProfile": {
"storageProfile": { "osDisk": { "caching": "ReadOnly", "createOption": "FromImage", "managedDisk": { "storageAccountType": "Standard_LRS" } }, "imageReference": "[parameters('moodleCommon').osType]" },
"osProfile": { "computerNamePrefix": "[parameters('moodleCommon').vmssName]", "adminUsername": "[parameters('moodleCommon').adminUsername]", "adminPassword": "[parameters('moodleCommon').adminPassword]" },
"networkProfile": { "networkInterfaceConfigurations": [ { "name": "vmssnic", "properties": { "ipConfigurations": [ { "name": "ipcfg_lb", "properties": { "subnet": { "id": "[variables('subnetWebRef')]" }, "loadBalancerBackendAddressPools": [ { "id": "[variables('extBeID')]" } ], "loadBalancerInboundNatPools": [ { "id": "[variables('extNatPoolID')]" } ] } } ], "primary": "true" } } ] },
"extensionProfile": {
"extensions": [
{ "name": "LinuxDiagnostic",
"properties": { "publisher": "Microsoft.OSTCExtensions", "type": "LinuxDiagnostic", "typeHandlerVersion": "2.3", "autoUpgradeMinorVersion": true,
"settings": { "xmlCfg": "[base64(concat(variables('wadCfgxStart'), variables('vmssID'), variables('wadCfgxEnd')))]", "storageAccount": "[parameters('moodleCommon').vmssdStorageAccounttName]" },
"protectedSettings": { "storageAccountName": "[parameters('moodleCommon').vmssdStorageAccounttName]", "storageAccountKey": "[listkeys(variables('dstorID'), variables('storageApiVersion')).key1]", "storageAccountEndPoint": "https://core.windows.net"} }
},
{ "name": "setup_moodle",
"properties": { "publisher": "Microsoft.OSTCExtensions", "type": "CustomScriptForLinux", "typeHandlerVersion": "1.4", "autoUpgradeMinorVersion": true,
"settings": { "fileUris": [ "[variables('scriptUri')]" ], "commandToExecute": "[variables('cmdExec')]" } }
}
]
}
}
}
},
{
"type": "Microsoft.Insights/autoscaleSettings",
"apiVersion": "2015-04-01",
"name": "autoscalewad",
"location": "[resourceGroup().location]",
"dependsOn": [ "[concat('Microsoft.Compute/virtualMachineScaleSets/', parameters('moodleCommon').vmssName)]" ],
"properties": { "name": "autoscalewad", "targetResourceUri": "[variables('vmssID')]", "enabled": true,
"profiles": [ { "name": "Profile1", "capacity": { "minimum": "2", "maximum": "10", "default": "4" },
"rules": [ { "scaleAction": { "direction": "Increase", "type": "ChangeCount", "value": "1", "cooldown": "PT1M" }, "metricTrigger": { "metricName": "\\Processor\\PercentProcessorTime", "metricNamespace": "", "metricResourceUri": "[variables('vmssID')]", "timeGrain": "PT1M", "statistic": "Average", "timeWindow": "PT5M", "timeAggregation": "Average", "operator": "GreaterThan", "threshold": 80 } },
{ "scaleAction": { "direction": "Decrease", "type": "ChangeCount", "value": "1", "cooldown": "PT5M" }, "metricTrigger": { "metricName": "\\Processor\\PercentProcessorTime", "metricNamespace": "", "metricResourceUri": "[variables('vmssID')]", "timeGrain": "PT1M", "statistic": "Average", "timeWindow": "PT5M", "timeAggregation": "Average", "operator": "LessThan", "threshold": 50 } } ] } ] }
}
]
}
"$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": [
{
"apiVersion": "[variables('storageApiVersion')]",
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').vmssdStorageAccounttName]",
"properties": {
"accountType": "Standard_LRS"
},
"type": "Microsoft.Storage/storageAccounts"
},
{
"apiVersion": "2016-04-30-preview",
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', parameters('moodleCommon').vmssdStorageAccounttName)]"
],
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').vmssName]",
"properties": {
"overprovision": "true",
"upgradePolicy": {
"mode": "Manual"
},
"virtualMachineProfile": {
"extensionProfile": {
"extensions": [
{
"name": "LinuxDiagnostic",
"properties": {
"autoUpgradeMinorVersion": true,
"protectedSettings": {
"storageAccountEndPoint": "https://core.windows.net",
"storageAccountKey": "[listkeys(variables('dstorID'), variables('storageApiVersion')).key1]",
"storageAccountName": "[parameters('moodleCommon').vmssdStorageAccounttName]"
},
"publisher": "Microsoft.OSTCExtensions",
"settings": {
"storageAccount": "[parameters('moodleCommon').vmssdStorageAccounttName]",
"xmlCfg": "[base64(concat(variables('wadCfgxStart'), variables('vmssID'), variables('wadCfgxEnd')))]"
},
"type": "LinuxDiagnostic",
"typeHandlerVersion": "2.3"
}
},
{
"name": "setup_moodle",
"properties": {
"autoUpgradeMinorVersion": true,
"publisher": "Microsoft.OSTCExtensions",
"settings": {
"commandToExecute": "[variables('cmdExec')]",
"fileUris": [
"[variables('scriptUri')]"
]
},
"type": "CustomScriptForLinux",
"typeHandlerVersion": "1.4"
}
}
]
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "vmssnic",
"properties": {
"ipConfigurations": [
{
"name": "ipcfg_lb",
"properties": {
"loadBalancerBackendAddressPools": [
{
"id": "[variables('extBeID')]"
}
],
"subnet": {
"id": "[variables('subnetWebRef')]"
}
}
}
],
"primary": "true"
}
}
]
},
"osProfile": {
"adminUsername": "[parameters('moodleCommon').sshUsername]",
"computerNamePrefix": "[parameters('moodleCommon').vmssName]",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"path": "[concat('/home/', parameters('moodleCommon').sshUsername, '/.ssh/authorized_keys')]",
"keyData": "[parameters('moodleCommon').sshPublicKey]"
}
]
}
}
},
"storageProfile": {
"imageReference": "[parameters('moodleCommon').osType]",
"osDisk": {
"caching": "ReadOnly",
"createOption": "FromImage",
"managedDisk": {
"storageAccountType": "Standard_LRS"
}
}
}
}
},
"sku": {
"capacity": 2,
"name": "[parameters('moodleCommon').autoscaleVmSku]",
"tier": "Standard"
},
"tags": {
"displayName": "webfarm"
},
"type": "Microsoft.Compute/virtualMachineScaleSets"
},
{
"apiVersion": "2015-04-01",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachineScaleSets/', parameters('moodleCommon').vmssName)]"
],
"location": "[resourceGroup().location]",
"name": "autoscalewad",
"properties": {
"enabled": true,
"name": "autoscalewad",
"profiles": [
{
"capacity": {
"default": "2",
"maximum": "[parameters('moodleCommon').autoscaleVmCount]",
"minimum": "2"
},
"name": "Profile1",
"rules": [
{
"metricTrigger": {
"metricName": "\\Processor\\PercentProcessorTime",
"metricNamespace": "",
"metricResourceUri": "[variables('vmssID')]",
"operator": "GreaterThan",
"statistic": "Average",
"threshold": 80,
"timeAggregation": "Average",
"timeGrain": "PT1M",
"timeWindow": "PT5M"
},
"scaleAction": {
"cooldown": "PT1M",
"direction": "Increase",
"type": "ChangeCount",
"value": "1"
}
},
{
"metricTrigger": {
"metricName": "\\Processor\\PercentProcessorTime",
"metricNamespace": "",
"metricResourceUri": "[variables('vmssID')]",
"operator": "LessThan",
"statistic": "Average",
"threshold": 50,
"timeAggregation": "Average",
"timeGrain": "PT1M",
"timeWindow": "PT5M"
},
"scaleAction": {
"cooldown": "PT5M",
"direction": "Decrease",
"type": "ChangeCount",
"value": "1"
}
}
]
}
],
"targetResourceUri": "[variables('vmssID')]"
},
"type": "Microsoft.Insights/autoscaleSettings"
}
],
"variables": {
"cmdExec": "[concat('bash ',parameters('moodleCommon').moodleSetupScriptFilename,' ',parameters('moodleCommon').gfsNameRoot,'0', ' ','data', ' ', parameters('moodleCommon').siteURL, ' ', concat('jumpbox-vm-',parameters('moodleCommon').resourcesPrefix))]",
"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)]",
"extProbeID": "[concat(variables('extLbID'),'/probes/',parameters('moodleCommon').extProbe )]",
"pipID": "[resourceId('Microsoft.Network/publicIPAddresses',parameters('moodleCommon').lbPipName)]",
"scriptUri": "[concat(parameters('moodleCommon').ScriptLocation,parameters('moodleCommon').moodleSetupScriptFilename)]",
"storageApiVersion": "2015-06-15",
"subnetWebRef": "[concat(resourceId('Microsoft.Network/virtualNetworks',parameters('moodleCommon').vnetName),'/subnets/',parameters('moodleCommon').subnetWeb)]",
"vmssID": "[resourceId('Microsoft.Compute/virtualMachineScaleSets',parameters('moodleCommon').vmssName)]",
"wadCfgxEnd": "[concat('\"><MetricAggregation scheduledTransferPeriod=\"PT1H\"/><MetricAggregation scheduledTransferPeriod=\"PT1M\"/></Metrics></DiagnosticMonitorConfiguration></WadCfg>')]",
"wadCfgxStart": "[concat(variables('wadLogs'),variables('wadPerfCounter'),'<Metrics resourceId=\"')]",
"wadLogs": "<WadCfg><DiagnosticMonitorConfiguration>",
"wadPerfCounter": "<PerformanceCounters scheduledTransferPeriod=\"PT1M\"><PerformanceCounterConfiguration counterSpecifier=\"\\Processor\\PercentProcessorTime\" sampleRate=\"PT15S\" unit=\"Percent\"><annotation displayName=\"CPU percentage guest OS\" locale=\"en-us\"/></PerformanceCounterConfiguration></PerformanceCounters>",
"webvmss1NIC": "[concat('Microsoft.Compute/virtualMachineScaleSets/', parameters('moodleCommon').vmssName, '/virtualMachines/0/networkInterfaces/vmssnic')]"
},
"outputs": {
"webvm1IP": {
"value": "[reference(variables('webvmss1NIC'), '2017-03-30').ipConfigurations[0].properties.privateIPAddress]",
"type": "string"
}
}
}

Просмотреть файл

@ -0,0 +1,18 @@
{
"$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": [],
"variables": {
"documentation1": "This sub-template intentionally blank - a blank template allows for an optional exectuion strategy",
"documentation2": "",
"documentation3": "You should look for a template of the same name, but with a 1 instead of a 0 (at the end)"
}
}

Просмотреть файл

@ -0,0 +1,40 @@
{
"$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": [
{
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"name": "[concat(parameters('moodleCommon').vmssName,'/','setup_moodle')]",
"properties": {
"autoUpgradeMinorVersion": true,
"publisher": "Microsoft.OSTCExtensions",
"settings": {
"commandToExecute": "[variables('cmdExec')]",
"fileUris": [
"[variables('scriptUri')]"
]
},
"type": "CustomScriptForLinux",
"typeHandlerVersion": "1.4"
},
"tags": {
"displayName": "setup_moodle"
},
"type": "Microsoft.Compute/virtualMachines/extensions"
}
],
"variables": {
"cmdExec": "[concat('bash ',parameters('moodleCommon').moodleSetupScriptFilename,' ',parameters('moodleCommon').gfsNameRoot,'0', ' ','data', ' ', parameters('moodleCommon').siteURL, ' ', concat('jumpbox-vm-',parameters('moodleCommon').resourcesPrefix))]",
"scriptUri": "[concat(parameters('moodleCommon').ScriptLocation,parameters('moodleCommon').moodleSetupScriptFilename)]"
}
}

144
scripts/install_elastic.sh Normal file
Просмотреть файл

@ -0,0 +1,144 @@
# Custom Script for Linux
#!/bin/bash
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
esClusterName=$1
elasticvm1ip=$2
elasticvm2ip=$3
elasticvm3ip=$4
echo $esClusterName >> /tmp/vars.txt
echo $elasticvm1ip >> /tmp/vars.txt
echo $elasticvm2ip >> /tmp/vars.txt
echo $elasticvm3ip >> /tmp/vars.txt
{
# make sure the system does automatic update
sudo apt-get -y update
sudo apt-get -y install unattended-upgrades
# configure elastic search repository & install elastic search
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list
sudo apt-get -y update
sudo apt-get -y install elasticsearch=5.5.0
# install the required packages
sudo apt-get install -y openjdk-8-jre openjdk-8-jdk default-jre default-jdk
# Configure elasticsearch
cat <<EOF > /etc/elasticsearch/elasticsearch.yml
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: ${esClusterName}
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: \${HOSTNAME}
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: [_eth0_, _local_]
#
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.zen.ping.unicast.hosts: ["$elasticvm1ip", "$elasticvm2ip", "$elasticvm3ip"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
discovery.zen.minimum_master_nodes: 3
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
EOF
service elasticsearch restart
} > /tmp/setup.log

Просмотреть файл

@ -1,6 +1,6 @@
#!/bin/bash
# This script built for Ubuntu Server 14.04 LTS
# This script built for Ubuntu Server 16.04 LTS
# You can customize variables such as MOUNTPOINT, RAIDCHUNKSIZE and so on to your needs.
# You can also customize it to work with other Linux flavours and versions.
# If you customize it, copy it to either Azure blob storage or Github so that Azure
@ -34,6 +34,10 @@ RAIDPARTITION="/dev/md1p1"
# An set of disks to ignore from partitioning and formatting
BLACKLIST="/dev/sda|/dev/sdb"
# make sure the system does automatic update
sudo apt-get -y update
sudo apt-get -y install unattended-upgrades
{
check_os() {
grep ubuntu /proc/version > /dev/null 2>&1
@ -276,4 +280,4 @@ BLACKLIST="/dev/sda|/dev/sdb"
configure_disks
configure_gluster
} > /tmp/gluster-setup.log
} > /tmp/gluster-setup.log

Просмотреть файл

@ -1,176 +0,0 @@
#!/bin/bash
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
#
# Install MariaDB Galera Cluster, by Julio Sene & Paulo Teixeira
# modified by Kevin Bergman
#
#
# Script location: https://raw.githubusercontent.com/pateixei/MoodleAzure/master/scripts/
NODEINDEX=${1}
NODECOUNT=${2}
NODELIST=${3}
mySqlUserPassword=${4}
DEBPASSWORD=${5:-`date +%D%A%B | md5sum| sha256sum | base64| fold -w16| head -n1`}
CNAME=${6:-"GaleraCluster"}
echo $NODEINDEX >> /tmp/vars.txt
echo $NODECOUNT >> /tmp/vars.txt
echo $NODELIST >> /tmp/vars.txt
echo $mySqlUserPassword >> /tmp/vars.txt
echo $DEBPASSWORD >> /tmp/vars.txt
echo $CNAME >> /tmp/vars.txt
{
apt-get update > /dev/null
apt-get install -f -y > /dev/null
apt-get install lsb-release bc > /dev/null
REL=`lsb_release -sc`
DISTRO=`lsb_release -is | tr [:upper:] [:lower:]`
apt-get install -y --fix-missing python-software-properties > /dev/null
apt-get install software-properties-common
if [ "$REL" = "trusty" ];
then
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://mirror.edatel.net.co/mariadb/repo/10.1/ubuntu trusty main'
else
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb http://mirror.edatel.net.co/mariadb/repo/10.1/ubuntu xenial main'
fi
apt-get update > /dev/null
echo "Installing MariaDB Custer for $NODEINDX of $NODECOUNT on $DISTRO $REL ..."
DEBIAN_FRONTEND=noninteractive apt-get install -y rsync mariadb-server
echo "Configuring MariaDB Cluster"
# Remplace Debian maintenance config file
echo -e '# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = '$DEBPASSWORD '
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = '$DEBPASSWORD '
socket = /var/run/mysqld/mysqld.sock
basedir = /usr' > ~/debian.cnf
mv ~/debian.cnf /etc/mysql/
mysql -u root <<EOF
CREATE DATABASE moodle;
GRANT ALL PRIVILEGES ON moodle.* TO 'moodledba'@'%'
IDENTIFIED BY '$mySqlUserPassword';
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES on *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '$DEBPASSWORD' WITH GRANT OPTION;
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('$mySqlUserPassword');
CREATE USER 'root'@'%' IDENTIFIED BY '$mySqlUserPassword';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EOF
# To create another MariaDB root user:
#CREATE USER '$MYSQLUSER'@'localhost' IDENTIFIED BY '$MYSQLUSERPASS';
#GRANT ALL PRIVILEGES ON *.* TO '$MYSQLUSER'@'localhost' WITH GRANT OPTION;
#CREATE USER '$MYSQLUSER'@'%' IDENTIFIED BY '$MYSQLUSERPASS';
#GRANT ALL PRIVILEGES ON *.* TO '$MYSQLUSER'@'%' WITH GRANT OPTION;
service mysql stop
# adjust my.cnf
# sed -i "s/#wsrep_on=ON/wsrep_on=ON/g" /etc/mysql/my.cnf
# create Galera config file
#wget https://raw.githubusercontent.com/pateixei/azure-nginx-php-mariadb-cluster/master/files/cluster.cnf > /dev/null
echo -e '[mysqld]
#mysql settings
#wsrep_on=ON
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
innodb_large_prefix=ON
innodb_file_format="Barracuda"
query_cache_size=0
query_cache_type=0
bind-address=0.0.0.0
#galera settings
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_name="CLUSTERNAME"
wsrep_cluster_address="gcomm://IPLIST"
wsrep_sst_method=rsync
# Galera Node Configuration
wsrep_node_address="MYIP"
wsrep_node_name="MYNAME"' > ~/cluster.cnf
echo "test123"
if [ "$NODEINDEX" = 0 ];
then
sed -i "s/#wsrep_on=ON/wsrep_on=ON/g;s/IPLIST//g;s/MYIP/$MYIP/g;s/MYNAME/$MYNAME/g;s/CLUSTERNAME/$CNAME/g" ~/cluster.cnf
else
sed -i "s/#wsrep_on=ON/wsrep_on=ON/g;s/IPLIST/$NODELIST/g;s/MYIP/$MYIP/g;s/MYNAME/$MYNAME/g;s/CLUSTERNAME/$CNAME/g" ~/cluster.cnf
fi
mv ~/cluster.cnf /etc/mysql/conf.d/
# Create the raid disk
wget https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/shared_scripts/ubuntu/vm-disk-utils-0.1.sh
bash vm-disk-utils-0.1.sh -s
mkdir /datadisks/disk1/data
cp -R -p /var/lib/mysql /datadisks/disk1/data/
sed -i "s,/var/lib/mysql,/datadisks/disk1/data/mysql,g" /etc/mysql/my.cnf
echo "test456"
# Starts a cluster if is the first node
if [ "$NODEINDEX" = 0 ];
then
echo "testa"
service mysql start --wsrep-new-cluster > /dev/null
echo "testb"
sed -i "s;gcomm://;gcomm://$NODELIST;g" /etc/mysql/conf.d/cluster.cnf
else
echo "testc"
service mysql start > /dev/null
fi
echo "testd"
} > /tmp/maria-setup.log
echo "MariaDB Cluster instalation finished"

Просмотреть файл

@ -1,179 +0,0 @@
#!/bin/bash
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#parameters
{
moodleVersion=$1
glusterNode=$2
glusterVolume=$3
siteFQDN=$4
mariadbIP=$5
moodledbname=$6
moodledbuser=$7
moodledbpass=$8
adminpass=$9
echo $moodleVersion >> /tmp/vars.txt
echo $glusterNode >> /tmp/vars.txt
echo $glusterVolume >> /tmp/vars.txt
echo $siteFQDN >> /tmp/vars.txt
echo $mariadbIP >> /tmp/vars.txt
echo $moodledbname >> /tmp/vars.txt
echo $moodledbuser >> /tmp/vars.txt
echo $moodledbpass >> /tmp/vars.txt
echo $adminpass >> /tmp/vars.txt
# create gluster mount point
mkdir -p /moodle
#configure gluster repository & install gluster client
sudo add-apt-repository ppa:gluster/glusterfs-3.8 -y >> /tmp/apt1.log
sudo apt-get -y update >> /tmp/apt2.log
sudo apt-get -y --force-yes install glusterfs-client mysql-client git >> /tmp/apt3.log
# mount gluster files system
echo -e '\n\rInstalling GlusterFS on '$glusterNode':/'$glusterVolume '/moodle\n\r'
sudo mount -t glusterfs $glusterNode:/$glusterVolume /moodle
#create html directory for storing moodle files
sudo mkdir -p /moodle/html
# create directory for apache ssl certs
sudo mkdir -p /moodle/certs
# create moodledata directory
sudo mkdir -p /moodle/moodledata
# configuring PHP 5.6 repository (NEW LINES TO ADD BEFORE THE <20>Install Lamp Stack<63> BELLOW)
sudo add-apt-repository -y ppa:ondrej/php >> /tmp/apt4.log
sudo apt-get -y update >> /tmp/apt4.log
# install pre-requisites
sudo apt-get install -y --fix-missing python-software-properties unzip
# install the LAMP stack
sudo apt-get -y --force-yes install apache2 >> /tmp/apt5a.log
sudo apt-get -y --force-yes install php5.6 php5.6-cli php5.6-curl php5.6-zip >> /tmp/apt5b.log
# install moodle requirements
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://mirror.edatel.net.co/mariadb/repo/10.1/ubuntu trusty main'
sudo apt-get -y update > /dev/null
sudo apt-get install -y --force-yes mariadb-client
sudo apt-get install -y --force-yes graphviz aspell php5.6-common php5.6-soap php5.6-json php5.6-zip > /tmp/apt6.log
sudo apt-get install -y --force-yes php5.6-bcmath php5.6-gd php5.6-mysql php5.6-xmlrpc php5.6-intl php5.6-xml php5.6-bz2 >> /tmp/apt6.log
sudo apt-get install -y --force-yes php5.6-redis php5.6-curl php5.6-mysql >> /tmp/apt6.log
# install Moodle
echo '#!/bin/bash
cd /tmp
# downloading moodle
curl -k --max-redirs 10 https://github.com/moodle/moodle/archive/'$moodleVersion'.zip -L -o moodle.zip
unzip -q moodle.zip
echo -e \n\rMoving moodle files to Gluster\n\r
mv -v moodle-'$moodleVersion' /moodle/html/moodle
# install Office 365 plugins
#if [ "$installOfficePlugins" = "True" ]; then
curl -k --max-redirs 10 https://github.com/Microsoft/o365-moodle/archive/'$moodleVersion'.zip -L -o o365.zip
unzip -q o365.zip
cp -r o365-moodle-'$moodleVersion'/* /moodle/html/moodle
rm -rf o365-moodle-'$moodleVersion'
#fi
' > /tmp/setup-moodle.sh
sudo chmod +x /tmp/setup-moodle.sh
sudo /tmp/setup-moodle.sh >> /tmp/apt7.log
# create cron entry
# It is scheduled for once per day. It can be changed as needed.
echo '0 0 * * * php /moodle/html/moodle/admin/cli/cron.php > /dev/null 2>&1' > cronjob
sudo crontab cronjob
# update Apache configuration
sudo cp /etc/apache2/apache2.conf apache2.conf.bak
sudo sed -i 's/\/var\/www/\/\moodle/g' /etc/apache2/apache2.conf
sudo echo ServerName \"localhost\" >> /etc/apache2/apache2.conf
#enable ssl
a2enmod rewrite ssl
echo -e "Generating SSL self-signed certificate"
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /moodle/certs/apache.key -out /moodle/certs/apache.crt -subj "/C=BR/ST=SP/L=SaoPaulo/O=IT/CN=$siteFQDN"
echo -e "\n\rUpdating PHP and site configuration\n\r"
#update virtual site configuration
echo -e '
<VirtualHost *:80>
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /moodle/html/moodle
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
<VirtualHost *:443>
DocumentRoot /moodle/html/moodle
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /moodle/certs/apache.crt
SSLCertificateKeyFile /moodle/certs/apache.key
BrowserMatch "MSIE [2-6]" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>' > /etc/apache2/sites-enabled/000-default.conf
# php config
PhpIni=/etc/php5/apache2/php.ini
sed -i "s/memory_limit.*/memory_limit = 512M/" $PhpIni
sed -i "s/;opcache.use_cwd.*/opcache.use_cwd = 1/" $PhpIni
sed -i "s/;opcache.validate_timestamps.*/opcache.validate_timestamps = 1/" $PhpIni
sed -i "s/;opcache.save_comments.*/opcache.save_comments = 1/" $PhpIni
sed -i "s/;opcache.enable_file_override.*/opcache.enable_file_override = 0/" $PhpIni
sed -i "s/;opcache.enable.*/opcache.enable = 1/" $PhpIni
sed -i "s/;opcache.memory_consumption.*/opcache.memory_consumption = 256/" $PhpIni
sed -i "s/;opcache.max_accelerated_files.*/opcache.max_accelerated_files = 8000/" $PhpIni
sudo chown -R www-data /moodle/html/moodle
sudo chown -R www-data /moodle/certs
sudo chown -R www-data /moodle/moodledata
sudo chmod -R 770 /moodle/html/moodle
sudo chmod -R 770 /moodle/certs
sudo chmod -R 770 /moodle/moodledata
# restart Apache
echo -e "\n\rRestarting Apache2 httpd server\n\r"
sudo service apache2 restart
echo -e "sudo -u www-data /usr/bin/php /moodle/html/moodle/admin/cli/install.php --chmod=770 --lang=pt_br --wwwroot=https://"$siteFQDN" --dataroot=/moodle/moodledata --dbhost="$mariadbIP" --dbname="$moodledbname" --dbuser="$moodledbuser" --dbpass="$moodledbpass" --dbtype=mariadb --fullname='Moodle LMS' --shortname='Moodle' --adminuser=admin --adminpass="$adminpass" --adminemail=admin@"$siteFQDN" --non-interactive --agree-license --allow-unstable || true "
sudo -u www-data /usr/bin/php /moodle/html/moodle/admin/cli/install.php --chmod=770 --lang=en_us --wwwroot=https://$siteFQDN --dataroot=/moodle/moodledata --dbhost=$mariadbIP --dbname=$moodledbname --dbuser=$moodledbuser --dbpass=$moodledbpass --dbtype=mariadb --fullname='Moodle LMS' --shortname='Moodle' --adminuser=admin --adminpass=$adminpass --adminemail=admin@$siteFQDN --non-interactive --agree-license --allow-unstable || true
echo -e "\n\rDone! Installation completed!\n\r"
} > /tmp/install.log

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -24,98 +24,486 @@
glusterNode=$1
glusterVolume=$2
siteFQDN=$3
syslogserver=$4
echo $glusterNode >> /tmp/vars.txt
echo $glusterVolume >> /tmp/vars.txt
echo $siteFQDN >> /tmp/vars.txt
{
# make sure the system does automatic update
sudo apt-get -y update
sudo apt-get -y install unattended-upgrades
# install pre-requisites
sudo apt-get -y install python-software-properties
# install pre-requisites
sudo apt-get -y install python-software-properties unzip rsyslog
#configure gluster repository & install gluster client
sudo add-apt-repository ppa:gluster/glusterfs-3.8 -y >> /tmp/apt1.log
sudo apt-get -y update >> /tmp/apt2.log
sudo apt-get -y --force-yes install glusterfs-client mysql-client git >> /tmp/apt3.log
#configure gluster repository & install gluster client
sudo add-apt-repository ppa:gluster/glusterfs-3.8 -y
sudo apt-get -y update
sudo apt-get -y install glusterfs-client postgresql-client mysql-client git
# configuring PHP 5.6 repository (NEW LINES TO ADD BEFORE THE <20>Install Lamp Stack<63> BELLOW)
sudo add-apt-repository -y ppa:ondrej/php >> /tmp/apt4.log
sudo apt-get -y update >> /tmp/apt4.log
# install the base stack
sudo apt-get -y install nginx php-fpm varnish php php-cli php-curl php-zip
# install the LAMP stack
sudo apt-get -y --force-yes install apache2 >> /tmp/apt5a.log
sudo apt-get -y --force-yes install php5.6 php5.6-cli >> /tmp/apt5b.log
# Moodle requirements
sudo apt-get install -y graphviz aspell php-soap php-json php-redis php-bcmath php-gd php-pgsql php-mysql php-xmlrpc php-intl php-xml php-bz2
# install moodle requirements, force-yes
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://mirror.edatel.net.co/mariadb/repo/10.1/ubuntu trusty main'
sudo apt-get -y update > /dev/null
# Mount gluster fs for /moodle
sudo mkdir -p /moodle
sudo chown www-data /moodle
sudo chmod 770 /moodle
sudo echo -e 'mount -t glusterfs '$glusterNode':/'$glusterVolume' /moodle'
sudo mount -t glusterfs $glusterNode:/$glusterVolume /moodle
sudo echo -e $glusterNode':/'$glusterVolume' /moodle glusterfs defaults,_netdev,log-level=WARNING,log-file=/var/log/gluster.log 0 0' >> /etc/fstab
sudo mount -a
sudo apt-get install -y --force-yes mariadb-client
sudo apt-get install -y --force-yes graphviz aspell php5.6-common php5.6-soap php5.6-json php5.6-zip php5.6-bcmath >/tmp/apt6.log
sudo apt-get install -y --force-yes php5.6-gd php5.6-mysql php5.6-xmlrpc php5.6-intl php5.6-xml php5.6-bz2 >> /tmp/apt6.log
sudo apt-get install -y --force-yes php5.6-redis php5.6-curl php5.6-mbstring php5.6-mysql >> /tmp/apt6.log
# Configure syslog to forward
cat <<EOF >> /etc/rsyslog.conf
\$ModLoad imudp
\$UDPServerRun 514
EOF
cat <<EOF >> /etc/rsyslog.d/40-remote.conf
local1.* @${syslogserver}:514
local2.* @${syslogserver}:514
EOF
service syslog restart
# create gluster mount point
sudo mkdir -p /moodle
# Build nginx config
cat <<EOF > /etc/nginx/nginx.conf
user www-data;
worker_processes 2;
pid /run/nginx.pid;
# make the moodle directory writable for owner
sudo chown www-data /moodle
sudo chmod 770 /moodle
events {
worker_connections 2048;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
client_max_body_size 0;
proxy_max_temp_file_size 0;
server_names_hash_bucket_size 128;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
proxy_buffering off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
map \$http_x_forwarded_proto \$fastcgi_https {
default \$https;
http '';
https on;
}
log_format moodle_combined '\$remote_addr - \$upstream_http_x_moodleuser [\$time_local] '
'"\$request" \$status \$body_bytes_sent '
'"\$http_referer" "\$http_user_agent"';
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
EOF
cat <<EOF >> /etc/nginx/sites-enabled/${siteFQDN}.conf
server {
listen 81 default;
server_name ${siteFQDN};
root /moodle/html/moodle;
index index.php index.html index.htm;
# Log to syslog
error_log syslog:server=localhost,facility=local1,severity=error,tag=moodle;
access_log syslog:server=localhost,facility=local1,severity=notice,tag=moodle moodle_combined;
# Log XFF IP instead of varnish
set_real_ip_from 10.0.0.0/8;
set_real_ip_from 127.0.0.1;
set_real_ip_from 172.16.0.0/12;
set_real_ip_from 192.168.0.0/16;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
# Redirect to https
if (\$http_x_forwarded_proto != https) {
return 301 https://\$server_name\$request_uri;
}
rewrite ^/(.*\.php)(/)(.*)$ /\$1?file=/\$3 last;
# Filter out php-fpm status page
location ~ ^/server-status {
return 404;
}
location / {
try_files \$uri \$uri/index.php?\$query_string;
}
# mount gluster files system
sudo echo -e 'mount -t glusterfs '$glusterNode':/'$glusterVolume' /moodle' > /tmp/mount.log
#sudo mount -t glusterfs $glusterNode:/$glusterVolume /moodle
sudo echo -e $glusterNode':/'$glusterVolume' /moodle glusterfs defaults,_netdev,log-level=WARNING,log-file=/var/log/gluster.log 0 0' >> /etc/fstab
sudo mount -a
# updapte Apache configuration
sudo cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak
sudo sed -i 's/\/var\/www/\/\moodle/g' /etc/apache2/apache2.conf
sudo echo ServerName \"localhost\" >> /etc/apache2/apache2.conf
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f \$document_root\$fastcgi_script_name) {
return 404;
}
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_read_timeout 3600;
fastcgi_index index.php;
include fastcgi_params;
}
}
#enable ssl
sudo a2enmod rewrite ssl
server {
listen 443 ssl;
root /moodle/html/moodle;
index index.php index.html index.htm;
#update virtual site configuration
echo -e '
<VirtualHost *:80>
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /moodle/html/moodle
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
<VirtualHost *:443>
DocumentRoot /moodle/html/moodle
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ssl on;
ssl_certificate /moodle/certs/nginx.crt;
ssl_certificate_key /moodle/certs/nginx.key;
SSLEngine on
SSLCertificateFile /moodle/certs/apache.crt
SSLCertificateKeyFile /moodle/certs/apache.key
# Log to syslog
error_log syslog:server=localhost,facility=local1,severity=error,tag=moodle;
access_log syslog:server=localhost,facility=local1,severity=notice,tag=moodle moodle_combined;
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
# Log XFF IP instead of varnish
set_real_ip_from 10.0.0.0/8;
set_real_ip_from 127.0.0.1;
set_real_ip_from 172.16.0.0/12;
set_real_ip_from 192.168.0.0/16;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
</VirtualHost>' > /etc/apache2/sites-enabled/000-default.conf
location / {
proxy_set_header Host \$host;
proxy_set_header HTTP_REFERER \$http_referer;
proxy_set_header X-Forwarded-Host \$host;
proxy_set_header X-Forwarded-Server \$host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_pass http://localhost:80;
}
}
EOF
# php config
PhpIni=/etc/php5/apache2/php.ini
sed -i "s/memory_limit.*/memory_limit = 512M/" $PhpIni
sed -i "s/;opcache.use_cwd.*/opcache.use_cwd = 1/" $PhpIni
sed -i "s/;opcache.validate_timestamps.*/opcache.validate_timestamps = 1/" $PhpIni
sed -i "s/;opcache.save_comments.*/opcache.save_comments = 1/" $PhpIni
sed -i "s/;opcache.enable_file_override.*/opcache.enable_file_override = 0/" $PhpIni
sed -i "s/;opcache.enable.*/opcache.enable = 1/" $PhpIni
sed -i "s/;opcache.memory_consumption.*/opcache.memory_consumption = 256/" $PhpIni
sed -i "s/;opcache.max_accelerated_files.*/opcache.max_accelerated_files = 8000/" $PhpIni
# php config
PhpIni=/etc/php/7.0/fpm/php.ini
sed -i "s/memory_limit.*/memory_limit = 512M/" $PhpIni
sed -i "s/max_execution_time.*/max_execution_time = 18000/" $PhpIni
sed -i "s/max_input_vars.*/max_input_vars = 100000/" $PhpIni
sed -i "s/max_input_time.*/max_input_time = 600/" $PhpIni
sed -i "s/upload_max_filesize.*/upload_max_filesize = 1024M/" $PhpIni
sed -i "s/post_max_size.*/post_max_size = 1056M/" $PhpIni
sed -i "s/;opcache.use_cwd.*/opcache.use_cwd = 1/" $PhpIni
sed -i "s/;opcache.validate_timestamps.*/opcache.validate_timestamps = 1/" $PhpIni
sed -i "s/;opcache.save_comments.*/opcache.save_comments = 1/" $PhpIni
sed -i "s/;opcache.enable_file_override.*/opcache.enable_file_override = 0/" $PhpIni
sed -i "s/;opcache.enable.*/opcache.enable = 1/" $PhpIni
sed -i "s/;opcache.memory_consumption.*/opcache.memory_consumption = 256/" $PhpIni
sed -i "s/;opcache.max_accelerated_files.*/opcache.max_accelerated_files = 8000/" $PhpIni
# Remove the default site. Moodle is the only site we want
rm -f /etc/nginx/sites-enabled/default
# restart Apache
sudo service apache2 restart
# restart Nginx
sudo service nginx restart
} > /tmp/setup.log
# fpm config - overload this
cat <<EOF > /etc/php/7.0/fpm/pool.d/www.conf
[www]
user = www-data
group = www-data
listen = /run/php/php7.0-fpm.sock
listen.owner = www-data
listen.group = www-data
pm = dynamic
pm.max_children = 3000
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 30
EOF
# Restart fpm
service php7.0-fpm restart
# Configure varnish startup for 16.04
VARNISHSTART="ExecStart=\/usr\/sbin\/varnishd -j unix,user=vcache -F -a :80 -T localhost:6082 -f \/etc\/varnish\/moodle.vcl -S \/etc\/varnish\/secret -s malloc,1024m -p thread_pool_min=200 -p thread_pool_max=4000 -p thread_pool_add_delay=2 -p timeout_linger=100 -p timeout_idle=30 -p send_timeout=1800 -p thread_pools=4 -p http_max_hdr=512 -p workspace_backend=512k"
sed -i "s/^ExecStart.*/${VARNISHSTART}/" /lib/systemd/system/varnish.service
# Configure varnish VCL for moodle
cat <<EOF >> /etc/varnish/moodle.vcl
vcl 4.0;
import std;
import directors;
backend default {
.host = "localhost";
.port = "81";
.first_byte_timeout = 3600s;
.connect_timeout = 600s;
.between_bytes_timeout = 600s;
}
sub vcl_recv {
# Varnish does not support SPDY or HTTP/2.0 untill we upgrade to Varnish 5.0
if (req.method == "PRI") {
return (synth(405));
}
if (req.restarts == 0) {
if (req.http.X-Forwarded-For) {
set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
} else {
set req.http.X-Forwarded-For = client.ip;
}
}
# Non-RFC2616 or CONNECT HTTP requests methods filtered. Pipe requests directly to backend
if (req.method != "GET" &&
req.method != "HEAD" &&
req.method != "PUT" &&
req.method != "POST" &&
req.method != "TRACE" &&
req.method != "OPTIONS" &&
req.method != "DELETE") {
return (pipe);
}
# Varnish don't mess with healthchecks
if (req.url ~ "^/admin/tool/heartbeat" || req.url ~ "^/healthcheck.php")
{
return (pass);
}
# Pipe requests to backup.php straight to backend - prevents problem with progress bar long polling 503 problem
# This is here because backup.php is POSTing to itself - Filter before !GET&&!HEAD
if (req.url ~ "^/backup/backup.php")
{
return (pipe);
}
# Varnish only deals with GET and HEAD by default. If request method is not GET or HEAD, pass request to backend
if (req.method != "GET" && req.method != "HEAD") {
return (pass);
}
### Rules for Moodle and Totara sites ###
# Moodle doesn't require Cookie to serve following assets. Remove Cookie header from request, so it will be looked up.
if ( req.url ~ "^/altlogin/.+/.+\.(png|jpg|jpeg|gif|css|js|webp)$" ||
req.url ~ "^/pix/.+\.(png|jpg|jpeg|gif)$" ||
req.url ~ "^/theme/font.php" ||
req.url ~ "^/theme/image.php" ||
req.url ~ "^/theme/javascript.php" ||
req.url ~ "^/theme/jquery.php" ||
req.url ~ "^/theme/styles.php" ||
req.url ~ "^/theme/yui" ||
req.url ~ "^/lib/javascript.php/-1/" ||
req.url ~ "^/lib/requirejs.php/-1/"
)
{
set req.http.X-Long-TTL = "86400";
unset req.http.Cookie;
return(hash);
}
# Perform lookup for selected assets that we know are static but Moodle still needs a Cookie
if( req.url ~ "^/theme/.+\.(png|jpg|jpeg|gif|css|js|webp)" ||
req.url ~ "^/lib/.+\.(png|jpg|jpeg|gif|css|js|webp)" ||
req.url ~ "^/pluginfile.php/[0-9]+/course/overviewfiles/.+\.(?i)(png|jpg)$"
)
{
# Set internal temporary header, based on which we will do things in vcl_backend_response
set req.http.X-Long-TTL = "86400";
return (hash);
}
# Serve requests to SCORM checknet.txt from varnish. Have to remove get parameters. Response body always contains "1"
if ( req.url ~ "^/lib/yui/build/moodle-core-checknet/assets/checknet.txt" )
{
set req.url = regsub(req.url, "(.*)\?.*", "\1");
unset req.http.Cookie; # Will go to hash anyway at the end of vcl_recv
set req.http.X-Long-TTL = "86400";
return(hash);
}
# Requests containing "Cookie" or "Authorization" headers will not be cached
if (req.http.Authorization || req.http.Cookie) {
return (pass);
}
# Almost everything in Moodle correctly serves Cache-Control headers, if
# needed, which varnish will honor, but there are some which don't. Rather
# than explicitly finding them all and listing them here we just fail safe
# and don't cache unknown urls that get this far.
return (pass);
}
sub vcl_backend_response {
# Happens after we have read the response headers from the backend.
#
# Here you clean the response headers, removing silly Set-Cookie headers
# and other mistakes your backend does.
# We know these assest are static, let's set TTL >0 and allow client caching
if ( beresp.http.Cache-Control && bereq.http.X-Long-TTL && beresp.ttl < std.duration(bereq.http.X-Long-TTL + "s", 1s) && !beresp.http.WWW-Authenticate )
{ # If max-age < defined in X-Long-TTL header
set beresp.http.X-Orig-Pragma = beresp.http.Pragma; unset beresp.http.Pragma;
set beresp.http.X-Orig-Cache-Control = beresp.http.Cache-Control;
set beresp.http.Cache-Control = "public, max-age="+bereq.http.X-Long-TTL+", no-transform";
set beresp.ttl = std.duration(bereq.http.X-Long-TTL + "s", 1s);
unset bereq.http.X-Long-TTL;
}
else if( !beresp.http.Cache-Control && bereq.http.X-Long-TTL && !beresp.http.WWW-Authenticate ) {
set beresp.http.X-Orig-Pragma = beresp.http.Pragma; unset beresp.http.Pragma;
set beresp.http.Cache-Control = "public, max-age="+bereq.http.X-Long-TTL+", no-transform";
set beresp.ttl = std.duration(bereq.http.X-Long-TTL + "s", 1s);
unset bereq.http.X-Long-TTL;
}
else { # Don't touch headers if max-age > defined in X-Long-TTL header
unset bereq.http.X-Long-TTL;
}
# Here we set X-Trace header, prepending it to X-Trace header received from backend. Useful for troubleshooting
if(beresp.http.x-trace && !beresp.was_304) {
set beresp.http.X-Trace = regsub(server.identity, "^([^.]+),?.*$", "\1")+"->"+regsub(beresp.backend.name, "^(.+)\((?:[0-9]{1,3}\.){3}([0-9]{1,3})\)","\1(\2)")+"->"+beresp.http.X-Trace;
}
else {
set beresp.http.X-Trace = regsub(server.identity, "^([^.]+),?.*$", "\1")+"->"+regsub(beresp.backend.name, "^(.+)\((?:[0-9]{1,3}\.){3}([0-9]{1,3})\)","\1(\2)");
}
# Gzip JS, CSS is done at the ngnix level doing it here dosen't respect the no buffer requsets
# if (beresp.http.content-type ~ "application/javascript.*" || beresp.http.content-type ~ "text") {
# set beresp.do_gzip = true;
#}
}
sub vcl_deliver {
# Revert back to original Cache-Control header before delivery to client
if (resp.http.X-Orig-Cache-Control)
{
set resp.http.Cache-Control = resp.http.X-Orig-Cache-Control;
unset resp.http.X-Orig-Cache-Control;
}
# Revert back to original Pragma header before delivery to client
if (resp.http.X-Orig-Pragma)
{
set resp.http.Pragma = resp.http.X-Orig-Pragma;
unset resp.http.X-Orig-Pragma;
}
# (Optional) X-Cache HTTP header will be added to responce, indicating whether object was retrieved from backend, or served from cache
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";
} else {
set resp.http.X-Cache = "MISS";
}
# Set X-AuthOK header when totara/varnsih authentication succeeded
if (req.http.X-AuthOK) {
set resp.http.X-AuthOK = req.http.X-AuthOK;
}
# If desired "Via: 1.1 Varnish-v4" response header can be removed from response
unset resp.http.Via;
unset resp.http.Server;
return(deliver);
}
sub vcl_backend_error {
# More comprehensive varnish error page. Display time, instance hostname, host header, url for easier troubleshooting.
set beresp.http.Content-Type = "text/html; charset=utf-8";
set beresp.http.Retry-After = "5";
synthetic( {"
<!DOCTYPE html>
<html>
<head>
<title>"} + beresp.status + " " + beresp.reason + {"</title>
</head>
<body>
<h1>Error "} + beresp.status + " " + beresp.reason + {"</h1>
<p>"} + beresp.reason + {"</p>
<h3>Guru Meditation:</h3>
<p>Time: "} + now + {"</p>
<p>Node: "} + server.hostname + {"</p>
<p>Host: "} + bereq.http.host + {"</p>
<p>URL: "} + bereq.url + {"</p>
<p>XID: "} + bereq.xid + {"</p>
<hr>
<p>Varnish cache server
</body>
</html>
"} );
return (deliver);
}
sub vcl_synth {
#Redirect using '301 - Permanent Redirect', permanent redirect
if (resp.status == 851) {
set resp.http.Location = req.http.x-redir;
set resp.http.X-Varnish-Redirect = true;
set resp.status = 301;
return (deliver);
}
#Redirect using '302 - Found', temporary redirect
if (resp.status == 852) {
set resp.http.Location = req.http.x-redir;
set resp.http.X-Varnish-Redirect = true;
set resp.status = 302;
return (deliver);
}
#Redirect using '307 - Temporary Redirect', !GET&&!HEAD requests, dont change method on redirected requests
if (resp.status == 857) {
set resp.http.Location = req.http.x-redir;
set resp.http.X-Varnish-Redirect = true;
set resp.status = 307;
return (deliver);
}
#Respond with 403 - Forbidden
if (resp.status == 863) {
set resp.http.X-Varnish-Error = true;
set resp.status = 403;
return (deliver);
}
}
EOF
# Restart Varnish
systemctl daemon-reload
service varnish restart
} > /tmp/setup.log