From db5a18622dc5235db2408859c6316616edff31cd Mon Sep 17 00:00:00 2001 From: Vincent Rioux Date: Tue, 23 Apr 2024 10:10:54 -0400 Subject: [PATCH 1/6] Update README.md with Moodle 4.4 links --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index dbc7c7a..d99ce7e 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ # Hosting Moodle™ on AWS -### Version 2.0.1 +### Version 2.0.2 ## Overview -This repository provides set of CloudFormation nested templates that deploy a highly available, elastic, and scalable [Moodle™ 4.3+](https://docs.moodle.org) environment on AWS. Moodle™ offers a learning platform that provides educators, administrators and learners a single robust, secure and integrated system for personalized learning environment. +This repository provides set of CloudFormation nested templates that deploy a highly available, elastic, and scalable [Moodle™ 4.4](https://docs.moodle.org) environment on AWS. Moodle™ offers a learning platform that provides educators, administrators and learners a single robust, secure and integrated system for personalized learning environment. -These nested templates can be used to deploy Moodle™ on AWS using [Amazon Virtual Private Cloud (Amazon VPC)](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Introduction.html), [Amazon Elastic Compute Cloud (Amazon EC2)](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts.html), [Auto Scaling](http://docs.aws.amazon.com/autoscaling/latest/userguide/WhatIsAutoScaling.html), [Elastic Load Balancing (Application Load Balancer)](http://docs.aws.amazon.com/elasticbalancing/latest/application/introduction.html), [Amazon Aurora](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/CHAP_AuroraOverview.html), [Amazon ElastiCache](http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/WhatIs.html), [Amazon Elastic File System (Amazon EFS)](http://docs.aws.amazon.com/efs/latest/ug/whatisefs.html), [Amazon CloudFront](http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Introduction.html), [Amazon Route 53](http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/Welcome.html), [Amazon Certificate Manager (Amazon ACM)](http://docs.aws.amazon.com/acm/latest/userguide/acm-overview.html) with [AWS CloudFormation](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html) in yaml format. +These nested templates can be used to deploy Moodle™ on AWS using [Amazon Virtual Private Cloud (Amazon VPC)](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Introduction.html), [Amazon Elastic Compute Cloud (Amazon EC2)](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts.html), [Auto Scaling](http://docs.aws.amazon.com/autoscaling/latest/userguide/WhatIsAutoScaling.html), [Elastic Load Balancing (Application Load Balancer)](http://docs.aws.amazon.com/elasticbalancing/latest/application/introduction.html), [Amazon Aurora](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/CHAP_AuroraOverview.html), [Amazon ElastiCache](http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/WhatIs.html), [Amazon Elastic File System (Amazon EFS)](http://docs.aws.amazon.com/efs/latest/ug/whatisefs.html), [Amazon CloudFront](http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Introduction.html), [Amazon Route 53](http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/Welcome.html), [Amazon Certificate Manager (Amazon ACM)](http://docs.aws.amazon.com/acm/latest/userguide/acm-overview.html) with [AWS CloudFormation](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html) in YAML format. This architecture is expansive enough to meet the needs of large institutions / organizations. Smaller organizations can choose to run a subset of the template to meet their needs. These templates can also be run individually and may be modified. -This template currently uses [Moodle™ 4.3+](https://download.moodle.org/download.php/stable403/moodle-latest-403.tgz) stable version downloaded directly from [download.moodle.org](https://download.moodle.org/releases/latest/). Details for downloading are available in the [templates/03-pipelinehelper.yaml](templates/03-pipelinehelper.yaml) template file. +This template currently uses [Moodle™ 4.4](https://download.moodle.org/download.php/stable404/moodle-4.4.tgz) stable version downloaded directly from [download.moodle.org](https://download.moodle.org/releases/latest/). Details for downloading are available in the [templates/03-pipelinehelper.yaml](templates/03-pipelinehelper.yaml) template file. ## Deployment guide @@ -94,7 +94,7 @@ With [elastic](https://docs.aws.amazon.com/efs/latest/ug/performance.html#elasti *Moodle™ recommends the `dirroot` be set as read only for the apache process in a clustered environment [[Reference]](https://docs.moodle.org/400/en/Server_cluster#.24CFG-.3Edirroot). You should not install plugins to a server cluster from the admin page. `Moodle™ recommends manually installing plugins on each server during planned maintenance`. To follow the infrastructure-as-code methodology, installation/upgrade of plugins can be managed using AWS CodePipeline scripts. See the `.pipeline` folder inside your AWS CodeCommit Moodle™ repository. ### AWS CodePipeline -This CloudFormation templates use AWS Services to create a CI/CD pipeline to help manage your Moodle™ environment. AWS CodeCommit will host a git repository for your Moodle™ environment. It initially pulls the source from [download.moodle.org.](https://download.moodle.org/download.php/stable403/moodle-4.0.3.tgz). It also adds files required to automate the deployment pipeline. You can explore these files under the `.pipeline` folder. +This CloudFormation templates use AWS Services to create a CI/CD pipeline to help manage your Moodle™ environment. AWS CodeCommit will host a git repository for your Moodle™ environment. It initially pulls the source from [download.moodle.org.](https://download.moodle.org/download.php/stable404/moodle-4.4.tgz). It also adds files required to automate the deployment pipeline. You can explore these files under the `.pipeline` folder. This template also creates an AWS CodePipeline configuration that build artifacts to deploy on EC2 with autoscaling groups using AWS CodeBuild and AWS CodeDeploy. It can optionally support a BLUE_GREEN deployment. *You can customize the overall pipeline for your Moodle™ setup.* From 3b91aff4ca6c2af3ca9adab8a3e89b8008dc9f87 Mon Sep 17 00:00:00 2001 From: Vincent Rioux Date: Tue, 23 Apr 2024 10:11:54 -0400 Subject: [PATCH 2/6] Update 03-pipelinehelper.yaml with Moodle 4.4 version --- templates/03-pipelinehelper.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/03-pipelinehelper.yaml b/templates/03-pipelinehelper.yaml index db376b8..5d41f07 100644 --- a/templates/03-pipelinehelper.yaml +++ b/templates/03-pipelinehelper.yaml @@ -533,7 +533,7 @@ Resources: mkdir /tmp/moodle/.pipeline # Get Latest Moodle stable version - wget -O /tmp/moodle.tgz https://download.moodle.org/download.php/direct/stable403/moodle-latest-403.tgz + wget -O /tmp/moodle.tgz https://download.moodle.org/download.php/stable404/moodle-4.4.tgz tar -xvzf /tmp/moodle.tgz --strip-components=1 -C /tmp/moodle/ wget -O /tmp/moodle/lib/aws.phar https://docs.aws.amazon.com/aws-sdk-php/v3/download/aws.phar cd /tmp/moodle From 74a576376fbedee82435ed7b9246e15769657309 Mon Sep 17 00:00:00 2001 From: Vincent Rioux Date: Tue, 23 Apr 2024 10:18:08 -0400 Subject: [PATCH 3/6] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d99ce7e..4cd2c74 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ You can launch this CloudFormation template in different AWS Regions. Below are | ap-southeast-1 |AP (Singapore)| [![cloudformation-launch-stack](images/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=ap-southeast-1#/stacks/new?stackName=Moodle&templateURL=https://s3.amazonaws.com/aws-refarch/moodle/al2023/templates/00-main.yaml) | | ap-southeast-2 |AP (Sydney)| [![cloudformation-launch-stack](images/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=ap-southeast-2#/stacks/new?stackName=Moodle&templateURL=https://s3.amazonaws.com/aws-refarch/moodle/al2023/templates/00-main.yaml) | | ap-south-1 |India (Mumbai)| [![cloudformation-launch-stack](images/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=ap-south-1#/stacks/new?stackName=Moodle&templateURL=https://s3.amazonaws.com/aws-refarch/moodle/al2023/templates/00-main.yaml) | -| ca-central-1 |Canada (Central))| [![cloudformation-launch-stack](images/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=ca-central-1#/stacks/new?stackName=Moodle&templateURL=https://s3.amazonaws.com/aws-refarch/moodle/al2023/templates/00-main.yaml) | +| ca-central-1 |Canada (Central)| [![cloudformation-launch-stack](images/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=ca-central-1#/stacks/new?stackName=Moodle&templateURL=https://s3.amazonaws.com/aws-refarch/moodle/al2023/templates/00-main.yaml) | ## Architecture From 861b642c3f58c37b6b9ae8dc221f46f67179e637 Mon Sep 17 00:00:00 2001 From: Vincent Rioux Date: Tue, 23 Apr 2024 16:23:30 -0400 Subject: [PATCH 4/6] Fix packages --- templates/04-web.yaml | 86 ++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/templates/04-web.yaml b/templates/04-web.yaml index 0005cc7..cbb7422 100644 --- a/templates/04-web.yaml +++ b/templates/04-web.yaml @@ -333,12 +333,43 @@ Resources: AWS::CloudFormation::Init: configSets: deploy_webserver: - - install_logs + - install_packages + - install_cloudwatchlogs - install_codedeploy - install_webserver - - start_webserver + - start_services - add_crontab - install_logs: + install_packages: + packages: + yum: + amazon-cloudwatch-agent: [] + ruby3.2: [] + httpd: [] + php8.1: [] + php8.1-gd: [] + php8.1-soap: [] + php8.1-intl: [] + php8.1-mbstring: [] + php8.1-xml: [] + php8.1-opcache: [] + php8.1-fpm: [] + php8.1-pgsql: [] + php8.1-mysqlnd: [] + cronie: [] + php8.1-devel: [] + php-pear: [] + libzip: [] + libzip-devel: [] + libsodium-devel: [] + libzstd-devel: [] + redis6-devel: [] + lz4-devel: [] + libmemcached-awesome-tools: [] + libmemcached-awesome-devel: [] + zlib-devel: [] + cyrus-sasl-devel: [] + libevent-devel: [] + install_cloudwatchlogs: files: /etc/awslogs/awslogs.conf: content: !Sub | @@ -393,35 +424,17 @@ Resources: owner: root group: root commands: - 01_create_state_directory: + create_state_directory: command: mkdir -p /var/awslogs/state - 02_install_cloudwatch_agent: - command: dnf install -y amazon-cloudwatch-agent - install_aws_ini: - commands: - install_aws_ini: - command: ./download_aws_ini.sh - cwd: /tmp - ignoreErrors: true install_codedeploy: files: - /tmp/install_codedeploy.sh: - content: - !Sub | - #!/bin/bash -xe - dnf install -y ruby - cd /home/ec2-user - wget https://aws-codedeploy-${AWS::Region}.s3.${AWS::Region}.amazonaws.com/latest/install - chmod +x ./install - ./install auto - mode: 000500 - owner: root - group: root + /home/ec2-user/install: + source: !Join ["", ["https://aws-codedeploy-", !Ref "AWS::Region", ".s3.", !Ref "AWS::Region", ".amazonaws.com/latest/install" ] ] + mode: "000755" commands: install_codedeploy: - command: ./install_codedeploy.sh - cwd: /tmp - ignoreErrors: false + command: "./install auto" + cwd: "/home/ec2-user/" install_webserver: files: /tmp/status.txt: @@ -433,20 +446,12 @@ Resources: /tmp/create_site_conf.sh: content: !Sub | #!/bin/bash -xe - dnf install -y php8.1 php-gd php-soap php-intl php-mbstring php-xml php-opcache php-fpm php-pgsql php-mysqlnd - - # Enable crontab on Amazon Linux 2023 - dnf install -y cronie - systemctl enable crond - systemctl start crond # Below to be able to compile zip.so for the PHP Zip library that's not in the available packages... - dnf install -y php8.1-devel php-pear libzip libzip-devel pecl install zip echo "extension=zip.so;" > /etc/php.d/50-zip.ini # Install Sodium - dnf install -y libsodium-devel pecl install -f libsodium echo "extension=sodium.so;" > /etc/php.d/50-sodium.ini @@ -457,12 +462,10 @@ Resources: echo 'extension=igbinary.so' > /etc/php.d/30-igbinary.ini /usr/bin/yes 'no' | pecl install msgpack echo 'extension=msgpack.so' > /etc/php.d/30-msgpack.ini - dnf install -q -y libzstd-devel /usr/bin/yes 'no' | pecl install zstd echo 'extension=zstd.so' > /etc/php.d/40-zstd.ini /usr/bin/yes 'no' | pecl install --configureoptions 'enable-lzf-better-compression="no"' lzf echo 'extension=lzf.so' > /etc/php.d/40-lzf.ini - dnf install -q -y redis6-devel lz4-devel /usr/bin/yes 'no' | pecl install --configureoptions 'enable-redis-igbinary="yes" enable-redis-lzf="yes" enable-redis-zstd="yes" enable-redis-msgpack="yes" enable-redis-lz4="yes" with-liblz4="yes"' redis echo 'extension=redis.so' > /etc/php.d/41-redis.ini @@ -509,8 +512,6 @@ Resources: #mv amazon-elasticache-cluster-client.so /usr/lib64/php/modules/ #echo 'extension=amazon-elasticache-cluster-client.so;' > /etc/php.d/50-elasticache.ini # Install Memcached client - note that ElastiCache client is failing on AL2023 - dnf install libmemcached libmemcached-devel -y -q - dnf install -y zlib-devel cyrus-sasl-devel libevent-devel /usr/bin/yes 'no' | pecl install --configureoptions 'enable-memcached-igbinary="yes" enable-memcached-msgpack="yes" enable-memcached-json="yes" enable-memcached-protocol="yes" enable-memcached-sasl="yes" enable-memcached-session="yes"' memcached echo 'extension=memcached.so' > /etc/php.d/41-memcached.ini @@ -550,13 +551,15 @@ Resources: create_site_conf: command: ./create_site_conf.sh cwd: /tmp - ignoreErrors: false - start_webserver: + start_services: services: sysvinit: httpd: enabled: true ensureRunning: true + crond: + enabled: true + ensureRunning: true add_crontab: files: /tmp/add_crontab.sh: @@ -570,7 +573,6 @@ Resources: add_crontab: command: ./add_crontab.sh cwd: /tmp - ignoreErrors: false Properties: LaunchTemplateData: BlockDeviceMappings: From 1bbf30498fac4265e5d1b30b1265fedac0023319 Mon Sep 17 00:00:00 2001 From: Vincent Rioux Date: Tue, 23 Apr 2024 16:23:49 -0400 Subject: [PATCH 5/6] Fix packages --- templates/03-pipelinehelper.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/03-pipelinehelper.yaml b/templates/03-pipelinehelper.yaml index 5d41f07..226decd 100644 --- a/templates/03-pipelinehelper.yaml +++ b/templates/03-pipelinehelper.yaml @@ -144,6 +144,10 @@ Parameters: Default: 2 Description: Specifies the minimum number of EC2 instances in the Web Autoscaling Group. Type: String + MoodleDirectDownloadURL: + Default: "https://download.moodle.org/download.php/direct/stable404/moodle-4.4.tgz" + Description: Specifies the TGZ Moodle direct download URL + Type: String Conditions: NumberOfSubnets1: @@ -533,7 +537,7 @@ Resources: mkdir /tmp/moodle/.pipeline # Get Latest Moodle stable version - wget -O /tmp/moodle.tgz https://download.moodle.org/download.php/stable404/moodle-4.4.tgz + wget -O /tmp/moodle.tgz ${MoodleDirectDownloadURL} tar -xvzf /tmp/moodle.tgz --strip-components=1 -C /tmp/moodle/ wget -O /tmp/moodle/lib/aws.phar https://docs.aws.amazon.com/aws-sdk-php/v3/download/aws.phar cd /tmp/moodle From 528d80b31694f582a78f90d03cb7a475a60dd58b Mon Sep 17 00:00:00 2001 From: Vincent Rioux Date: Tue, 23 Apr 2024 16:24:20 -0400 Subject: [PATCH 6/6] Add Moodle download URL as parameter --- templates/00-main.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/templates/00-main.yaml b/templates/00-main.yaml index 7b85f8a..e432b7e 100644 --- a/templates/00-main.yaml +++ b/templates/00-main.yaml @@ -660,6 +660,10 @@ Parameters: Description: Email address for notification Type: String Default: hello@yourdomain.com + MoodleDirectDownloadURL: + Default: "https://download.moodle.org/download.php/direct/stable404/moodle-4.4.tgz" + Description: Specifies the TGZ Moodle direct download URL + Type: String Conditions: DeployWithoutSessionCache: @@ -947,6 +951,8 @@ Resources: !Ref WebAsgMax WebAsgMin: !Ref WebAsgMin + MoodleDirectDownloadURL: + !Ref MoodleDirectDownloadURL TemplateURL: !Sub '${DeploymentLocation}/03-pipelinehelper.yaml' sessioncache: