Skip to content

Commit 3ca4463

Browse files
add readme
1 parent f3c31a5 commit 3ca4463

1 file changed

Lines changed: 100 additions & 6 deletions

File tree

ansible/README.md

Lines changed: 100 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,106 @@ Ansible provides a framework for our administration and deployment. It requires
44
Here is the organization of the files in `devops-scripts/ansible`
55

66
* `*-hosts` - Files naming all the servers
7-
* `*.yml` - The top level ansible actions. These files describe how a host has vars and roles executed on it.
8-
* `/group_vars` - yml files that define variables and values for your ansible scripts. This mostly maps one to one with machine types in AWS. They’re a key value map.
9-
* `/library` - Third party libraries and scripts.
10-
* `/roles` - A set of folders containing the ansible roles. A role defines the executable actions by ansible. The center pieces is the `/tasks/main.yml`. It defines name actions and requirements.
7+
* `*.yml` - The top level ansible actions. These files describe how a host has vars and roles executed on it.
8+
* `/group_vars` - yml files that define variables and values for your ansible scripts. This mostly maps one to one with machine types in AWS. They’re a key value map.
9+
* `/library` - Third party libraries and scripts.
10+
* `/roles` - A set of folders containing the ansible roles. A role defines the executable actions by ansible. The center pieces is the `/tasks/main.yml`. It defines name actions and requirements.
1111
The role can have several sub folders.
12-
* `/handlers` - ???
12+
* `/handlers` - ???
1313
* `/defaults` - ???
1414
* `/meta` - contains dependencies
15-
* `/template` - templates for any files that need to be generate and delivered.
15+
* `/template` - templates for any files that need to be generate and delivered.
16+
17+
# How to Deploy at Runnable
18+
## Setup
19+
20+
Before you can deploy you'll need to install the appropriate tools, scripts, and keys on your local machine.
21+
To do so, execute the following steps:
22+
23+
1. Install Ansible (the deploy automation tool we use to deploy projects to production)
24+
http://docs.ansible.com/intro_installation.html
25+
26+
2. Get the latest devops-scripts (the recipes that we use to deploy various projects)
27+
https://github.com/CodeNow/devops-scripts
28+
29+
3. Change to the devops scripts repo directory and run the following command:
30+
`ln -s /<local-path-to-devops-scripts>/ssh/config ~/.ssh/config`
31+
32+
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`, `runnablevpc.pem`, or both.
33+
34+
5. Move the “Keys of Power” .pem files to your `~/.ssh` directory
35+
36+
At this point you should be capable of deploying;
37+
keep reading to find out how to actually perform a deploy!
38+
39+
## Deploying
40+
41+
### Step 1: Determine the Current Deploy Version
42+
**IMPORTANT:** always pull latest devopts-scripts!!
43+
**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.
44+
45+
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.
46+
47+
Once you've found the correct tag, copy it down somewhere that is easily and quickly accessible, then continue your quest of deployment...
48+
49+
### Step 2: Deploy the Project via Ansible
50+
**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.
51+
52+
From the devops-script/ansible directory here's how to deploy:
53+
```
54+
ansible-playbook -i ./[stage-hosts, prod-hosts] [appname].yml
55+
```
56+
`stage-hosts` is to deploy to staging, `prod-hosts` is to deploy to production
57+
`appname` is what you want to deploy
58+
this command builds and deploys master branch
59+
60+
```
61+
ansible-playbook -i ./[stage-hosts, prod-hosts] [appname].yml -e git_branch=some_brach_or_tag
62+
```
63+
Use above to deploy a specific tag or branch or release
64+
For tags use: `-e git_branch=v1.9.9`
65+
For branches use: `-e git_branch=that_branch`
66+
For a specific commit use: `-e git_branch=3928745892364578623`
67+
68+
```
69+
ansible-playbook -i ./[stage-hosts, prod-hosts] [appname].yml -t deploy -e git_branch=some_brach_or_tag
70+
```
71+
This will redeploy the current deploy without rebuilding
72+
73+
```
74+
ansible-playbook -i./[stage-hosts, prod-hosts] [appname].yml -e git_branch=some-branch-name -e build_args=”--no-cache”
75+
```
76+
77+
deploy latest version of the branch
78+
79+
## Reverting
80+
81+
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.
82+
83+
## Deploy Songs
84+
85+
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:
86+
87+
[api: Push it - Rick Ross](https://www.youtube.com/watch?v=qk2jeE1LOn8)
88+
89+
[runnable-angular: Push it to the limit - Scarface](https://www.youtube.com/watch?v=9D-QD_HIfjA)
90+
91+
[mavis: Fairy Tail theme song](https://www.youtube.com/watch?v=kIwmrk7LoDk)
92+
93+
[khronos: Time After Time - Cyndi Lauper](https://www.youtube.com/watch?v=VdQY7BusJNU)
94+
95+
[navi: Ocarina of Time: Lost Woods The Legend of Zelda](https://www.youtube.com/watch?v=iOGpdGEEcJM)
96+
97+
[optimus: Original Transformers opening theme](https://www.youtube.com/watch?v=nLS2N9mHWaw)
98+
99+
[charon: Enter Sandman - Metallica](https://www.youtube.com/watch?v=CD-E-LDc384)
100+
101+
[docker listener: Call Me Maybe - Carly Rae Jepsen](https://www.youtube.com/watch?v=fWNaR-rxAic)
102+
103+
[krain: men at work - down under](https://www.youtube.com/watch?v=XfR9iY5y94s)
104+
105+
[filibuster: He's a Pirate - Pirates Of The Caribbean](https://www.youtube.com/watch?v=yRh-dzrI4Z4)
106+
107+
[shiva: FFXIV Shiva Theme](https://www.youtube.com/watch?v=noJiH8HLZw4)
108+
109+
**IMPORTANT:** Make sure the play the song loud and proud when deploying!

0 commit comments

Comments
 (0)