地形版本
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