Skip to content
Merged
Changes from 4 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
151 changes: 90 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,91 +22,120 @@ https://github.com/CodeNow/devops-scripts

5. Move the “Keys of Power” .pem files to your `~/.ssh` directory

At this point you should be capable of deploying;
keep reading to find out how to actually perform a deploy!
At this point you should be capable of deploying; keep reading to find out how to actually perform a deploy!

## Deploying
## Deploying Services
- **IMPORTANT:** always pull latest devopts-scripts (`git pull origin master`)
- **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.

### Step 1: Determine the Current Deploy Version
**IMPORTANT:** always pull latest devopts-scripts!!
**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.
To determine the latest deploy tag for a project please check the project's repository on
github and look for the latest release tag (should be in the form `vX.Y.Z`). Once you've located the tag,
copy it down somewhere that is easily and quickly accessible (you may need to use it quickly if something goes wrong).

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.
### Step 2: Deploy the Project via `ansible-playbook`

Once you've found the correct tag, copy it down somewhere that is easily and quickly accessible, then continue your quest of deployment...
- **WARNING:** If you were unable to determine the last deploy tag for a project and cannot revert **STOP**.
Ask someone on the team for help before continuing.
- **IMPORTANT:** All commands should be run from the `devops-script/ansible` directory.

### Step 2: Deploy the Project via Ansible
**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.
#### Latest Master
Build and deploy a service to the latest commit on the master branch of its repository. This will build
the docker image needed to run the container on our infrastructure.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we never deploy master - it's impossible to roll back. always deploy the latest tag, never the master branch.


From the devops-script/ansible directory here's how to deploy:
##### Command
```
ansible-playbook -i ./[stage-hosts, prod-hosts] [appname].yml
ansible-playbook -i ./[inventory_dir] [service-playbook]
```
`stage-hosts` is to deploy to staging, `prod-hosts` is to deploy to production
`appname` is what you want to deploy
this command builds and deploys master branch

##### Arguments
- `[inventory_dir]` - The environment inventory files (servers and variables). Should be one of the following:
- `stage-hosts` - Runnable sandbox staging environment services
- `gamma-hosts` - Gamma services (internal use only; production mirror)
- `delta-hosts` - Delta services (real production)
- `[service-playbook]` - The playbook for the service you wish to deploy, ex:
- `api.yml` - Deploys both the api and the api-workers services
- `shiva.yml` - Deploys the shiva micro-service
- `charon.yml` - Deploys a specific version of charon DNS to all docks

#### Branch or Tag
Build and deploy a service to a specific branch or tag on its repository. This performs a build
of the docker image needed to run the service on our architecture.

##### Command
```
ansible-playbook -i ./[stage-hosts, prod-hosts] [appname].yml -e git_branch=some_brach_or_tag
ansible-playbook -i ./[inventory_dir] [service-playbook] -e git_branch=[branch-or-tag]
```
Use above to deploy a specific tag or branch or release
For tags use: `-e git_branch=v1.9.9`
For branches use: `-e git_branch=that_branch`
For a specific commit use: `-e git_branch=3928745892364578623`

```
ansible-playbook -i ./[stage-hosts, prod-hosts] [appname].yml -t deploy -e git_branch=some_brach_or_tag
```
This will redeploy the current deploy without rebuilding

```
ansible-playbook -i ./[stage-hosts, prod-hosts] [appname].yml -e git_branch=some-branch-name -e build_args=--no-cache
```

deploy latest version of the branch

## Reverting

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.

## Deploy Songs

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:
##### Arguments
- `[inventory_dir]` - The environment inventory files (servers and variables).
- `[service-playbook]` - The playbook for the service you wish to deploy.
- `[branch-or-tag]` - The branch or tag you wish to deploy, ex:
- `-e git_branch=v1.9.9` (version tag)
- `-e git_branch=my-feature-branch` (branch)
- `-e git_branch=3928745892364578623` (specific commit)

