I'm setting my hostname using a cloud-init file which has this,

hostname: "${hostname}"
fqdn: "${fqdn}"

This sets the hostname and fqdn to the results of the DHCP setting on a port,

data "template_file" "user_data" {
  template = templatefile(
      hostname = openstack_networking_port_v2.port_company.dns_assignment[0].hostname
      fqdn     = openstack_networking_port_v2.port_company.dns_assignment[0].fqdn

The problem here is that while this works the first time, the second time it ends up doing this,

Changes to Outputs:
  ~ fqdn         = "host-10-2-68-89.openstack.build." -> "test-server.openstack.build."
  ~ hostname     = "host-10-2-68-89" -> "test-server"
  ~ instance_ips = "" -> (known after apply)

How can I properly set my hostname with cloud-init using Terraform?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.