Skip to content

Chef Cookbook + CloudFormation Template - Stand up autoscaling group with EC2 Instances on Amazon Linux Running Mediawiki on Nginx. Using RDS backend and EFS for content sharing (uploads).

License

Notifications You must be signed in to change notification settings

bonusbits/bonusbits_chef_mediawiki

Repository files navigation

Bonusbits Mediawiki on Nginx in AWS Chef Cookbook and CloudFormation Template

CircleCI Join the chat at https://gitter.im/bonusbits/bonusbits_mediawiki

Purpose

Deploy an autoscaling group with EC2 Instances on Amazon Linux Running Mediawiki on Nginx. Using RDS backend and EFS for content sharing (uploads).

No ELB/ALB configured, because we deploy behind an existing Sophos load balancer.

Prerequisites

Launcher

Click this button to open AWS CloudFormation web console with the Template URL automatically entered.

CloudFormation Template

Public S3 Link:
https://s3.amazonaws.com/bonusbits-public/cloudformation-templates/cookbooks/bonusbits-mediawiki-nginx.yml

The CloudFormation Template the following:

  1. Create Autoscale Group for Frontend Web Server in private network for HA not Scaling (Currently)
  2. Adds the EC2 Instance to the appropriate security groups
  3. Create own Security Group
  4. Create IAM Instance Profile Role
  5. Create Cloudwatch CPU Alarm for Autoscale Group
  6. UserData Installs some basic packages needed for bootstrapping
    1. cfn-init
    2. aws-cfn-bootstrap
    3. cloud-init
    4. git
  7. Cloud Init (cfn-init)
    1. Configure CFN Hup and Auto Reloader Hook Conf
    2. Setup and Execute Chef Zero
      1. Install Chef Client from internet
      2. Create Chef Configuration Files
      3. Download bonusbits_mediawiki_nginx cookbook from Github
      4. Triggers Chef Zero run
    3. Run DNS Update Script (Optional)
    4. Warm EBS Volume

Cookbook

  1. Adjust Sudoers secure path to include /usr/local/bin
  2. Install Linux packages for Mediawiki, Nginx and PHP FPM
  3. Configure Nginx
  4. Configure PHP FPM
  5. Install specific version of Mediawiki and list of extensions
  6. Create LocalSettings.php
  7. Configure Extensions
  8. Mount and Configure fstab for EFS share
  9. Install and configure CloudWatch Logs Agent
  10. Setup EFS share backup to encrypted/versioned S3 bucket
  11. Create node info script
  12. Create Route53 DNS Upset script

Tips

  1. If needed the instance size can be increased.
  2. Optionally you could add an ELB and scale past one, but I designed it to be an affordable easy solution.

Disclaimer

All of the example values are randomly generated and not real or used by Bonus Bits. Such as, data bag secret, HostedZoneId, etc. Other times it's more obvious that example values are fake such as vpc-0000000. We just added random values to a few specific parameters and attributes to give a better idea of what should be entered.

The point is, don't think we put any real secrets in the repo.

Also, this is a highly customized Mediawiki implementation for our needs and may be outside the scope of what you would like to implement. The main purpose is to share code ideas that you can use for your own project. Use are your own cost and risk. Don't rely on us to maintain the projects for your needs. Fork away and enjoy the help to success!

We'll maintain this project for our needs and we hope it helps others on similar implementations!