Skip to content

Commit a1dbb1b

Browse files
committed
docs: decal infra
1 parent f957ebb commit a1dbb1b

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
title: Decal Terraform
3+
---
4+
5+
# Decal VMs Terraform Infrastructure
6+
7+
Our decal VMs are provisioned through Terraform. You'll need to be root to run terraform. If you are the current decal head facilitor, talk to SM. If they approve, they should make sure your ssh key is added to the root user on implosion (edit `~root/.ssh/authorized_keys` on implosion).
8+
9+
All commands should be run under `implosion:~root/terraform`. Make sure to read the following documentation thoroughly.
10+
11+
new plan:
12+
we have one input csv file with (username, email)
13+
have terraform transform the csv file, generate the passwords, and write it to an output csv
14+
15+
## Common Commands
16+
Display the plan of changes that will be taken:
17+
```sh
18+
terraform plan
19+
```
20+
21+
Apply the proposed changes to the infrastructure:
22+
```sh
23+
terraform apply
24+
```
25+
26+
Recreate the VM for user waddles:
27+
```sh
28+
./scripts/wipe_vm.sh waddles
29+
```
30+
31+
Reset the VM password for user waddles:
32+
```sh
33+
./scripts/reset_password.sh waddles
34+
```
35+
36+
## Getting Started
37+
Make sure to create a `terraform.tfvars` file using the `terraform.tfvars.example` provided.
38+
39+
Get (or generate) a root SSH key for the VMs and place it in `../data/decal_root` and `../data/decal_root.pub`. This will allow you to access all student VMs in case a password reset or interactive debugging is required.
40+
41+
Create `../data/students.in.csv` which contains the OCF username and email for each student to create a VM for:
42+
```csv
43+
username,email
44+
45+
```
46+
47+
You can then use that to create `../data/students.csv`, which defines the VMs that terraform will provision:
48+
```sh
49+
python3 ../transform_students_csv.py
50+
```
51+
52+
Run the following command to ensure everything is okay:
53+
```sh
54+
terraform plan
55+
```
56+
57+
Then hit the apply:
58+
```sh
59+
terraform apply
60+
```
61+
If you get an error about not finding a cloud-init iso, this is because of a bug in the libvirt provider. Just run `terraform apply` again and it'll figure itself out. (https://github.com/dmacvicar/terraform-provider-libvirt/issues/973)
62+
If you get random errors about resources already existing, destroy it all with `terraform destroy -target libvirt_domain.decalvm -target libvirt_volume.decalvm_volume -target libvirt_cloudinit_disk.decalvm_init -target dns_a_record_set.decalvm_arecord -target dns_aaaa_record_set.decalvm_aaaarecord` and run it again single-threaded `terraform apply -parallelism=1`.
63+
64+
Once all the VMs have been created, you can send the students their login information:
65+
```sh
66+
python3 ../send_vms.py
67+
```
68+
69+
## Other Commands
70+
71+
To reboot all VMs:
72+
```sh
73+
python3 ./scripts/reboot_all.py
74+
```
75+
76+
To reboot a VM:
77+
```sh
78+
./scripts/reboot.sh <ocfusername>
79+
```
80+
81+
To wipe a VM:
82+
```sh
83+
./scripts/wipe_vm.sh <ocfusername>
84+
```
85+
86+
## Other Information
87+
88+
If you need to destroy all VMs at the end of the semester, just clear out the entire `../data/students.csv` except for the header line and run `terraform apply`.
89+
90+
If you migrate the location of the storage pool, make sure it's added to apparmor in `/etc/apparmor.d/local/abstractions/libvirt-qemu` otherwise you'll get permissions errors.
91+
92+

0 commit comments

Comments
 (0)