Add hetzner storage box to terraform and immich
This commit is contained in:
parent
400b342ec4
commit
0a6ac9b168
13 changed files with 210 additions and 77 deletions
|
|
@ -97,3 +97,57 @@ resource "hcloud_firewall" "nodes_services" {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#########################
|
||||
### Storage Box Setup ###
|
||||
#########################
|
||||
|
||||
resource "random_password" "hcloud_storage_box_password" {
|
||||
length = 32
|
||||
override_special = "-_+="
|
||||
min_lower = 4
|
||||
min_numeric = 4
|
||||
min_special = 4
|
||||
min_upper = 4
|
||||
}
|
||||
|
||||
resource "hcloud_storage_box" "box01" {
|
||||
name = "box01"
|
||||
storage_box_type = "bx11"
|
||||
location = "fsn1"
|
||||
password = random_password.hcloud_storage_box_password.result
|
||||
|
||||
access_settings = {
|
||||
reachable_externally = true
|
||||
samba_enabled = false
|
||||
ssh_enabled = false
|
||||
webdav_enabled = false
|
||||
zfs_enabled = true
|
||||
}
|
||||
|
||||
delete_protection = true
|
||||
}
|
||||
|
||||
resource "random_password" "hcloud_storage_box_sub_passwords" {
|
||||
for_each = local.services_storage_box
|
||||
length = 32
|
||||
override_special = "-_+"
|
||||
min_lower = 4
|
||||
min_numeric = 4
|
||||
min_special = 4
|
||||
min_upper = 4
|
||||
}
|
||||
|
||||
resource "hcloud_storage_box_subaccount" "service_accounts" {
|
||||
for_each = local.services_storage_box
|
||||
storage_box_id = hcloud_storage_box.box01.id
|
||||
home_directory = "${each.key}/"
|
||||
password = random_password.hcloud_storage_box_sub_passwords[each.key].result
|
||||
|
||||
access_settings = {
|
||||
reachable_externally = true
|
||||
webdav_enabled = true
|
||||
}
|
||||
|
||||
description = each.key
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ terraform {
|
|||
}
|
||||
hcloud = {
|
||||
source = "hetznercloud/hcloud"
|
||||
version = "~> 1.45.0"
|
||||
version = "~> 1.57.0"
|
||||
}
|
||||
healthchecksio = {
|
||||
source = "kristofferahl/healthchecksio"
|
||||
|
|
@ -33,4 +33,6 @@ locals {
|
|||
buckets_s3 = merge([for key, val in local.services_s3 : {for bucket in val : bucket => key}]...)
|
||||
|
||||
hetzner_hosts = {for key, val in var.hosts : key => val if val.provider == "hetzner"}
|
||||
|
||||
services_storage_box = {for key, val in var.services : key => val if val.storage_box}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,17 @@ output "hosts" {
|
|||
}
|
||||
}
|
||||
|
||||
output "hcloud_storage_box_accounts" {
|
||||
value = {
|
||||
for key, value in hcloud_storage_box_subaccount.service_accounts : key => {
|
||||
host = value.server
|
||||
user = value.username
|
||||
pass = value.password
|
||||
}
|
||||
}
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "healthchecksio" {
|
||||
value = {
|
||||
backup = {
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ variable "services" {
|
|||
s3 = optional(string)
|
||||
s3_buckets = optional(list(string))
|
||||
database = bool
|
||||
storage_box = optional(bool, false)
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue