在Azure VM中未设置FQDN

时间:2018-12-13 08:18:13

标签: azure terraform terraform-provider-azure

Terraform版本

Terraform v0.11.10
+ provider.azurerm v1.19.0

Terraform配置文件

resource "azurerm_virtual_machine" "main" {
  name                  = "${var.prefix}-vm"
  location              = "${azurerm_resource_group.main.location}"
  resource_group_name   = "${azurerm_resource_group.main.name}"
  network_interface_ids = ["${azurerm_network_interface.main.id}"]
  vm_size               = "Standard_DS1_v2"

  storage_image_reference {
    publisher = "Canonical"
    offer     = "UbuntuServer"
    sku       = "16.04-LTS"
    version   = "latest"
  }
  storage_os_disk {
    name              = "myosdisk1"
    caching           = "ReadWrite"
    create_option     = "FromImage"
    managed_disk_type = "Standard_LRS"
  }
  os_profile {
    computer_name  = "head01.test.local"
    admin_username = "${var.admin_username}"
    custom_data    = "${file("custom_data.txt")}"
  }
  os_profile_linux_config {
    disable_password_authentication = true
    ssh_keys {
      path     = "/home/${var.admin_username}/.ssh/authorized_keys"
      key_data = "${var.ssh_key_data}"
    } 
  }
  tags {
    environment = "staging"
  }
}

自定义数据文件

#cloud-config
fqdn: head01.test.local

预期行为

它应该设置FQDN,运行hostname -f应该返回完整的FQDN

实际行为

hostname仅返回FQDN head01的第一部分。 hostname --fqdn失败,错误为hostname: Temporary failure in name resolution

其他信息

我也尝试过custom_data方法(现在被评论)。结果相同。

/etc/hosts内容

127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts

::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

/etc/resolv.conf内容

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 10.4.0.5
search reddog.microsoft.com

0 个答案:

没有答案