This commit is contained in:
2026-01-20 01:09:06 +01:00
parent e888ea338f
commit 661bb4e074

View File

@@ -1,5 +1,4 @@
# Terraform # Terraform
## Basic Proxmox setup ## Basic Proxmox setup
Add `TerraformProv` role Add `TerraformProv` role
```sh ```sh
@@ -26,15 +25,17 @@ Add environment variable
```sh ```sh
cp terraform.tfvars.example cp terraform.tfvars.example
``` ```
fill with your secrets (do no push this file) > ![NOTE]
> fill with your secrets (do no push this file)
## Usefull commands ## Usefull commands
### OpenTofu
```sh ```sh
opentofu.tofu init tofu init # initialize module
opentofu.tofu plan tofu plan # test configuration
opentofu.tofu apply tofu apply # apply configuration
opentofu.tofu destroy tofu destroy # destroy all vm
tofu apply -target module.<module-name> tofu apply -target module.<module-name> # apply a specific module
``` ```
### On WSL ### On WSL
@@ -230,18 +231,6 @@ package_update: true
package_upgrade: false package_upgrade: false
``` ```
##### Backup setup
```hcl
packages:
- nfs-common
mounts:
- [ "192.168.1.12:/main/backups", "/backups", "nfs", "defaults,_netdev,x-systemd.requires=network-online.target", "0", "0" ]
```
`nfs-common`: NFS mount package for `/main/backups` mount point.
`mounts`: adds NFS mount point to `/etc/fstab` file.
##### Environment variables for scripts ##### Environment variables for scripts
```hcl ```hcl
write_files: write_files:
@@ -253,4 +242,43 @@ write_files:
permissions: "0644" permissions: "0644"
content: | content: |
${env-file-content} ${env-file-content}
``` ```
`.env.example` files are given in each modules describing mandatory variables used by scripts.
##### Backup setup
```hcl
packages:
- nfs-common
mounts:
- [ "192.168.1.12:/main/backups", "/backups", "nfs", "defaults,_netdev,x-systemd.requires=network-online.target", "0", "0" ]
write_files:
- path: /usr/local/bin/restore-backup.sh
permissions: "0755"
content: |
${restore-backup-script}
- path: /etc/systemd/system/restore-backup.service
permissions: "0644"
content: |
${restore-backup-service}
- path: /usr/local/bin/backup.sh
permissions: "0755"
content: |
${create-backup-script}
- path: /etc/systemd/system/create-backup.timer
permissions: "0644"
content: |
${create-backup-timer}
- path: /etc/systemd/system/create-backup.service
permissions: "0644"
content: |
${create-backup-service}
```
- `restore-backup.sh`: Restore backup script (specific per module).
- `restore-backup.service`: Restore backup `systemd` service (common for all modules).
- `create-backup.service`: Create backup `systemd` service (common for all modules).
- `create-backup.timer`: Create backup `systemd` timer (common for all modules).
- `nfs-common`: NFS mount package for `/main/backups` mount point.
- `mounts`: adds NFS mount point to `/etc/fstab` file.