The final project in the class is to package your Mediawiki application using Terraform and Ansible. Your code will be deployed on an empty GCP project and after it runs a client will be able to access their new Wiki using an IP address. MediaWiki is the wiki engine behind Wikipedia. MediaWiki is capable of scaling to handle an effectively unlimited user load because of its modular design. MediaWiki uses and SQL based database separating the data and web layers. Despite its size and complexity, MediaWiki is fairly simple to setup.
You should be committing and pushing your code regularly. When you get something working –even a small thing– stop, commit and push it. That will give you a history of changes that is useful for when you want to restore something that was lost.
The basic application structure is shown in the diagram below.
In order to complete the project your application should have all of the parts that are shown in the diagram:
An instance that runs your web server and database
A persistent disk that holds the database files
A VPC with firewall rules for your instance
A cloud storage buckets that holds automated backups
The Google Cloud Monitoring agent installed on your instance
Students that are looking for an extra challenge should try to create two instances, one for the webserver and one for the database. The next sections describe the requirements in more detail.
The deployment is based on one or more instances. The instances should run any Linux you like but it’s easiest to stick with Debian 11. You can optionally implement the application with separate VMs for the webserver and database or you can keep them on a single instance. If you have both functions on the same instance you should tag the instance with two tags in Terraform:
tags = ["web", "db"]
If you elect to use two instances you should separate the tags.
The contents of the database should be located on a separate persistent disk. The format and mount points are shown below:
The default system disk for your distribution.
The system disk is just the default disk that comes with the distribution.
The deployment should create a Cloud Storage Bucket. Once a day the instance should make a
tar file from the contents of
/var/lib/mysql and copy it to the bucket. In order to conserve space the bucket should be set to keep files for six months from their creation. Files older than six months should be deleted automatically.
Use the shell script that you created for the Final Document milestone to perform the backups. Making that script executable in
/etc/cron.daily/backup will cause it to be run every day.
The application runs on a single VM. You need visibility into the VM so you can see if the VM is properly sized (not too big, not too small) and that there are no errors on the VM. Install the Cloud Logging agent so that the VM reports its logging data to the Logging tool.
Your application should be completely setup after running the following commands in the root of your Git repository:
$ terraform init $ terraform apply $ ansible-playbook -i ./gcp.yaml playbook.yaml
The Terraform step should create all of the GCP resources you’ll need:
VPC and Firewall
A storage bucket
An instance with some extras:
A persistent disk for the database
An attached service account for backups
The Ansible playbook should configure the instance by:
Formatting and mounting the data disk
Installing all necessary packages (including MediaWiki)
Configuring a default user for MariaDB
Configuring periodic backups
After running the playbook you should be able to navigate to the IP address of your instance and go to the MediaWiki installer.
There’s a lot of work to do. When you think you have the application working post your
playbook.yaml files to the class discussion board.