Skip to content

Commit

Permalink
remove serials from instances (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
glitchcrab committed Aug 6, 2023
1 parent d955d24 commit a45ebd9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Enable HA masters (3).
- Bump `glitchcrab/terraform-module-proxmox-instance` to 1.6.0
- Do not power on nodes after creation.
- Remove serials from instances.

## [0.1.0] - 2022-12-19

Expand Down
24 changes: 4 additions & 20 deletions cluster/resources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,14 @@ resource "macaddress" "master_net0_mac" {
count = local.master_count
}

resource "random_string" "master_serial" {
count = local.master_count

length = 16
special = false
upper = false
}

module "master_instances" {
count = local.master_count
depends_on = [local_file.set_smbios_values]

source = "github.com/glitchcrab/terraform-module-proxmox-instance?ref=v1.8.0"

pve_instance_name = "master${count.index}-${local.name_stub}"
pve_instance_description = "${local.master_description} (serial: ${random_string.master_serial[count.index].result})"
pve_instance_description = "${local.master_description} (UUID: ${local.master_placement[count.index].uuid})"
vmid = lookup(local.master_placement[count.index], "vmid")

target_node = lookup(local.master_placement[count.index], "host")
Expand Down Expand Up @@ -68,7 +60,7 @@ resource "null_resource" "set_master_smbios_values" {
depends_on = [module.master_instances]

provisioner "local-exec" {
command = "/usr/bin/env bash scripts/set_smbios_values.sh ${replace(local.pve_token_id, "!", "'!'")} ${local.pve_token} ${local.master_placement[count.index].host} ${local.master_placement[count.index].vmid} ${local.master_sku} ${random_string.master_serial[count.index].result} ${local.master_placement[count.index].uuid}"
command = "/usr/bin/env bash scripts/set_smbios_values.sh ${replace(local.pve_token_id, "!", "'!'")} ${local.pve_token} ${local.master_placement[count.index].host} ${local.master_placement[count.index].vmid} ${local.master_sku} ${local.master_placement[count.index].uuid}"
}

lifecycle {
Expand All @@ -80,22 +72,14 @@ resource "macaddress" "worker_net0_mac" {
count = local.worker_count
}

resource "random_string" "worker_serial" {
count = local.worker_count

length = 16
special = false
upper = false
}

module "worker_instances" {
count = local.worker_count
depends_on = [local_file.set_smbios_values]

source = "github.com/glitchcrab/terraform-module-proxmox-instance?ref=v1.8.0"

pve_instance_name = "worker${count.index}-${local.name_stub}"
pve_instance_description = "${local.worker_description} (serial: ${random_string.worker_serial[count.index].result})"
pve_instance_description = "${local.worker_description} (UUID: ${local.worker_placement[count.index].uuid})"
vmid = lookup(local.worker_placement[count.index], "vmid")

target_node = lookup(local.worker_placement[count.index], "host")
Expand Down Expand Up @@ -134,7 +118,7 @@ resource "null_resource" "set_worker_smbios_values" {
depends_on = [module.worker_instances]

provisioner "local-exec" {
command = "/usr/bin/env bash scripts/set_smbios_values.sh ${replace(local.pve_token_id, "!", "'!'")} ${local.pve_token} ${local.worker_placement[count.index].host} ${local.worker_placement[count.index].vmid} ${local.worker_sku} ${random_string.worker_serial[count.index].result} ${local.worker_placement[count.index].uuid}"
command = "/usr/bin/env bash scripts/set_smbios_values.sh ${replace(local.pve_token_id, "!", "'!'")} ${local.pve_token} ${local.worker_placement[count.index].host} ${local.worker_placement[count.index].vmid} ${local.worker_sku} ${local.worker_placement[count.index].uuid}"
}

lifecycle {
Expand Down
3 changes: 1 addition & 2 deletions cluster/templates/set_smbios_values.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pve_token="$${2}"
host="$${3}"
vmid="$${4}"
role="$${5}"
serial="$${6}"
uuid="$${7}"

if [[ "$${role}" == "master" ]]; then
Expand Down Expand Up @@ -37,7 +36,7 @@ done
curl --silent --insecure -H \
"Authorization: PVEAPIToken=$${pve_token_id}=$${pve_token}" \
-X POST --data-urlencode \
smbios1="serial=$${serial},family=${family},sku=$${sku},uuid=$${uuid}" \
smbios1="family=${family},sku=$${sku},uuid=$${uuid}" \
${pm_api_url}/nodes/$${host}/qemu/$${vmid}/config
_ret=$?

Expand Down
4 changes: 0 additions & 4 deletions cluster/zz_versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ terraform {
source = "Telmate/proxmox"
version = "~> 2.9.14"
}
random = {
source = "hashicorp/random"
version = "~> 3.4.3"
}
time = {
source = "hashicorp/time"
version = "0.9.1"
Expand Down

0 comments on commit a45ebd9

Please sign in to comment.