Skip to content

Commit

Permalink
AWS public wercker multiple deploy.
Browse files Browse the repository at this point in the history
  • Loading branch information
enxebre committed Jun 11, 2015
1 parent 68e2da1 commit 1f3c1d4
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bootstrap/aws-public/config-default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export ATLAS_INFRASTRUCTURE=${ATLAS_INFRASTRUCTURE:-capgemini/apollo}
export TF_VAR_access_key=${TF_VAR_access_key:?"Need to set TF_VAR_access_key non-empty"}
export TF_VAR_secret_key=${TF_VAR_secret_key:?"Need to set TF_VAR_secret_key non-empty"}
export TF_VAR_key_file=${TF_VAR_key_file:-$HOME/.ssh/apollo_aws_rsa}
export TF_VAR_key_name=${TF_VAR_key_name:-apollo}
export TF_VAR_key_name=${TF_VAR_key_name:-deployer}

# Terraform mappings needs to be statically passed as -var parameters
# so no really needed to export them. Exporting for consitency.
Expand Down
1 change: 0 additions & 1 deletion bootstrap/aws-public/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ ansible_ssh_config() {
ControlPath ~/.ssh/mux-%r@%h:%p
ControlPersist 30m
User ubuntu
IdentityFile $TF_VAR_key_file
UserKnownHostsFile /dev/null
EOF
popd
Expand Down
66 changes: 66 additions & 0 deletions docs/getting-started-guides/aws-public.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
## Getting started on AWS

### Prerequisites

1. You need an AWS account. Visit [http://aws.amazon.com](http://aws.amazon.com) to get started
2. You need an AWS [instance profile and role](http://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html) with EC2 full access.
3. You need an Atlas account. Visit [https://atlas.hashicorp.com](https://atlas.hashicorp.com) to get started.
4. You need to have installed and configured Terraform (>= 0.5.0 recommended). Visit [https://www.terraform.io/intro/getting-started/install.html](https://www.terraform.io/intro/getting-started/install.html) to get started.
6. You need to have [Python](https://www.python.org/) >= 2.7.5 installed along with [pip](https://pip.pypa.io/en/latest/installing.html).
7. You will need to have created an SSH RSA key pair for accessing your aws intances. You can create it as follows:

```
cd ~/.ssh
ssh-keygen -P "" -t rsa -f id_rsa_aws -b 4096 -C "[email protected]"
openssl rsa -in ~/.ssh/id_rsa_aws -outform pem > id_rsa_tmp.pem
chmod 400 id_rsa_aws.pem
eval `ssh-agent -s`
ssh-add id_rsa_aws.pem
```

### Cluster Turnup

#### Download Apollo

##### Install from source at head
1. ```git clone https://github.com/Capgemini/apollo.git```
2. ```cd apollo```
3. ```pip install -r requirements.txt```

#### Set config

Configuration can be set via environment variables.

All variables following the pattern "TF_VAR_" will be available for Apollo in terraform, see [https://github.com/hashicorp/terraform/pull/1621#issuecomment-100825568](https://github.com/hashicorp/terraform/pull/1621#issuecomment-100825568)

All variables following pattern "APOLLO_" will be available for Apollo in ansible.

For a full list of default config options for AWS see ```bootstrap/aws-public/config-default.sh```

As a minimum you will need to set these environment variables -

```
APOLLO_PROVIDER=aws-public
TF_VAR_user
TF_VAR_access_key
TF_VAR_secret_key
TF_VAR_key_name="deployer"
TF_VAR_key_file='~/.ssh/id_rsa_aws.pub'
ATLAS_TOKEN
```

_NOTE: The value for ATLAS_TOKEN should be set to whatever you generated with your [Atlas Account](https://atlas.hashicorp.com/settings/tokens).

#### Turn up the cluster
```
sh bootstrap/apollo-launch.sh
```

NOTE: The script will provision a new VPC and a 3 node mesos master cluster in eu-west-1 (Ireland).

#### Tearing down the cluster
```
sh bootstrap/apollo-down.sh
```


3 changes: 1 addition & 2 deletions docs/getting-started-guides/aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ For a full list of default config options for AWS see ```bootstrap/aws/config-de
As a minimum you will need to set these environment variables -

```
APOLLO_PROVIDER=aws or APOLLO_PROVIDER=aws-public
APOLLO_PROVIDER=aws
TF_VAR_user
TF_VAR_access_key
TF_VAR_secret_key
Expand All @@ -48,7 +48,6 @@ sh bootstrap/apollo-launch.sh
```

NOTE: The script will provision a new VPC and a 3 node mesos master cluster in eu-west-1 (Ireland).
If you choose APOLLO_PROVIDER=aws-public:

It will also create a mesos slave cluster and a Bastion server for accessing the VPC via VPN and SSH.

Expand Down
7 changes: 6 additions & 1 deletion terraform/aws-public/mesos-masters.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
resource "aws_key_pair" "deployer" {
key_name = "${var.key_name}"
public_key = "${file(var.key_file)}"
}

/* Base packer build we use for provisioning master instances */
resource "atlas_artifact" "mesos-master" {
name = "${var.atlas_artifact.master}"
Expand All @@ -9,7 +14,7 @@ resource "aws_instance" "mesos-master" {
instance_type = "${var.instance_type.master}"
ami = "${replace(atlas_artifact.mesos-master.id, concat(var.region, ":"), "")}"
count = "${var.masters}"
key_name = "${var.key_name}"
key_name = "${aws_key_pair.deployer.key_name}"
subnet_id = "${aws_subnet.public.id}"
source_dest_check = false
security_groups = ["${aws_security_group.default.id}"]
Expand Down
2 changes: 1 addition & 1 deletion terraform/aws-public/mesos-slaves.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ resource "aws_instance" "mesos-slave" {
instance_type = "${var.instance_type.slave}"
ami = "${replace(atlas_artifact.mesos-master.id, concat(var.region, ":"), "")}"
count = "${var.slaves}"
key_name = "${var.key_name}"
key_name = "${aws_key_pair.deployer.key_name}"
subnet_id = "${aws_subnet.public.id}"
source_dest_check = false
security_groups = ["${aws_security_group.default.id}"]
Expand Down
2 changes: 1 addition & 1 deletion terraform/aws-public/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ variable "secret_key" {

variable "key_name" {
description = "The aws ssh key name."
default = "Apollo"
default = "deployer"
}

variable "key_file" {
Expand Down
6 changes: 3 additions & 3 deletions wercker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ deploy:
- pip-install:
requirements_file: "requirements.txt"
- capgemini/apollo-deploy:
cloud: digitalocean
artifact_name: enxebre/apollo-ubuntu-14.04-amd64
artifact_version: 2
cloud: $CLOUD
artifact_name: $ARTIFACT_NAME
artifact_version: $ARTIFACT_VERSION
terraform_version: 0.5.0
run_tests: true
after-steps:
Expand Down

0 comments on commit 1f3c1d4

Please sign in to comment.