This repository has been archived by the owner on Oct 31, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
explain manual steps for setting up the environment #75
Open
afeld
wants to merge
6
commits into
master
Choose a base branch
from
manual-setup
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
496cec1
separate AMI building and full deployment into their own jobs
afeld 958a70b
combine validation jobs in CircleCI so they run faster and using the …
afeld 5cfcee0
validate Ansible playbook in CircleCI
afeld a55c9e1
move validation commands into a Makefile
afeld d2b5d34
add Make target for building the AMI
afeld 8da5d00
add instructions on manual environment setup
afeld File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
DB_HOST = $(shell cd terraform/env && terraform output db_host) | ||
DB_NAME = $(shell cd terraform/env && terraform output db_name) | ||
DB_USER = $(shell cd terraform/env && terraform output db_user) | ||
|
||
ami: roles | ||
cd terraform/env && \ | ||
packer build \ | ||
-var db_host=$(DB_HOST) \ | ||
-var db_name=$(DB_NAME) \ | ||
-var db_user=$(DB_USER) \ | ||
-var "db_pass=${TF_VAR_db_pass}" \ | ||
../../packer/wordpress.json | ||
|
||
validate: roles | ||
cd ansible && ansible-playbook --syntax-check -i "localhost," -c local wordpress.yml | ||
packer validate -syntax-only packer/wordpress.json | ||
cd terraform/bootstrap && terraform validate | ||
cd terraform/mgmt && terraform validate | ||
cd terraform/env && terraform validate | ||
|
||
roles: | ||
# this command fails if the requirements.yml is empty | ||
# cd ansible && ansible-galaxy install -p roles -r requirements.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,8 +32,9 @@ Currently, both the management and environment VPCs will be deployed in the same | |
1. Install Ansible dependencies. | ||
|
||
```sh | ||
ansible-galaxy install -p ansible/roles -r ansible/requirements.yml | ||
make roles | ||
``` | ||
|
||
1. Specify a region ([options](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions)). | ||
|
||
```sh | ||
|
@@ -76,27 +77,61 @@ Currently, both the management and environment VPCs will be deployed in the same | |
### Application environment | ||
|
||
1. [Create an access key for the deployer user.](https://console.aws.amazon.com/iam/home#/users/circleci-deployer?section=security_credentials) | ||
1. Set up CircleCI for the project. | ||
* [Specify environment variables](https://circleci.com/docs/2.0/env-vars/#adding-environment-variables-in-the-app): | ||
* [The required AWS configuration](https://www.terraform.io/docs/providers/aws/index.html#environment-variables) | ||
* `TF_ENV_BUCKET` - get via `terraform output env_backend_bucket` | ||
* `TF_VAR_db_pass` | ||
* `TF_VAR_general_availability_endpoint` | ||
* Generate a deployer key, and add it under the project settings. | ||
1. Follow either the CircleCI or manual steps below. | ||
1. Visit the site, which is the `url` output from Terraform, to complete WordPress setup. | ||
|
||
```sh | ||
ssh-keygen -t rsa -b 4096 -f id_rsa_circleci -C "[email protected]" -N "" | ||
cat id_rsa_circleci | pbcopy | ||
Note that if the public IP address changes after you set up the site initially, you will need to [change the site URL](https://codex.wordpress.org/Changing_The_Site_URL#Changing_the_Site_URL) in WordPress. | ||
|
||
# save as private key in CircleCI | ||
#### CircleCI | ||
|
||
rm id_rsa_circleci* | ||
``` | ||
To set up CircleCI for the project: | ||
|
||
* The build will bootstrap the environment. | ||
1. Visit the site, which is the `url` output from Terraform at the end of the CircleCI run, to complete WordPress setup. | ||
* [Specify environment variables](https://circleci.com/docs/2.0/env-vars/#adding-environment-variables-in-the-app): | ||
* [The required AWS configuration](https://www.terraform.io/docs/providers/aws/index.html#environment-variables) | ||
* `TF_ENV_BUCKET` - get via `terraform output env_backend_bucket` | ||
* `TF_VAR_db_pass` | ||
* `TF_VAR_general_availability_endpoint` | ||
* Generate a deployer key, and add it under the project settings. | ||
|
||
Note that if the public IP address changes after you set up the site initially, you will need to [change the site URL](https://codex.wordpress.org/Changing_The_Site_URL#Changing_the_Site_URL) in WordPress. | ||
```sh | ||
ssh-keygen -t rsa -b 4096 -f id_rsa_circleci -C "[email protected]" -N "" | ||
cat id_rsa_circleci | pbcopy | ||
|
||
# save as private key in CircleCI | ||
|
||
rm id_rsa_circleci* | ||
``` | ||
|
||
* The build will bootstrap the environment. | ||
|
||
#### Manual | ||
|
||
To set up / deploy Terraform's environment configuration on your local machine: | ||
|
||
1. Set up Terraform. | ||
|
||
```sh | ||
cd ../env | ||
terraform init "-backend-config=bucket=$(cd ../mgmt && terraform output env_backend_bucket)" | ||
``` | ||
|
||
1. Bootstrap the environment. | ||
|
||
```sh | ||
terraform apply -target=aws_route53_record.db | ||
``` | ||
|
||
1. Create the AMI, making sure to pass your database password. | ||
|
||
```sh | ||
TF_VAR_db_pass=<db_pass> make ami | ||
``` | ||
|
||
1. Deploy the rest of the environment. | ||
|
||
```sh | ||
terraform apply | ||
``` | ||
|
||
#### Troubleshooting | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the Makefile is in the root devsecops-example directory, this step should be:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also considered
make ami -f ../../Makefile
but that failed sincemake
expects to be run in the root dir and it tries to cd intoterraform/env
.