Skip to content

Commit

Permalink
tf(vsphere-vm): fix fqdn not set properly in ubuntu images
Browse files Browse the repository at this point in the history
  • Loading branch information
giovannibaratta committed Jan 16, 2024
1 parent eee7042 commit 44f5e6d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#cloud-config

hostname: ${hostname}
fqdn: ${fqdn}
prefer_fqdn_over_hostname: true

ssh_pwauth: false

Expand Down
2 changes: 1 addition & 1 deletion terraform/modules/vsphere-vm/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.2
0.0.3
3 changes: 3 additions & 0 deletions terraform/modules/vsphere-vm/vm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ resource "random_password" "vm_root_user" {
}

locals {
hostname = split(".", var.fqdn)[0]

# Fallback to a random generated password if the user didn't provide one
root_password = coalesce(var.root_password, random_password.vm_root_user.result)

# User data rendered using the Terraform provider produce an invalid configuration
# See https://github.com/hashicorp/terraform-provider-cloudinit/issues/165
default_user_data = templatefile("${path.module}/files/default-cloud-config.yml.tftpl", {
hostname: local.hostname
fqdn : var.fqdn
root_password : local.root_password
authorized_key : var.vm_authorized_key
Expand Down

0 comments on commit 44f5e6d

Please sign in to comment.