Skip to content

Repository files navigation

devops-scripts

Scripts for managing our deployments.

How to Deploy at Runnable

Setup

Before you can deploy you'll need to install the appropriate tools, scripts, and keys on your local machine. To do so, execute the following steps:

  1. Install Ansible v2.2.1.0 (the deploy automation tool we use to deploy projects to production) Installation: http://docs.ansible.com/intro_installation.html Upgrading: sudo pip install ansible==2.2.1.0 or http://docs.ansible.com/ansible/intro_installation.html#latest-releases-via-pip

  2. Install JMESPath: pip install jmespath-terminal

  3. Get the latest devops-scripts (the recipes that we use to deploy various projects) https://github.com/CodeNow/devops-scripts

  4. Change to the devops scripts repo directory and run the following command: ln -s /<local-path-to-devops-scripts>/ssh/config ~/.ssh/config

  5. Obtain the "Ansible Secrets" zip for the environment you want to deploy (or create the new environment following ./environments/README.md)

  6. Unzip file obtained above into devops-scripts/environments/${YOUR_ENV}/secrets

  7. Copy the *.pem files from devops-scripts/ansible/secrets to your ~/.ssh directory

  8. Install two required tools onto your machine:

brew update && brew install vault daemon

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

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

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).

Step 2: Deploy the Project via ansible-playbook

  • 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.

Ansible Vault

Please note that there are playbook that require encrypted ansible vault files. If you see the following error:

ERROR: A vault password must be specified to decrypt # snip

you will need to re-run the playbook with:

--ask-vault-pass

Latest Tag

Build and deploy a service to the latest tag of its repository. This will build the docker image needed to run the container on our infrastructure.

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 ../[inventory_dir] [service-playbook] -e @../environments/[gamma-or-delta]/main.yml -e git_branch=[branch-or-tag] -t deploy
Arguments
  • [inventory_dir] - The environment inventory files (servers and variables). Should be one of the following:
    • /enviroments/stage - Runnable sandbox staging environment services
    • /environments/gamma - Gamma services (internal use only; production mirror)
    • /environments/delta - Delta services (real production)
  • [main-var-file] - The file with the main variables for the environment
  • [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] - 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)
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.

Generally this command is only used with gamma-hosts/ as it is often used to update code being tested in the production mirror.

Command
ansible-playbook -i ../[inventory_dir] [service-playbook] -e @../environments/[gamma-or-delta]/main.yml] -e git_branch=[branch-or-tag] -t deploy -e build_args=--no-cache
Arguments
  • [inventory_dir] - The environment inventory files (servers and variables).
  • [main-var-file] - The file with the main variables for the environment
  • [service-playbook] - The playbook for the service you wish to deploy.
  • [branch-or-tag] - The branch or tag you wish to deploy.

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

  • IMPORTANT: Make sure to play the song loud and proud when deploying!

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:

ServiceDeploy Song Link
api / api-workersPush it - Rick Ross
arithmancyonerepublic - Counting Stars
big poppaBig Poppa - The Notorious B.I.G.
charonEnter Sandman - Metallica
clioBilly Joel - We Didn't Start the Fire
creamC.R.E.A.M. - Wu-Tang Clan
customerbotTrailer Park Boys Theme
deployerRollout - Ludacris
detentionUnbreakable Kimmy Schmidt
docker-listenerCall Me Maybe - Carly Rae Jepsen
drakeDrake - Hotline Bling
filibusterHe's a Pirate - Pirates Of The Caribbean
Full Stack Deploy (all.yml)The Cleveland Orchestra (George Szell conducting) Ludwig von Beethoven Symphony No. 9 "Chorale (Ode To Joy)" Opus 125 IV.
github-proxyProxy - Martin Garrix
khronosTime After Time - Cyndi Lauper
krainMen at Work - Down Under
linkZelda Main Theme Song
mavisFairy Tail Theme song
naviOcarina of Time: Lost Woods The Legend of Zelda
optimusOriginal Transformers Opening Theme
pheidiChariots of Fire Theme
runnable-angularPush It To The Limit - Scarface
sauronSauron Theme Song from LOTR
Security GroupsOut Of The Woods - Tayor Swift
shivaFFXIV Shiva Theme
starlordBlue Swede - Hooked on a Feeling
swarm-deamonPink Floyd - Another Brick In The Wall
swarm-managerEric Prydz VS Pink Floyd - 'Proper Education'
varnishKarate Kid Theme Song
vault / vault-valuesSeal - Kiss From A Rose

About

devops-scripts

Resources

Stars

1 star

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages