Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grizzly env #603

Open
wants to merge 62 commits into
base: setup-playbook
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
4df8e16
Start adding default hosts
thejsj Feb 1, 2017
50e36c4
Add default variables
thejsj Feb 2, 2017
b74fc64
Add ENVs in other files
thejsj Feb 2, 2017
5ba8128
Change spacing
thejsj Feb 2, 2017
ac326a9
Remove variable for IP address and change it with hosts
thejsj Feb 2, 2017
4c6ea19
Fix vars
thejsj Feb 2, 2017
4add3a7
Add values to consul
thejsj Feb 3, 2017
0b1cf47
Add rol for lets encrypt
thejsj Feb 3, 2017
3003d82
Split up single-host into parts
thejsj Feb 3, 2017
7f060ea
Merge branch 'setup-playbook' of github.com:CodeNow/devops-scripts in…
thejsj Feb 3, 2017
e4a5a2d
Step 1: Add env, domain, and user_content_domain
thejsj Feb 3, 2017
7cdd4d0
Step 3: Add access key, region, and ssh key name for AWS
thejsj Feb 3, 2017
5f03212
Step 4 and Step 5: Fill in variables
thejsj Feb 3, 2017
0ab1bec
Step 6: Fill in MAIN_HOST_IP_ADDRESS and main host
thejsj Feb 3, 2017
9f5d224
Change IP address to new host
thejsj Feb 4, 2017
6d0c4b8
Step 8: Add RDS database
thejsj Feb 4, 2017
5ea8862
Fix script for base (step 6)
thejsj Feb 4, 2017
d0fd726
Step 6 Fix: Fix IP address and children
thejsj Feb 4, 2017
bf6a1cb
Fix letsencrypt cert generation stuff
thejsj Feb 6, 2017
32b03ea
Step 11: Adding credentials for local vault
thejsj Feb 6, 2017
72e1802
Fix template
thejsj Feb 6, 2017
1f3ae30
Delete unnecesary file
thejsj Feb 6, 2017
c21dc9b
Fix genClientCert to take two arguments
thejsj Feb 6, 2017
f587a95
Step 13: Generate docker client certs
thejsj Feb 6, 2017
df015a1
Step 14: Fill in security group and subnet for dock
thejsj Feb 6, 2017
1676303
Step 19: Add keys and auth token for vault
thejsj Feb 7, 2017
0bb471e
BUG: Fix pulling of swarm image
thejsj Feb 7, 2017
d79872a
Styep 15: Create AMI for docks
thejsj Feb 7, 2017
9e8b8f5
Setp 16: Add LC Version for dock pool
thejsj Feb 7, 2017
5979fa9
Bug: Assert mongo group and user exist
thejsj Feb 7, 2017
b56c40b
Step 4: Fill in Cookie for navi
thejsj Feb 7, 2017
18a041d
Bug: Fix mongo ports
thejsj Feb 7, 2017
76fc36e
Bug: Fix problem with swarm_version template string
thejsj Feb 7, 2017
7f88c08
Bug: Fix node base Dockerfile
thejsj Feb 7, 2017
1c5c579
Redo Step 6: Add new main host IP address
thejsj Feb 7, 2017
e155639
Redo Step 13: Generate new certs for docker client
thejsj Feb 7, 2017
e779852
Bug: Fix registry IP address. Fix typo
thejsj Feb 8, 2017
68ab14e
Redo Step 19: Create vault tokens
thejsj Feb 8, 2017
664e300
Bug: Upgrade dock-init
thejsj Feb 8, 2017
b8da574
Redo Step 15: Bake new AMI
thejsj Feb 8, 2017
ee168bd
Redo Step 17: Upgrade launch configuration version
thejsj Feb 8, 2017
09f7f15
Bug: Fix BP installing postgres
thejsj Feb 8, 2017
61af0a9
Bug: Add kill_container_name for consul-template
thejsj Feb 8, 2017
049dc8b
Bug: Fix Redis port
thejsj Feb 8, 2017
b7a7b0b
Bug: Remove comment from variables. Gets inserted into the ENV
thejsj Feb 8, 2017
cfd7e6f
Enhancement: Create Mongo user when deploying mongo
thejsj Feb 8, 2017
4ae4a1d
Bug: Add certs and known_hosts in order to be able to install npm mod…
thejsj Feb 8, 2017
c597a59
Step 21: Add Github variables and other variables needed to deploy FE
thejsj Feb 8, 2017
a235e85
Bug: Add certs and known_hosts in order to be able to install npm mod…
thejsj Feb 8, 2017
deea1d4
Bug: Fix mongodb datadog deployment stuff
thejsj Feb 8, 2017
ed4d3b9
Step 21: Go through deploying applications
thejsj Feb 8, 2017
a22fab3
Bug: Adding region and node-sass to web, marketing, and detention
thejsj Feb 8, 2017
bf552a0
Step 21: Add new necessary vars
thejsj Feb 8, 2017
0f9095e
Bug: Add image-builder to dock script
thejsj Feb 9, 2017
070fd0f
Bug: Change access token in link to variable
thejsj Feb 9, 2017
bf67917
Bug: Fix mongo image
thejsj Feb 9, 2017
c5ac889
Step 4: Fix auth for MongoDB
thejsj Feb 9, 2017
9e469d0
Step 4: Change HelloRunnable Access Tokens
thejsj Feb 9, 2017
0663233
Bug: Make number of containers default to 1 in single host
thejsj Feb 9, 2017
0c39afb
Bug: Github domain should be github.com, not api.github.com
thejsj Feb 9, 2017
7329f91
Step 16: Fix subnet, asg, ami, access key for grizzly env
thejsj Feb 9, 2017
7c3770b
Step 13: Generate new certs for docker_client
thejsj Feb 9, 2017
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
2 changes: 2 additions & 0 deletions ansible/base.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
- hosts: registry

