Terraform v0.11.10
+ provider.azurerm v1.19.0
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