Final Milestone#
The final project in the class is to package your Mediawiki application using Terraform and Ansible. Your code will be deployed in a 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.
Application Structure#
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
An instance that runs your database
A persistent disk that holds the database files
A VPC with firewall rules for your instances
A cloud storage buckets that holds automated backups
The Google Cloud Monitoring agent installed on your instance
The next sections describe the requirements in more detail.
Compute#
The deployment is based on two or more instances. The instances should run any Linux you like but it’s easiest to stick with Debian. You should implement the application with separate VMs for the webserver and database you should not keep them on the same instance. Be sure to tag your instances in Terraform:
# MediaWiki instance
tags = ["web"]
# MariaDB instance
tags = ["db"]
Database Storage#
The contents of the database should be located on a separate persistent disk. The format and mount points are shown below:
Disk |
Filesystem |
Capacity |
Mount Point |
Notes |
|---|---|---|---|---|
|
|
10 Gib |
|
The default system disk for your distribution. |
|
|
10 Gib |
|
MariaDB data |
The system disk is just the default disk that comes with the distribution.
Backups#
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.
Logging#
The application runs on multiple VMs. You need visibility into the VMs so you can see if the VMs are properly sized (not too big, not too small) and that there are no errors. Install the Cloud Logging agent so that the VM reports its logging data to the Logging tool.
Application Process#
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
Instances with some extras:
A persistent disk for the database
An attached service account for backups
The Ansible playbook should configure the instance by:
On
webinstances:Installing MediaWiki
On the
dbinstance:Formatting and mounting the data disk
Installing and configuring 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.
Turn In#
There’s a lot of work to do. When you think you have the application working post your a link to your GitHub repository to the class message board.