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

View File

@@ -1,5 +1,4 @@
# Terraform
## Basic Proxmox setup
Add `TerraformProv` role
```sh
@@ -26,15 +25,17 @@ Add environment variable
```sh
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
### OpenTofu
```sh
opentofu.tofu init
opentofu.tofu plan
opentofu.tofu apply
opentofu.tofu destroy
tofu apply -target module.<module-name>
tofu init # initialize module
tofu plan # test configuration
tofu apply # apply configuration
tofu destroy # destroy all vm
tofu apply -target module.<module-name> # apply a specific module
```
### On WSL
@@ -230,18 +231,6 @@ package_update: true
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
```hcl
write_files:
@@ -254,3 +243,42 @@ write_files:
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.