move random_pet to host module

This commit is contained in:
phaer
2022-03-05 15:25:43 +01:00
parent 3337a6a4f5
commit d08a350362
4 changed files with 27 additions and 14 deletions

View File

@@ -1,5 +1,25 @@
resource "random_pet" "server" {
length = 1
keepers = {
# We re-create the id (and server) whenever one of those attributes
# changes. This should include all input variables to this module,
# but NO SENSITIVE values as they might be logged here.
name = var.name
public_key = var.public_key
additional_public_keys = join(",", var.additional_public_keys)
ssh_keys = join(",", var.ssh_keys)
firewall_ids = join(",", var.firewall_ids)
placement_group_id = var.placement_group_id
labels = join(",", [for k, v in var.labels: "${k}=${v}" ])
location = var.location
ipv4_subnet_id = var.ipv4_subnet_id
private_ipv4 = var.private_ipv4
server_type = var.server_type
}
}
resource "hcloud_server" "server" {
name = var.name
name = local.name
image = "ubuntu-20.04"
rescue = "linux64"
@@ -90,7 +110,7 @@ data "template_cloudinit_config" "config" {
content = templatefile(
"${path.module}/templates/userdata.yaml.tpl",
{
hostname = var.name
hostname = local.name
sshAuthorizedKeys = concat([local.ssh_public_key], var.additional_public_keys)
}
)