*NEW JUAREZ* [stack: The Cleveland Orchestra (George Szell conducting) Ludwig von Beethoven Symphony No. 9 "Chorale (Ode To Joy)" Opus 125 IV. Presto; Allegro molto assai (Alla marcia); Andante maestroso; Allegro energico, sempre ben marcato.] (https://www.youtube.com/watch?v=4g5770gaais)

[api: Push it - Rick Ross](https://www.youtube.com/watch?v=qk2jeE1LOn8)
#### Redeploy Tag or Branch (No Build)
Redeploy the given tag or branch without building the docker image. This is useful for when a redeploy
is required, but it is of an already built image (e.g. when a service runs out of memory).

[runnable-angular: Push it to the limit - Scarface](https://www.youtube.com/watch?v=9D-QD_HIfjA)

[mavis: Fairy Tail theme song](https://www.youtube.com/watch?v=R4UFCTMrV-o)

[khronos: Time After Time - Cyndi Lauper](https://www.youtube.com/watch?v=VdQY7BusJNU)

[navi: Ocarina of Time: Lost Woods The Legend of Zelda](https://www.youtube.com/watch?v=iOGpdGEEcJM)

[optimus: Original Transformers opening theme](https://www.youtube.com/watch?v=nLS2N9mHWaw)

[charon: Enter Sandman - Metallica](https://www.youtube.com/watch?v=CD-E-LDc384)
##### Command
```
ansible-playbook -i ./[inventory_dir] [service-playbook] -t deploy -e git_branch=[branch-or-tag]
```

[docker listener: Call Me Maybe - Carly Rae Jepsen](https://www.youtube.com/watch?v=fWNaR-rxAic)
##### Arguments
- `[inventory_dir]` - The environment inventory files (servers and variables).
- `[service-playbook]` - The playbook for the service you wish to deploy.
- `[branch-or-tag]` - The branch or tag you wish to deploy.

[krain: men at work - down under](https://www.youtube.com/watch?v=XfR9iY5y94s)
##### Rebuild and Deploy Tag or Branch (No Cache)
Forces a rebuild of a docker image for the given service at the given branch or tag and then deploys the
newly created image. This is useful when a previously deployed branch has new changes that need to
be deployed to an environment.

[filibuster: He's a Pirate - Pirates Of The Caribbean](https://www.youtube.com/watch?v=yRh-dzrI4Z4)
Generally this command is only used with `gamma-hosts/` as it is often used to update code
being tested in the production mirror.

[shiva: FFXIV Shiva Theme](https://www.youtube.com/watch?v=noJiH8HLZw4)
##### Command
```
ansible-playbook -i ./[inventory_dir] [service-playbook] -e git_branch=[branch-or-tag] -e build_args=--no-cache
```

[swarm-manager: Eric Prydz VS Pink Floyd - 'Proper Education'](https://www.youtube.com/watch?v=IttkDYE33aU)
##### Arguments
- `[inventory_dir]` - The environment inventory files (servers and variables).
- `[service-playbook]` - The playbook for the service you wish to deploy.
- `[branch-or-tag]` - The branch or tag you wish to deploy.

[swarm-deamon: Pink Floyd - Another Brick In The Wall](https://www.youtube.com/watch?v=5IpYOF4Hi6Q)

[vault / vault-values: Seal - Kiss From A Rose](https://www.youtube.com/watch?v=zP3so2hY4CM)
## Reverting
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.

[Sauron: Sauron theme song from LOTR](https://www.youtube.com/watch?v=V_rk9VBrXMY)
## Deploy Songs

[Detention: Unbreakable Kimmy Schmidt](https://youtu.be/CV9xF8CjhJk?t=21s)
- **IMPORTANT:** Make sure to play the song loud and proud when deploying!

[Link: Zelda Main Theme Song](https://www.youtube.com/watch?v=cGufy1PAeTU)
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:

**IMPORTANT:** Make sure to play the song loud and proud when deploying!
| Service | Deploy Song Link |
| ------- | ---------------- |
| api / api-workers | [Push it - Rick Ross](https://www.youtube.com/watch?v=qk2jeE1LOn8) |
| charon | [Enter Sandman - Metallica](https://www.youtube.com/watch?v=CD-E-LDc384) |
| detention | [Unbreakable Kimmy Schmidt](https://youtu.be/CV9xF8CjhJk?t=21s) |
| docker-listener | [Call Me Maybe - Carly Rae Jepsen](https://www.youtube.com/watch?v=fWNaR-rxAic) |
| filibuster | [He's a Pirate - Pirates Of The Caribbean](https://www.youtube.com/watch?v=yRh-dzrI4Z4) |
| khronos | [Time After Time - Cyndi Lauper](https://www.youtube.com/watch?v=VdQY7BusJNU) |
| krain | [Men at Work - Down Under](https://www.youtube.com/watch?v=XfR9iY5y94s) |
| link | [Zelda Main Theme Song](https://www.youtube.com/watch?v=cGufy1PAeTU) |
| mavis | [Fairy Tail theme song](https://www.youtube.com/watch?v=R4UFCTMrV-o) |
| navi | [Ocarina of Time: Lost Woods The Legend of Zelda](https://www.youtube.com/watch?v=iOGpdGEEcJM) |
| optimus | [Original Transformers Opening Theme](https://www.youtube.com/watch?v=nLS2N9mHWaw) |
| runnable-angular | [Push it to the limit - Scarface](https://www.youtube.com/watch?v=9D-QD_HIfjA) |
| sauron | [Sauron theme song from LOTR](https://www.youtube.com/watch?v=V_rk9VBrXMY) |
| shiva | [FFXIV Shiva Theme](https://www.youtube.com/watch?v=noJiH8HLZw4) |
| swarm-deamon | [Pink Floyd - Another Brick In The Wall](https://www.youtube.com/watch?v=5IpYOF4Hi6Q) |
| swarm-manager | [Eric Prydz VS Pink Floyd - 'Proper Education'](https://www.youtube.com/watch?v=IttkDYE33aU) |
| vault / vault-values | [Seal - Kiss From A Rose](https://www.youtube.com/watch?v=zP3so2hY4CM) |
| Full Stack Deploy (`all.yml`) | [The Cleveland Orchestra (George Szell conducting) Ludwig von Beethoven Symphony No. 9 "Chorale (Ode To Joy)" Opus 125 IV.] (https://www.youtube.com/watch?v=4g5770gaais) |