Skip to content

Commit a86ab95

Browse files
authored
AZ fixes for servers, add DNS entries, fix provisioner (#21)
Co-authored-by: Ryan J. Price <ryapric@gmail.com>. Bypassing CI check failure because it was introduced with the latest linter, which I will fix later.
1 parent a65f2a5 commit a86ab95

16 files changed

Lines changed: 168 additions & 48 deletions

.pre-commit-config.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.6.0
4+
hooks:
5+
# Git style
6+
- id: check-added-large-files
7+
- id: check-merge-conflict
8+
- id: check-vcs-permalinks
9+
- id: forbid-new-submodules
10+
- id: no-commit-to-branch
11+
12+
# Common errors
13+
- id: end-of-file-fixer
14+
- id: trailing-whitespace
15+
args: [--markdown-linebreak-ext=md]
16+
exclude: CHANGELOG.md
17+
- id: check-yaml
18+
- id: check-merge-conflict
19+
- id: check-executables-have-shebangs
20+
21+
- repo: https://github.com/jumanjihouse/pre-commit-hooks
22+
rev: 3.0.0
23+
hooks:
24+
- id: shfmt
25+
args: ['-l', '-i', '2', '-ci', '-sr', '-w']
26+
- id: shellcheck
27+
- repo: https://github.com/antonbabenko/pre-commit-terraform
28+
rev: v1.96.3
29+
hooks:
30+
- id: terraform_fmt
31+
- id: terraform_docs

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local_team_servers := $(shell vagrant status | grep -E -o 'team[0-9]+')
1+
local_team_servers = $(shell vagrant status | grep -E -o 'team[0-9]+')
22

33
ci:
44
@bash ./scripts/ci.sh
@@ -8,9 +8,11 @@ up-local:
88
@vagrant up --parallel
99

1010
up-aws:
11+
@terraform -chdir=./terraform init
1112
@terraform -chdir=./terraform apply
1213

1314
yeet-aws:
15+
@terraform -chdir=./terraform init
1416
@terraform -chdir=./terraform apply -auto-approve
1517
@printf 'Waiting 30s for EC2 instances to hopefully process userdata...\n' && sleep 30
1618
@make -s provision-aws

instructions/challenge_2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ following:
1818
- Once there, the app there needs to be named `run-app`, not `app`
1919

2020
- To ensure both locations always have the same version (e.g. during hotfixes),
21-
make a reference from the binary location to the target location without
22-
copying the actual file. This way, any update or change will reflect in both
21+
make a reference from the binary location to the target location *without
22+
copying the actual file*. This way, any update or change will reflect in both
2323
places at once without needing to manually sync them.

instructions/challenge_3.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ Create that service, and get it running. You need to make sure it runs *even if
1515
the system reboots* -- meaning that if the server is restarted for any reason,
1616
the app service needs to start again *without you starting it manually*.
1717

18-
If for any reason you need to check out more detailed logs of the service, you
19-
can also use the separate `journalctl` command to inspect them.
18+
If for any reason you need to check out more detailed logs of the service you're
19+
creating, you can also use the separate `journalctl` command to inspect them.

instructions/challenge_4.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ look at the `/opt/app` directory again, you may have noticed that there is a
2424
correctly-installed app binary.
2525

2626
Once you do that, be sure to check the `systemd` and/or `journald` logs of the
27-
new `app-deb.service` to make sure it's running successfully! (and, just like
28-
the last one, that it would keep running after a reboot)
27+
new `app-deb.service` to make sure it's running successfully (and, just like
28+
the last one, that it would keep running after a reboot).

instructions/challenge_6.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dissappeared while on a golfing trip a few weeks past. We were told that the
88
code was about ready to deploy, just hadn't gotten the chance to merge it into
99
the main branch. See if you can figure out how to get it up and running.
1010

11-
The name of the app is 'carrot-cruncher'. The last dev got the repo set up
11+
The name of the app is "carrot-cruncher". The last dev got the repo set up
1212
somewhere on disk, but they never said where... hopefully you'll able to find
1313
it. When you do, supposedly there was a new working branch pushed to the remote
1414
repo, so you'll need to figure out how to authenticate to that repo.

scripts/ci.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ if [[ "$(</tmp/go-modules wc -l)" -gt 0 ]] ; then
2424
printf '> Installing CI checks for Go...\n'
2525
for pkg in \
2626
honnef.co/go/tools/cmd/staticcheck@latest \
27+
github.com/mgechev/revive@latest \
2728
github.com/kisielk/errcheck@latest \
2829
; do
2930
go install "${pkg}"
@@ -39,9 +40,11 @@ while read -r module ; do
3940
cd "${mod_dir}"
4041
printf '>> Running go vet...\n'
4142
go vet ./...
42-
printf '>> Running linter...\n'
43+
printf '>> Running staticcheck linter...\n'
4344
staticcheck ./...
44-
printf '>> Running error checker...\n'
45+
printf '>> Running revive linter...\n'
46+
revive --set_exit_status ./...
47+
printf '>> Running error-checker...\n'
4548
errcheck ./...
4649
)
4750
done < /tmp/go-modules

scripts/linux-workshop-admin.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ _score-for-challenge() {
3535
log-info "Providing instruction to user for Challenge ${next_challenge}"
3636
cp "${wsroot}/instructions/challenge_${next_challenge}.md" /home/appuser/
3737
# Also broadcast message to user when challenge is complete
38-
wall "Congrats on finishing Challenge ${which_challenge}! Be sure to check your home directory for any new instruction files! (hit any key to dismiss this message)"
38+
wall "Congrats on finishing Challenge ${which_challenge}! Be sure to check your home directory for any new instruction files! (hit Enter to dismiss this message)"
3939
else
4040
log-info 'Team is done with the workshop!'
4141
cp "${wsroot}/instructions/congrats.md" /home/appuser/
4242
# This check suppresses an infinite loop of congratulations, lol
4343
if [[ ! -f "${wsroot}"/team_has_been_congratulated ]] ; then
44-
wall "Congratulations -- you have completed ALL CHALLENGES! Be sure to read congrats.md in your home directory! (hit any key to dismiss this message)"
44+
wall "Congratulations -- you have completed ALL CHALLENGES! Be sure to read congrats.md in your home directory! (hit Enter to dismiss this message)"
4545
touch "${wsroot}"/team_has_been_congratulated
4646
fi
4747
fi

scripts/provision-ec2-team-parallelizer.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ log-info "Adding files to Team server ${server_num} at ${server_ip}..."
3232
scp -P 2332 -r -o StrictHostKeyChecking=accept-new ../scripts ../services ../instructions ../dummy-app-src admin@"${server_ip}":/tmp
3333

3434
log-info "Running init on Team server ${server_num} at ${server_ip}..."
35-
ssh -p 2332 admin@"${server_ip}" "export team_name=Team-${server_num} && export db_addr=${db_priv_ip} && sudo -E bash /tmp/scripts/init.sh"
35+
ssh -p 2332 admin@"${server_ip}" "source /tmp/.tfenv && sudo -E bash /tmp/scripts/init.sh"
3636

3737
log-info "Running tests on Team server ${server_num} at ${server_ip}..."
3838
ssh -p 2332 admin@"${server_ip}" "sudo -E bats /.ws/scripts/test.bats"

terraform/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.terraform/
22
*.tfvars
33
*tfstate*
4+
!main.auto.tfvars

0 commit comments

Comments
 (0)