Skip to content

Commit

Permalink
Release 1.0.3 (#21)
Browse files Browse the repository at this point in the history
* Added CloudFormation Parameters JSON Example. Updated content on README

* Added cloud-init, cloud-init-output and yum logs to CloudWatch Logging

* Removed draft backup script code. Going to use Data Pipeline solution to back EFS.

* Removed update-tag because created own repo with the script https://github.com/bonusbits/update_reference_git_tag

* Removed draft backup script code. Going to use Data Pipeline solution to back EFS.
  • Loading branch information
LevonBecker authored Mar 16, 2017
1 parent befd0e7 commit 694573c
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 88 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
##CHANGE LOG
---

##1.0.3 - 03/16/2017 - Levon Becker - [Issue 6](https://github.com/bonusbits/bonusbits_mediawiki_nginx/issues/6)
* Dropped backup script drafts. Going to Data Pipeline backup solution.

##1.0.2 - 03/12/2017 - Levon Becker - [Issue 5](https://github.com/bonusbits/bonusbits_mediawiki_nginx/issues/5) & [Issue 11](https://github.com/bonusbits/bonusbits_mediawiki_nginx/issues/11) & [Issue 17](https://github.com/bonusbits/bonusbits_mediawiki_nginx/issues/17)
* Dropped Sidebar Ads from 5 to 3 matching ad units plus small, medium then large progression. updated data bag sidebar php
* Fixed dns attribute overrides needed in environment file for test kitchen
Expand Down
74 changes: 51 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

# Purpose
Deploy an autoscaling group with EC2 Instances on Amazon Linux Running Mediawiki on Nginx. Using RDS backend and EFS for content sharing (uploads).
Optional an ALB can be applied. It's option because we may want to deploy behind an existing 3rd party cloud load balancer such as Sophos United Threat Management Instance/s.

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

# Prerequisites
* VPC with Public (If Using ALB) and Private subnets
* [Example Template](https://github.com/bonusbits/cloudformation_templates/blob/master/infrastructure/vpc.yml)
* Create RDS Instance
* [Example Template](https://github.com/bonusbits/cloudformation_templates/tree/master/database)
* Create empty Mediawiki Database and User
* Create Empty Mediawiki Database and User
* [Wiki Article](https://www.bonusbits.com/wiki/Reference:Secure_Mediawiki_Nginx_Configuration)
* EFS Mount Storage Created
* [Example Template](https://github.com/bonusbits/cloudformation_templates/blob/master/infrastructure/nat-gateway.yml)
Expand All @@ -23,38 +24,65 @@ Optional an ALB can be applied. It's option because we may want to deploy behind


# Launcher
Click this button to open AWS CloudFormation web console to enter parameters and create the stack.<br>
Click this button to open AWS CloudFormation web console with the Template URL automatically entered.<br>
[![](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?#/stacks/new?&templateURL=https://s3.amazonaws.com/bonusbits-public/cloudformation-templates/cookbooks/bonusbits-mediawiki-nginx.yml)


# CloudFormation Template Details
Public S3 Link:<br>
[https://s3.amazonaws.com/bonusbits-public/cloudformation-templates/cookbooks/bonusbits-mediawiki-nginx.yml](https://s3.amazonaws.com/bonusbits-public/cloudformation-templates/cookbooks/bonusbits-mediawiki-nginx.yml)

The [CloudFormation Template](https://github.com/bonusbits/bonusbits_mediawiki_nginx/blob/master/cloudformation/bonusbits-mediawiki-nginx.yml) the following:

1. Create Elastic Load Balancer v2 in public network (Optional)
1. HTTP Listener
2. HTTPS Listener
2. Autoscaling Group for Frontend Web Servers in private network
3. Adds the EC2 Instances to the appropriate security groups
4. Create own Security Group
5. Create IAM Instance Profile Role
4. Installs some basic packages needed for bootstrapping
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
5. Add DNS Update Script to Userdata (Optional)
6. Setup and Execute Chef Zero
1. Install Chef Client from internet
2. Create Chef Configuration Files
2. Download bonusbits_mediawiki_nginx cookbook from Github
3. Triggers Chef Zero run
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. Installs Latest Mediawiki
2. Add AWS API Access configurations
3. Starts Squid
4. Install and configure CloudWatch Logs Agent
5. Setup scripts and cron jobs to stream logs to CloudWatch Logs
1. Adjust Sudoers secure path to include */usr/local/bin*
2. Install Linux packages for Mediawiki, Nginx and PHP FPM
1. 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.
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!
6 changes: 0 additions & 6 deletions attributes/backups.rb

This file was deleted.

126 changes: 126 additions & 0 deletions cloudformation/example_parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
[
{
"ParameterKey": "Owner",
"ParameterValue": "First Last"
},
{
"ParameterKey": "DeleteAfter",
"ParameterValue": "Never"
},
{
"ParameterKey": "VPC",
"ParameterValue": "vpc-00000000"
},
{
"ParameterKey": "SubnetIdList",
"ParameterValue": "subnet-00000000,subnet-00000000,subnet-00000000"
},
{
"ParameterKey": "InternalAccessSecurityGroup",
"ParameterValue": "sg-00000000"
},
{
"ParameterKey": "RemoteSecurityGroup",
"ParameterValue": "sg-00000000"
},
{
"ParameterKey": "RdsSecurityGroup",
"ParameterValue": "sg-00000000"
},
{
"ParameterKey": "EfsSecurityGroup",
"ParameterValue": "sg-00000000"
},
{
"ParameterKey": "EfsFileSystemId",
"ParameterValue": "fs-00000000"
},
{
"ParameterKey": "KeyPairName",
"ParameterValue": "mykeypair"
},
{
"ParameterKey": "InstanceType",
"ParameterValue": "t2.small"
},
{
"ParameterKey": "MinAutoScaleCount",
"ParameterValue": "1"
},
{
"ParameterKey": "MaxAutoScaleCount",
"ParameterValue": "1"
},
{
"ParameterKey": "AlarmSnsTopicArn",
"ParameterValue": "arn:aws:sns:us-west-2:00000000:alerts"
},
{
"ParameterKey": "CookbookName",
"ParameterValue": "bonusbits_mediawiki_nginx"
},
{
"ParameterKey": "CookbookVersion",
"ParameterValue": "latest"
},
{
"ParameterKey": "ChefClientVersion",
"ParameterValue": "12.18.31"
},
{
"ParameterKey": "DataBagItem",
"ParameterValue": "bonusbits"
},
{
"ParameterKey": "DataBagSecret",
"ParameterValue": "CYEh1mnfH+TrzeVa8cyDAHWicV8hKni7P40xVPUn2Cm8638QvFS24iK7DRtP5VlDpogSaxDm050riKcAZ++rwUsJdUcQyx6KdXIMKEVml+ZjYW9BC3c4fMWPYbBkdWHBTpUP6OpMl9eNdPoa36vKRuxBrYGAKzLLDlTTqvoRlKEpAKpdSdgp3zZnGeymEeYYyG2Lv9p6ZbmlcDqRdB2hPu+grNkDWNrwDfV/UxF3QOtLQQB7c5edDHa1rmegNbP1Gb/h2Gu+HFf2sQnCFnjG20rxwJaL5lSdUs2AOdR+B+fDL+y7o6LxIN3n3EQWfdzzDsJXFjKhF0b+mAAmgJy9q2R1Sqr0f0X078icvu9zlUMjgJxSAShsXW00y9swcItQXFpJTFXnaswbd7YtJBsrNvfcOuSF9GhO6y1vCTbeOUMet+G6KbDIO0YxKF+fi07VPSTkAoXznC0t9o8s7Kqdd1pgx3xxVr80r9v3uKZcM+wMBk7TrpswKr6A4sIT0kBaJTgr37uDH8uIoiqEpxHfHEge6vVWfJyRaXjdyG7aJ3VwuJvSrIkuVJCam3ie2Dr09KBUWNYHXOmPb3eM0ByudcXNS0IXNAWqQJ5leNTINcqq4OZmAJHHOUo7qJhtqLVtr+Zwcady+WQ0ta1kmhQuWJ8RAhCCBUCUTISKEtXuF8E="
},
{
"ParameterKey": "MediawikiMajorRelease",
"ParameterValue": "1"
},
{
"ParameterKey": "MediawikiMinorRelease",
"ParameterValue": "28"
},
{
"ParameterKey": "SiteFolderName",
"ParameterValue": "mediawiki"
},
{
"ParameterKey": "UploadFolderName",
"ParameterValue": "uploads"
},
{
"ParameterKey": "RootSitePath",
"ParameterValue": "/var/www/html"
},
{
"ParameterKey": "NginxXforwardedTraffic",
"ParameterValue": "true"
},
{
"ParameterKey": "NginxRewriteWikiAlias",
"ParameterValue": "false"
},
{
"ParameterKey": "UpdateDNS",
"ParameterValue": "true"
},
{
"ParameterKey": "HostedZoneId",
"ParameterValue": "V2UYT8USYGG8F8"
},
{
"ParameterKey": "RecordName",
"ParameterValue": "www.example.com"
},
{
"ParameterKey": "SetupBackups",
"ParameterValue": "true"
},
{
"ParameterKey": "BackupInterval",
"ParameterValue": "daily"
}
]
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'MIT'
description 'Deploy Mediawiki on Amazon Linux running Nginx and Php-fpm'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '1.0.2'
version '1.0.3'
issues_url 'https://github.com/bonusbits/bonusbits_mediawiki_nginx/issues'
source_url 'https://github.com/bonusbits/bonusbits_mediawiki_nginx'

Expand Down
46 changes: 0 additions & 46 deletions pipeline/update-tag.sh

This file was deleted.

11 changes: 0 additions & 11 deletions recipes/backups.rb

This file was deleted.

1 change: 0 additions & 1 deletion templates/default/backups/backup-mediawiki.sh.erb

This file was deleted.

17 changes: 17 additions & 0 deletions templates/default/cloudwatch_logs/awslogs.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@
state_file = /var/lib/awslogs/agent-state
use_gzip_http_content_encoding = true

[cloud-init]
log_group_name = <%= node['bonusbits_mediawiki_nginx']['aws']['logs_group_name'] %>
log_stream_name = <%= node['ec2']['instance_id'] %>-cloud-init
datetime_format = %b %d %H:%M:%S
file = /var/log/cloud-init.log

[cloud-init-output]
log_group_name = <%= node['bonusbits_mediawiki_nginx']['aws']['logs_group_name'] %>
log_stream_name = <%= node['ec2']['instance_id'] %>-cloud-init-output
file = /var/log/cloud-init-output.log

[yum]
log_group_name = <%= node['bonusbits_mediawiki_nginx']['aws']['logs_group_name'] %>
log_stream_name = <%= node['ec2']['instance_id'] %>-yum
datetime_format = %b %d %H:%M:%S
file = /var/log/yum.log

[nginx-access]
log_group_name = <%= node['bonusbits_mediawiki_nginx']['aws']['logs_group_name'] %>
log_stream_name = <%= node['ec2']['instance_id'] %>-nginx-access
Expand Down

0 comments on commit 694573c

Please sign in to comment.