8000 installer by dominis · Pull Request #4 · dominis/mikado · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ terraform.tfplan
.vagrant
terraform/wpexample.com.tf
terraform-error-1480468042.log
.mikado
mikado.conf
mikado.conf.dev
__pycache__
*.pyc
.DS_Store
20 changes: 12 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
.ONESHELL:
.PHONY: build-ami deploy-ami plan apply destroy graph clean

-include env.mk
-include bootstrap_tmp.mk
-include .mikado.conf.mk
-include .aws_data.mk

.mikado.conf.mk:
@cat mikado.conf | sed 's/"//g ; s/=/:=/' > .mikado.conf.mk

.aws_data.mk:
@bash ./scripts/aws_data.sh | sed 's/"//g ; s/=/:=/' > .aws_data.mk

update:
@terraform get ./terraform

bootstrap_tmp.mk:
@bash bootstrap.sh > bootstrap_tmp.mk

build-ami:
@packer build packer/wp.json 2>&1 | tee .packer-out.log
@$(MAKE) clean

deploy-ami:
@bash deploy_ami.sh
@bash ./scripts/deploy_ami.sh
@$(MAKE) clean

# This target executes the terraform plan stage
# This will not change anything in you AWS setup only displays the changes
Expand Down Expand Up @@ -53,4 +56,5 @@ destroy: update
clean:
@rm -rf ./.tmp
@rm -rf ./.terraform
@rm -rf ./bootstrap_tmp.mk
@rm -f ./.mikado.conf.mk
@rm -f ./.aws_data.mk
50 changes: 14 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

Mikado helps managing your AWS infrastructure for Wordpress sites by defining an out-of-box, highly available, easy-to-deploy setup.

Our goals are:
The project goals are:
- Provide an oversimplified but flexible and resilient one-click Wordpress deployment
- Create a widely used standardized Wordpress infrastructure
- Implement performance, security and infrastructure best practices out of box
- Implement performance, security and infrastructure best practices
- Have automated, auditable, and idempotent configuration


Expand All @@ -34,46 +34,24 @@ Mikado provides a fully automated way to deploy and maintain your infrastructure

## Quick start

### Building your base AWS infra

Mikado provides a Vagrant instance for local development with all the dependencies installed.

Get the latest version of mikado:
```
git clone http://github.com/dominis/mikado
cd mikado
curl -s https://raw.githubusercontent.com/dominis/mikado/master/scripts/mikado-boom | sh
```

