Final Milestone#

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.

Application Structure#

The basic application structure is shown in the diagram below.

Application overview

In order to complete the project your application should have all of the parts that are shown in the diagram:

  1. An instance that runs your web server and database

  2. A persistent disk that holds the database files

  3. A VPC with firewall rules for your instance

  4. A cloud storage buckets that holds automated backups

  5. 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.

Database Storage#

The contents of the database should be located on a separate persistent disk. The format and mount points are shown below:




Mount Point




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.


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.

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:

  1. VPC and Firewall

  2. A storage bucket

  3. An instance with some extras:

    1. A persistent disk for the database

    2. An attached service account for backups

The Ansible playbook should configure the instance by:

  1. Formatting and mounting the data disk

  2. Installing all necessary packages (including MediaWiki)

  3. Configuring a default user for MariaDB

  4. 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 and playbook.yaml files to the class discussion board.