- hosts: localhost
connection: local
tasks:
Expand Down
75 changes: 75 additions & 0 deletions ansible/default-hosts/docks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env node

'use strict';

var aws = require('aws-sdk');
var ec2 = new aws.EC2({
accessKeyId: '${AWS_ACCESS_KEY_ID_1}',
secretAccessKey: '${AWS_SECRET_ACCESS_KEY_1}',
region: '${AWS_REGION}'
});

var params = {
Filters: [
// Only search for docks in the cluster security group
{
Name: 'instance.group-id',
Values: ['${AWS_DOCK_SG}'] // This script is the same for all environments
},
// Only fetch instances that are tagged as docks
{
Name: 'tag:role',
Values: ['dock']
},
// Only fetch running instances
{
Name: 'instance-state-name',
Values: ['running']
}
]
};

ec2.describeInstances(params, function (err, data) {
if (err) {
console.error("An error occurred: ", err);
process.exit(1);
}

// Get a set of instances from the describe response
var instances = [];
data.Reservations.forEach(function (res) {
res.Instances.forEach(function (instance) {
instances.push(instance);
});
});

// Map the instances to their private ip addresses
// NOTE This will work locally because of the wilcard ssh proxy in the config
var hosts = instances.map(function (instance) {
return instance.PrivateIpAddress;
});

var hostVars = {};
instances.forEach(function (instance) {
for (var i = 0; i < instance.Tags.length; i++) {
if (instance.Tags[i].Key === 'org') {
hostVars[instance.PrivateIpAddress] = {
host_tags: instance.Tags[i].Value + ',build,run'
};
}
}
});

// Output the resulting JSON
// NOTE http://docs.ansible.com/ansible/developing_inventory.html
console.log(JSON.stringify(
{
docks: {
hosts: hosts
},
_meta : {
hostvars : hostVars
}
}
));
});
159 changes: 159 additions & 0 deletions ansible/default-hosts/hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
[bastion]
dafault-bastion

[hipache]
default-main httpsCheckForBackend80=false prependIncomingPort=true subDomainDepth=4

[userland]
default-main

[mongodb]
default-main

[api_group:children]
worker
api
socket-server

[api]
default-main

[big-poppa]
default-main

[cream]
default-main

[consul]
default-main

[docker-listener]
default-main

[vault]
default-main

[worker]
default-main

[navi]
default-main

[ingress]
default-main

[link]
default-main

[mongo-navi]
default-main

[charon]
default-main

[khronos]
default-main

[optimus]
default-main

[detention]
default-main

