Skip to content

Commit 481f3f3

Browse files
author
Bryan Kendall
committed
Merge remote-tracking branch 'origin/master' into khronos-workers
2 parents 4e77cda + aeb9bbd commit 481f3f3

11 files changed

Lines changed: 117 additions & 11 deletions

File tree

README.md

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,98 @@
11
devops-scripts
22
==============
33

4-
Scripts for managing our deployments.
4+
Scripts for managing our deployments.
5+
6+
# How to Deploy at Runnable
7+
## Setup
8+
9+
Before you can deploy you'll need to install the appropriate tools, scripts, and keys on your local machine.
10+
To do so, execute the following steps:
11+
12+
1. Install Ansible (the deploy automation tool we use to deploy projects to production)
13+
http://docs.ansible.com/intro_installation.html
14+
15+
2. Get the latest devops-scripts (the recipes that we use to deploy various projects)
16+
https://github.com/CodeNow/devops-scripts
17+
18+
3. Change to the devops scripts repo directory and run the following command:
19+
`ln -s /<local-path-to-devops-scripts>/ssh/config ~/.ssh/config`
20+
21+
4. Obtain the “Keys of Power” from someone who can already deploy (ask Anand if you don’t know). Depending on what you want to deploy you'll receive either `Test-runnable.pem`, `oregon.pem`, or both.
22+
23+
5. Move the “Keys of Power” .pem files to your `~/.ssh` directory
24+
25+
At this point you should be capable of deploying;
26+
keep reading to find out how to actually perform a deploy!
27+
28+
## Deploying
29+
30+
### Step 1: Determine the Current Deploy Version
31+
**IMPORTANT:** always pull latest devopts-scripts!!
32+
**IMPORTANT:** Before you deploy a new version of any project make sure to determine which version of the project is currently deployed. This way you can quickly revert to the last stable release if something goes wrong after pushing a new version.
33+
34+
Currently the easiest way to determine the current deploy version is to check the latest tag in the repository you are pushing. Note: If you just tagged a new release this would be the second latest tag.
35+
36+
Once you've found the correct tag, copy it down somewhere that is easily and quickly accessible, then continue your quest of deployment...
37+
38+
### Step 2: Deploy the Project via Ansible
39+
**WARNING:** If you were unable to determine the last deploy tag for a project and cannot revert STOP HERE. Ask someone on the team for help before continuing.
40+
41+
From the devops-script/ansible directory here's how to deploy:
42+
```
43+
ansible-playbook -i ./[stage-hosts, prod-hosts] [appname].yml
44+
```
45+
`stage-hosts` is to deploy to staging, `prod-hosts` is to deploy to production
46+
`appname` is what you want to deploy
47+
this command builds and deploys master branch
48+
49+
```
50+
ansible-playbook -i ./[stage-hosts, prod-hosts] [appname].yml -e git_branch=some_brach_or_tag
51+
```
52+
Use above to deploy a specific tag or branch or release
53+
For tags use: `-e git_branch=v1.9.9`
54+
For branches use: `-e git_branch=that_branch`
55+
For a specific commit use: `-e git_branch=3928745892364578623`
56+
57+
```
58+
ansible-playbook -i ./[stage-hosts, prod-hosts] [appname].yml -t deploy -e git_branch=some_brach_or_tag
59+
```
60+
This will redeploy the current deploy without rebuilding
61+
62+
```
63+
ansible-playbook -i./[stage-hosts, prod-hosts] [appname].yml -e git_branch=some-branch-name -e build_args=”--no-cache”
64+
```
65+
66+
deploy latest version of the branch
67+
68+
## Reverting
69+
70+
If, for some reason, the new deploy is not operating as expected you can quickly revert by referencing the tag you collected in Step 1. Simply run the appropriate deploy command in the previous section with the last release tag and the new deploy will be reverted.
71+
72+
## Deploy Songs
73+
74+
It is the custom at Runnable to play a song to the entire team when deploying. For each of the repositories here are the respective songs:
75+
76+
[api: Push it - Rick Ross](https://www.youtube.com/watch?v=qk2jeE1LOn8)
77+
78+
[runnable-angular: Push it to the limit - Scarface](https://www.youtube.com/watch?v=9D-QD_HIfjA)
79+
80+
[mavis: Fairy Tail theme song](https://www.youtube.com/watch?v=kIwmrk7LoDk)
81+
82+
[khronos: Time After Time - Cyndi Lauper](https://www.youtube.com/watch?v=VdQY7BusJNU)
83+
84+
[navi: Ocarina of Time: Lost Woods The Legend of Zelda](https://www.youtube.com/watch?v=iOGpdGEEcJM)
85+
86+
[optimus: Original Transformers opening theme](https://www.youtube.com/watch?v=nLS2N9mHWaw)
87+
88+
[charon: Enter Sandman - Metallica](https://www.youtube.com/watch?v=CD-E-LDc384)
89+
90+
[docker listener: Call Me Maybe - Carly Rae Jepsen](https://www.youtube.com/watch?v=fWNaR-rxAic)
91+
92+
[krain: men at work - down under](https://www.youtube.com/watch?v=XfR9iY5y94s)
93+
94+
[filibuster: He's a Pirate - Pirates Of The Caribbean](https://www.youtube.com/watch?v=yRh-dzrI4Z4)
95+
96+
[shiva: FFXIV Shiva Theme](https://www.youtube.com/watch?v=noJiH8HLZw4)
97+
98+
**IMPORTANT:** Make sure the play the song loud and proud when deploying!

ansible/beta-hosts/docks.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ var params = {
2020
{
2121
Name: 'tag:role',
2222
Values: ['dock']
23+
},
24+
// Only fetch running instances
25+
{
26+
Name: 'instance-state-name',
27+
Values: ['running']
2328
}
2429
]
2530
};

ansible/beta-hosts/variables

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ datadog_tags=env:beta
5555
domain=runnable-beta.com
5656
new_relic_license_key=338516e0826451c297d44dc60aeaf0a0ca4bfead
5757
node_env=production-beta
58-
pg_database=shiva
58+
pg_database=astral
5959
pg_host=beta-infrastructure-db.cnksgdqarobf.us-west-2.rds.amazonaws.com
6060
pg_pass=QBjSpAXVYwmGHu4Y
6161
pg_user=shiva

ansible/group_vars/alpha-api.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ container_envs: >
2727
-e DATADOG_HOST={{ datadog_host }}
2828
-e DATADOG_PORT={{ datadog_port }}
2929
-e DOMAIN={{ domain }}
30-
-e FULL_API_DOMAIN=http://api.{{ domain }}
3130
-e GITHUB_CALLBACK_URL=https://api.{{ domain }}/auth/github/callback
3231
-e GITHUB_CLIENT_ID={{ api_github_client_id }}
3332
-e GITHUB_CLIENT_SECRET={{ api_github_client_secret }}

ansible/group_vars/alpha-image-builder.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ name: "{{ app_name }}"
44
image_builder_docker_namespace: runnable/image-builder
55

66
# we need to push this
7-
do_not_push=false
7+
do_not_push: false

ansible/group_vars/alpha-shiva.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
name: "shiva"
2-
32
container_image: "registry.runnable.com/runnable/{{ name }}"
43
container_tag: "{{ git_branch }}"
5-
repo: "git@github.com:CodeNow/{{ name }}.git"
6-
node_version: "0.10.38"
7-
npm_version: "2.1.18"
4+
repo: "git@github.com:CodeNow/astral.git"
5+
node_version: "4.2.1"
6+
npm_version: "2.8.3"
7+
8+
# Overrides the start command in the builder role
9+
npm_start_command: "run shiva-start"
810

911
# Not actually needed, just allows container-kill-start to work
1012
hosted_ports: ["3000"]

ansible/group_vars/alpha-workers.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ container_envs: >
2424
-e DATADOG_HOST={{ datadog_host }}
2525
-e DATADOG_PORT={{ datadog_port }}
2626
-e DOMAIN={{ domain }}
27-
-e FULL_API_DOMAIN=http://api.{{ domain }}
2827
-e GITHUB_CALLBACK_URL=https://api.{{ domain }}/auth/github/callback
2928
-e GITHUB_CLIENT_ID={{ api_github_client_id }}
3029
-e GITHUB_CLIENT_SECRET={{ api_github_client_secret }}

ansible/prod-hosts/docks.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ var params = {
2020
{
2121
Name: 'tag:role',
2222
Values: ['dock']
23+
},
24+
// Only fetch running instances
25+
{
26+
Name: 'instance-state-name',
27+
Values: ['running']
2328
}
2429
]
2530
};

ansible/prod-hosts/variables

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ datadog_tags=env:alpha
5555
domain=runnable.io
5656
new_relic_license_key=338516e0826451c297d44dc60aeaf0a0ca4bfead
5757
node_env=production
58-
pg_database=shiva
58+
pg_database=astral
5959
pg_host=alpha-production-db.czw5moz6rmpp.us-west-1.rds.amazonaws.com:30573
6060
pg_pass=wCJGCfCWE9CKmQwa2XUKj6d8WYcEZAb9
6161
pg_user=shiva
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
---
22
build_dir: /opts/builds/docker_build/
3+
npm_start_command: start

0 commit comments

Comments
 (0)