Skip to content

Commit 2cdb948

Browse files
ryapricJDeBo
andauthored
Post-dry-run enhancements for Linux workshop (#2)
Co-authored-by: Justin DeBo <justin.debo@gmail.com>
1 parent e4f9b8c commit 2cdb948

24 files changed

Lines changed: 380 additions & 90 deletions

File tree

linux/Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,26 @@ up-local:
44
@vagrant up db
55
@vagrant up $(local_team_servers)
66

7+
up-aws:
8+
@(cd ./terraform && terraform apply)
9+
10+
yeet-aws:
11+
@(cd ./terraform && terraform apply -auto-approve)
12+
@make -s provision-aws
13+
714
provision-local:
815
# Don't re-provision DB at the same time, since it throws off team server tests
916
@vagrant provision db
1017
@vagrant provision $(local_team_servers)
1118

19+
provision-aws:
20+
@(cd ./terraform && bash ../scripts/provision-ec2.sh)
21+
1222
down-local:
1323
@vagrant destroy -f
24+
25+
down-aws:
26+
@(cd ./terraform && terraform destroy)
27+
28+
nuke-aws:
29+
@(cd ./terraform && terraform destroy -auto-approve)

linux/Vagrantfile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Vagrant.configure("2") do |config|
2-
box = "debian/bullseye64"
2+
box = "debian/bookworm64" # Debian 12
33

4-
cpus = 2
4+
cpus = 1
55
memory = 768
66

77
config.vm.provider "virtualbox" do |vb|
@@ -27,13 +27,21 @@ Vagrant.configure("2") do |config|
2727

2828
db.vm.network "private_network", ip: db_addr
2929
db.vm.network "forwarded_port", guest: 5432, host: 5432, protocol: "tcp"
30+
db.vm.network "forwarded_port", guest: 8080, host: 8080, protocol: "tcp"
3031

3132
db.vm.synced_folder ".", "/vagrant", disabled: true
3233

3334
db.vm.provision "file", source: "./scripts", destination: "/tmp/scripts"
35+
db.vm.provision "file", source: "./score-server", destination: "/tmp/score-server"
3436

3537
db.vm.provision "shell",
3638
inline: <<-SCRIPT
39+
# Need both running here for Vagrant -- other platforms should ONLY have 2332
40+
sudo sh -c 'grep 2332 /etc/ssh/sshd_config || printf "Port 2332\nPort 22\n" >> /etc/ssh/sshd_config'
41+
sudo systemctl restart ssh
42+
43+
rm -rf /root/score-server
44+
sudo cp -r /tmp/score-server /root/score-server
3745
bash /tmp/scripts/init-db.sh
3846
SCRIPT
3947
end
@@ -55,6 +63,10 @@ Vagrant.configure("2") do |config|
5563

5664
team.vm.provision "shell",
5765
inline: <<-SCRIPT
66+
# Need both running here for Vagrant -- other platforms should ONLY have 2332
67+
sudo sh -c 'grep 2332 /etc/ssh/sshd_config || printf "Port 2332\nPort 22\n" >> /etc/ssh/sshd_config'
68+
sudo systemctl restart ssh
69+
5870
export team_name="Team-#{i}"
5971
export db_addr='#{db_addr}'
6072
bash /tmp/scripts/init.sh

linux/dummy-app-src/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1+
# the possible locations of the app binary itself, and its debfile
12
app
3+
*.deb
4+
dist/debian/app/usr/bin/app
5+
# but NOT its Debian packaging root directory, which must have the same name
6+
!dist/debian/app/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Package: app
2+
Version: 1.0.0
3+
Architecture: amd64
4+
Maintainer: Ricky Bobby <bigredluvr@talladega.net>
5+
Description: Literally prints money for our company
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This file doesn't actually do anything, but there needs to be a file in the
2+
# tree so that git commits the directory structure itself

linux/dummy-app-src/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module example.com/myteam/app
22

3-
go 1.15
3+
go 1.19

linux/instructions/congrats.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Congratulations!
2+
================
3+
4+
You got the app working again, and your company is once again printing money
5+
hand over fist. Your boss is going to be thrilled! Remember to ask for a raise
6+
during your next performance review `;-)`
7+
8+
There's nothing else for you to do here except celebrate your accomplishments!
9+
Now you can kick back, relax... orrr, if you're feeling adventurous, try to
10+
break the workshop scoring system in your favor.

linux/instructions/step_0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Oh no! Our app isn't running!
33

44
Your company runs a handful of web applications on their Linux servers.
55
Unfortunately, it seems that at least one of them has stopped responding to
6-
healthcheck pings. This is *bad* -- ever second that service isn't running, the
6+
healthcheck pings. This is *bad* -- every second that service isn't running, the
77
company isn't making any money! Well, at least that's how your boss feels. You
88
just work here.
99

linux/instructions/step_1.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
Step 1: Rebuild the app binary
22
==============================
33

4-
You land on the server and need to figure out why the application isn't running.
5-
Based on the architecture diagram for the app, you know the source code for it
4+
You hop into the production server and need to figure out why the application isn't
5+
running. Based on the architecture diagram for the app and your knowledge of your
6+
company's deployment pipelines, you know the source code for it
67
should have been dumped into the directory `/opt/app`. That's probably the best
78
place to start looking; as a first step, see if you can get the app binary
89
built. Note that the application is written in Go, so you might need to look up

linux/instructions/step_3.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@ managed by a tool called `systemd`, defined in what are called "unit files".
1111
Furthermore, you know that your app's service definition is supposed to be
1212
(aptly) named `app.service`.
1313

14-
See if that service exists on the machine. If not, create it, and get it
15-
running.
14+
Create that service, and get it running. You need to make sure it runs *even if
15+
the system reboots* -- meaning that if the server is restarted for any reason,
16+
the app service needs to start again *without you starting it manually*.
17+
18+
If for any reason you need to check out more detailed logs of the service, you
19+
can also use the separate `journald` command to inspect them.

0 commit comments

Comments
 (0)