[palantiri]
default-main

[rabbitmq]
default-main

[web]
default-main

[redis]
default-main

[redis-slave]
default-main

[sauron]
default-main

[shiva]
default-main

[socket-server]
default-main

[socket-server-proxy]
default-main

[registry]
default-main

[swarm-manager]
default-main

[metis]
default-main

[drake]
default-main

[pheidi]
default-main

[github-varnish]
default-main

[single-host-proxy]
default-main

[docks]

[dock]

[prometheus]
default-main

[bear-clone:children]
api
bastion
big-poppa
charon
consul
cream
dock
docker-listener
docks
drake
hipache
ingress
khronos
metis
mongodb
navi
optimus
pheidi
prometheus
rabbitmq
redis
redis-slave
registry
sauron
shiva
single-host-proxy
socket-server
socket-server-proxy
swarm-manager
userland
web
worker

[local]
127.0.0.1

[ec2]
local

[targets]
localhost ansible_connection=local bastion_name=default-bastion
134 changes: 134 additions & 0 deletions ansible/default-hosts/variables
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
[api_group:vars]
api_aws_access_key_id=${AWS_ACCESS_KEY_ID_1}
api_aws_secret_access_key=${AWS_SECRET_ACCESS_KEY_1}
api_github_client_id=${GITHUB_CLIEND_ID}
api_github_client_secret=${GITHUB_CLIENT_SECRET}
api_github_deploy_keys_bucket=runnable.deploykeys.${ENV}
api_mongo_auth=${MONGO_USERNAME}:${MONGO_PASSWORD}
api_mongo_database=${ENV}
api_mongo_replset_name=${ENV}-rs0
api_s3_context_bucket=runnable.context.resources.${ENV}

[big-poppa:vars]
big_poppa_pg_pass=${POSTGRES_PASSWORD}
big_poppa_pg_host=${POSTGRES_HOST}:${POSTGRES_PORT}
big_poppa_pg_port=${POSTGRES_PORT}
big_poppa_pg_user=big_poppa
big_poppa_github_token=${GITHUB_ACCESS_TOKEN}
big_poppa_mongo_auth=${MONGO_USERNAME}:${MONGO_PASSWORD}
big_poppa_mongo_database=${MONGO_DATABASE}
big_poppa_mongo_replset_name=${MONGO_DATABASE}-rs0
big_poppa_pg_pool_min=10
big_poppa_pg_pool_max=20

[cream:vars]
cream_hello_runnable_github_token=${GITHUB_ACCESS_TOKEN}
cream_stripe_secret_key=${STRIPE_SECRET_KEY}
cream_stripe_publishable_key=${STRIPE_PUBLISHABLE_KEY}

[docks:vars]
docker_config=docks
docks_rollbar_key=${ROLLBAR_TOKEN_DOCKS}

[dock:vars]
docks_rollbar_key=${ROLLBAR_TOKEN_DOCKS}

[drake:vars]
drake_port=80

[khronos:vars]
khronos_mongo_auth=${MONGO_USER}:${MONGO_PASSWORD}
khronos_mongo_database=${MONGO_DATABASE}
khronos_mongo_replset_name=${MONGO_DATABASE}

[metis:vars]

[navi:vars]
navi_cookie_secret=${COOKIE_SECRET}
_navi_proxy_port=65100
_navi_proxy_ssl_port=65101

[optimus:vars]
optimus_aws_access_id=${AWS_ACCESS_KEY_ID_1}
optimus_aws_secret_id=${AWS_SECRET_ACCESS_KEY_1}
optimus_github_deploy_keys_bucket=runnable.deploykeys.${ENV}

[palantiri:vars]

[pheidi:vars]
pheidi_mongo_auth=${MONGO_USER}:${MONGO_PASSWORD}
pheidi_mongo_database=${MONGO_DATABASE}
pheidi_mongo_replset_name=${MONGO_DATABASE}
pheidi_runnabot_tokens=${GITHUB_ACCESS_TOKEN}

[sauron:vars]

[registry:vars]
registry_s3_access_key=${AWS_ACCESS_KEY_ID_1}
registry_s3_secret_key=${AWS_SECRET_ACCESS_KEY_1}
registry_s3_bucket=runnableimages.${ENV}
registry_s3_region=${AWS_REGION}

