|
2 | 2 |
|
3 | 3 | Configuration for all VMs / Containers running on nerdserv using Terraform
|
4 | 4 |
|
5 |
| -## Prerequisites |
6 |
| - |
7 |
| -### Terraform |
8 |
| - |
9 |
| -We recommend using the |
10 |
| -[Terraform version manager](https://github.com/tfutils/tfenv) to install the |
11 |
| -correct version of `terraform` for this project. |
12 |
| - |
13 |
| -```bash |
14 |
| -tfenv install |
15 |
| -``` |
16 |
| - |
17 |
| -### Encryption Key |
18 |
| - |
19 |
| -You will need the team’s `age` encryption key to run the encryption and |
20 |
| -decryption steps for the Terraform state files. |
21 |
| - |
22 |
| -## Usage |
23 |
| - |
24 |
| -The [proxmox provider](https://registry.terraform.io/providers/Telmate/proxmox/latest/docs) |
25 |
| -allows Terraform to provision proxmox VMs and LXC containers through proxmox's API. |
26 |
| - |
27 |
| -### Work with the Config |
28 |
| - |
29 |
| -1. If you have not done so, initialize Terraform by running |
30 |
| - `terraform init`. |
31 |
| - |
32 |
| -2. Validate the config BEFORE committing. |
33 |
| - |
34 |
| - ```bash |
35 |
| - terraform validate |
36 |
| - ``` |
37 |
| - |
38 |
| -3. Format the Terraform config files BEFORE committing. |
39 |
| - |
40 |
| - ```bash |
41 |
| - make format |
42 |
| - ``` |
43 |
| - |
44 |
| -4. Commit the changes and create a pull request, Terraform cloud should pick it |
45 |
| - up and create a plan. |
46 |
| - |
47 |
| -5. Merge the pull request, everything will get applied to |
| 5 | +## How to get a (debian) VM |
| 6 | + |
| 7 | +1. Add your ssh key to `locals.tf` in the root of the directory. |
| 8 | + ```tf |
| 9 | + locals { |
| 10 | + users = { |
| 11 | + // ... snip ... |
| 12 | + your_membername = { |
| 13 | + ssh_key = "your ssh-key here" |
| 14 | + } |
| 15 | + } |
| 16 | + // ... snip ... |
| 17 | + } |
| 18 | + ``` |
| 19 | +2. Create a new file in the `proxmox` directory named `{your_vm_name}.tf` |
| 20 | + ```tf |
| 21 | + module "<your_vm_name>_vm" { |
| 22 | + source = "../modules/vm" |
| 23 | + node = var.node |
| 24 | + pool = var.pool |
| 25 | +
|
| 26 | + name = "docker" |
| 27 | + vm_id = "<this needs to be the next free vm_id>" |
| 28 | +
|
| 29 | + clone = data.proxmox_virtual_environment_vm.debian_cloud_vm_template.vm_id |
| 30 | +
|
| 31 | + cores = <how many (virtual) cores you need> |
| 32 | + memory = <how much memory you need in MB> |
| 33 | +
|
| 34 | + disk = { |
| 35 | + // gigabytes |
| 36 | + size = <how much storage you need in GB> |
| 37 | + storage = var.storage.disk |
| 38 | + } |
| 39 | +
|
| 40 | + network = { |
| 41 | + bridge = var.network.bridge |
| 42 | + internal_bridge = proxmox_virtual_environment_network_linux_bridge.internal_bridge.name |
| 43 | + } |
| 44 | +
|
| 45 | + admins = [ |
| 46 | + local.users["your_membername"] |
| 47 | + ] |
| 48 | + } |
| 49 | + ``` |
0 commit comments