Start the vagrant instance, for this you need to [install vagrant](https://www.vagrantup.com/docs/installation/) first:
```
vagrant up
vagrant ssh
cd mikado
```
### Building your base AWS infra

You need to create your env file for your credentials:
```
cp env.mk.template env.mk
vim env.mk
```
Mikado provides a Vagrant instance for local development with all the dependencies installed.

Once you done you can run terraform to build the base infrastructure:
```
make apply
```
This will create a VPC in the selected region with public and private subnets in all available Availability Zones. This is needed for the next step.
Also a dialog based installer provided.

At this point you will be able to create the image for your application servers. This step will start a new EC2 instance in one of your subnets and will provision it by using Ansible. If the process is successful an [AMI](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html) will be created. This will be the base for your servers in the Auto Scaling Groups.
```
make build-ami
make deploy-ami
```
![installer](https://cloud.githubusercontent.com/assets/157738/20834138/cb8d69cc-b893-11e6-9abc-d3d48dc32b43.png)
![installer](https://cloud.githubusercontent.com/assets/157738/20834140/cb906384-b893-11e6-860f-4742cd1668bc.png)
![installer](https://cloud.githubusercontent.com/assets/157738/20834141/cb908008-b893-11e6-95e5-4a936874845e.png)
![installer](https://cloud.githubusercontent.com/assets/157738/20834137/cb8c66a8-b893-11e6-9cba-df01e8eaac01.png)
![installer](https://cloud.githubusercontent.com/assets/157738/20834139/cb8de0a0-b893-11e6-995f-3bd7e0b60b16.png)
![installer](https://cloud.githubusercontent.com/assets/157738/20834136/cb8c2940-b893-11e6-97f8-289e902a68ee.png)
![installer](https://cloud.githubusercontent.com/assets/157738/20837059/9b65aa3e-b8a2-11e6-892a-82a0e8083ab3.png)

If you make it this far you can configure your Wordpress setup. Check out the [examples](https://github.com/dominis/mikado/tree/master/examples).
```
cp examples/basic-no-fastly.tf terraform/wpexample.com.tf
make apply
```

### Deploying your website

Expand Down Expand Up @@ -103,7 +81,7 @@ Take a look at the [example repository](https://github.com/dominis/wordpress.exa

- Q: The following error is thrown during `vagrant up`:
_The box 'bento/centos-7.1' could not be found or could not be accessed in the remote catalog. If this is a private box on HashiCorp's Atlas, please verify you're logged in via `vagrant login`. Also, please double-check the name. The expanded URL and error message are shown below:_ (sic!)
- A: On version 1.8.7 the embedded curl Vagrant uses had a [bug](https://github.com/mitchellh/vagrant/issues/7969).
- A: On version 1.8.7 the embedded curl Vagrant uses had a [bug](https://github.com/mitchellh/vagrant/issues/7969).
Workaround for v1.8.7: `sudo rm -rf /opt/vagrant/embedded/bin/curl`
Or, update Vagrant to v1.8.8

Expand Down
20 changes: 19 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,19 @@ VAGRANTFILE_API_VERSION = "2"

$script = <<SCRIPT
yum -y install epel-release
yum install jq make unzip ntpdate openssl-devel gcc python-devel python-pip -y
yum install -y \
dialog \
python34-devel \
jq \
make \
unzip \
ntpdate \
openssl-devel \
gcc \
python-devel \
python-pip \

# Install terraform and packer
cd /usr/src
wget --quiet https://releases.hashicorp.com/terraform/0.7.13/terraform_0.7.13_linux_amd64.zip
wget --quiet https://releases.hashicorp.com/packer/0.12.0/packer_0.12.0_linux_amd64.zip
Expand All @@ -15,9 +26,16 @@ unzip packer_0.12.0_linux_amd64.zip
mv terraform /usr/bin/
mv packer /usr/bin/

# python2 stuff
pip install -U pip
pip install urllib3[secure]
pip install awscli

# python3 stuff
curl https://bootstrap.pypa.io/get-pip.py | python3.4
pip3 install pythondialog
pip3 install pyyaml

SCRIPT

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
Expand Down
6 changes: 3 additions & 3 deletions examples/basic-with-fastly-statuscake.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module "wp" {
source = "./wp"
domain = "wpexample.com"
domain = "###DOMAIN###"
public_subnets = "${module.vpc.public_subnets}"
private_subnets = "${module.vpc.private_subnets}"
internal_sg = "${module.sg.internal_sg_id}"
Expand All @@ -12,15 +12,15 @@ module "wp" {

module "wp-fastly" {
source = "./wp-fastly"
domain = "wpexample.com"
domain = "###DOMAIN###"
domain_zone_id = "${module.wp.route53_zone_id}"
api_key = "${var.fastly_api_key}"
elb_public_sg_id = "${module.wp.prod-elb_public_sg_id}"
}

module "wp-statuscake" {
source = "./wp-statuscake"
domain = "wpexample.com"
domain = "###DOMAIN###"
username = "${var.statuscake_username}"
apikey = "${var.statuscake_apikey}"
}
19 changes: 19 additions & 0 deletions examples/basic-with-fastly.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module "wp" {
source = "./wp"
domain = "###DOMAIN###"
public_subnets = "${module.vpc.public_subnets}"
private_subnets = "${module.vpc.private_subnets}"
internal_sg = "${module.sg.internal_sg_id}"
availability_zones = "${module.vpc.availability_zones}"
vpc_id = "${module.vpc.vpc_id}"
db_pass = "superPass34234"
no_cdn = false
}

module "wp-fastly" {
source = "./wp-fastly"
domain = "###DOMAIN###"
domain_zone_id = "${module.wp.route53_zone_id}"
api_key = "${var.fastly_api_key}"
elb_public_sg_id = "${module.wp.prod-elb_public_sg_id}"
}
18 changes: 18 additions & 0 deletions examples/basic-with-statuscake.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module "wp" {
source = "./wp"
domain = "###DOMAIN###"
public_subnets = "${module.vpc.public_subnets}"
private_subnets = "${module.vpc.private_subnets}"
internal_sg = "${module.sg.internal_sg_id}"
availability_zones = "${module.vpc.availability_zones}"
vpc_id = "${module.vpc.vpc_id}"
db_pass = "superPass34234"
no_cdn = false
}

module "wp-statuscake" {
source = "./wp-statuscake"
domain = "###DOMAIN###"
username = "${var.statuscake_username}"
apikey = "${var.statuscake_apikey}"
}
2 changes: 1 addition & 1 deletion examples/basic-no-fastly.tf → examples/basic.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module "wp" {
source = "./wp"
domain = "wpexample.com"
domain = "###DOMAIN###"
public_subnets = "${module.vpc.public_subnets}"
private_subnets = "${module.vpc.private_subnets}"
internal_sg = "${module.sg.internal_sg_id}"
Expand Down
38 changes: 16 additions & 22 deletions env.mk.template → mikado.conf.example
Original file line number Diff line number Diff line change
@@ -1,58 +1,52 @@
##########################################
# Here you can set up your env variables
#
# This a Makefile: https://www.gnu.org/software/make/manual/html_node/Variables_002fRecursion.html
##########################################

######################
# Mandatory variables
######################
export AWS_ACCESS_KEY_ID:=
export AWS_SECRET_ACCESS_KEY:=
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=

# your site's domain: example.com
export domain:=wpexample.com
export domain=wpexample.com

# the aws region you want to deploy http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-regions.html#examples
export TF_VAR_region:=us-east-1
export TF_VAR_region=us-east-1

# Comma separated list of trusted CIDR blocks (the computer's ip you want to use to connect to the servers) for the security goups
export TF_VAR_allowed_cidrs=0.0.0.0/0

# Your rsa public key
export rsa_public_key:=
export rsa_public_key=

# more info at https://github.com/dominis/mikado#deploying-your-website
export site_repo:=https://github.com/dominis/wordpress.example.com.git
export site_repo=https://github.com/dominis/wordpress.example.com.git

# Instance type used for AMI builds
# NB you can choose a big instance for faster
# builds but aws bills the entire hour
# even if your instance only run for a few minutes
export build_instance_type:=t2.micro
export build_instance_type=t2.micro

###########################################
# The following variables are all optional
###########################################
# https://manage.fastly.com/account
export TF_VAR_fastly_api_key:=
export TF_VAR_fastly_api_key=

# https://app.statuscake.com/APIKey.php
export TF_VAR_statuscake_username:=
export TF_VAR_statuscake_apikey:=
export TF_VAR_statuscake_username=
export TF_VAR_statuscake_apikey=

# https://app.datadoghq.com/account/settings#integrations/amazon_web_services
export TF_VAR_datadog_external_id:=
export TF_VAR_datadog_external_id=

# https://app.datadoghq.com/account/settings#api
export datadog_api_key:=
export datadog_api_key=

# https://ACCOUNT.loggly.com/tokens
export loggly_token:=
export loggly_token=

# https://rpm.newrelic.com/accounts/
export newrelic_license_key:=
export newrelic_license_key=

# https://YOURACCOUNT.slack.com/apps/A0F7XDUAZ-incoming-webhooks
export slack_webhook_url:=
export slack_channel:=#mikado-notifications
export slack_webhook_url=
export slack_channel=#mikado-notifications
12 changes: 7 additions & 5 deletions bootstrap.sh → scripts/aws_data.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
set -e

source ./mikado.conf

# we need to query aws api for the available azs in the region and feed it to tf
az_count=$( \
aws ec2 describe-availability-zones \
Expand Down Expand Up @@ -54,8 +56,8 @@ efs_filesysyem_id=$( \
)

# print out the result in makefile format
echo "export source_ami:=${source_ami}"
echo "export vpc_id:=${vpc_id}"
echo "export subnet_id:=${subnet_id}"
echo "export efs_filesysyem_id:=${efs_filesysyem_id}"
echo "export TF_VAR_az_count:=${az_count}"
echo "export source_ami=${source_ami}"
echo "export vpc_id=${vpc_id}"
echo "export subnet_id=${subnet_id}"
echo "export efs_filesysyem_id=${efs_filesysyem_id}"
echo "export TF_VAR_az_count=${az_count}"
2 changes: 2 additions & 0 deletions deploy_ami.sh → scripts/deploy_ami.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
set -e

source ./mikado.conf

if [ -z "$TF_VAR_region" ]; then
echo "Please run make deploy-ami instead."
exit 1
Expand Down
Loading
0