[shiva:vars]
aws_access_key_id=${AWS_ACCESS_KEY_ID_1}
aws_secret_access_key=${AWS_ACCESS_KEY_ID_1}
shiva_aws_region=${AWS_REGION}
shiva_dock_security_groups=${AWS_DOCK_SG}
shiva_ssh_key_name=${AWS_SSH_KEY_NAME}
shiva_aws_instance_image_id=${AWS_DOCK_AMI_ID}
shiva_aws_instance_image_name=${AWS_DOCK_AMI_NAME}
shiva_aws_instance_type=t2.medium
shiva_dock_pool_asg_name=${ENV}-asg-dock-pool
shiva_aws_launch_configuration_name=${ENV}-lc-${AWS_LC_VERSION}
shiva_aws_auto_scaling_group_subnets=${AWS_ASG_SUBNET}
shiva_aws_auto_scaling_group_max=29
shiva_aws_auto_scaling_group_prefix=asg-${ENV}-

[swarm-manager:vars]
aws_access_key=${AWS_ACCESS_KEY_ID_1}
aws_secret_key=${AWS_SECRET_ACCESS_KEY_1}
environment_name=${ENV}

[vault:vars]
vault_hello_runnable_github_token=${GITHUB_ACCESS_TOKEN_HELLO_RUNNABLE}
vault_aws_access_key_id=${AWS_ACCESS_KEY_ID_1}
vault_aws_secret_key=${AWS_SECRET_ACCESS_KEY_1}
vault_aws_region=${AWS_REGION}
vault_root_token=${LOCAL_VAULT_ROOT_TOKEN}
vault_unseal_tokens={'one':'${LOCAL_VAULT_TOKEN_1}', 'two': '${LOCAL_VAULT_TOKEN_2}', 'three': '${LOCAL_VAULT_TOKEN_3}', 'four': '${LOCAL_VAULT_TOKEN_4}', 'five': '${LOCAL_VAULT_TOKEN_5}'}
_vault_port=65240
_vault_ssl_port=65241

[${ENV}:vars]
bastion_sshd_port=60709
datadog_tags=env:${ENV}
datadog_mongodb_user=datadog
datadog_mongodb_pwd=
domain=${DOMAIN}
mongo_port=27017
node_env=${ENV}
pg_user=astral
pg_pass=${POSTGRES_PASSWORD}
pg_host=${POSTGRES_HOST}:${POSTGRES_PORT}
rabbit_password=${RABBIT_PASSWORD}
rabbit_username=${RABBIT_USERNAME}
_registry_port=65001
_consul_api_port=65200
_consul_https_port=65201
_swarm_master_port=65250
user_content_domain=${USER_CONTENT_DOMAIN}
max_navi_port=65000
_redis_port=65075
_redis_tls_port=65076
api_hello_runnable_github_token=${GITHUB_ACCESS_TOKEN_HELLO_RUNNABLE}
vault_auth_token=${REMOTE_VAULT_ROOT_TOKEN}
vault_token_01=${REMOTE_VAULT_TOKEN_1}
vault_token_02=${REMOTE_VAULT_TOKEN_2}
vault_token_03=${REMOTE_VAULT_TOKEN_3}
vault_token_04=${REMOTE_VAULT_TOKEN_4}
vault_token_05=${REMOTE_VAULT_TOKEN_5}
github_domain=api.github.com
is_github_enterprise=false
github_protocol=https
proxy_container_image=runnable/sticky-nginx
proxy_container_image_version=v1.8.1
6 changes: 4 additions & 2 deletions ansible/dock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
name={{ dock }}
groups=dock

- include: image-builder.yml git_branch="v4.2.3"
- include: charon.yml git_branch="v4.0.0"
- include: dock-init.yml git_branch="v10.1.0"
- include: dock-init.yml git_branch="v10.1.1"
- include: krain.yml git_branch="v0.3.0"

- hosts: "{{ dock }}"
tasks:
tasks:
- name: remove datadog agent
become: true
apt:
Expand All @@ -29,3 +30,4 @@
- { role: install-ssm }
- { role: dock-images }
- { role: docks-psad }

Loading