代码之家  ›  专栏  ›  技术社区  ›  shashwat

在azure vm中未设置fqdn

  •  0
  • shashwat  · 技术社区  · 7 年前

    地形版

    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 回复  |  直到 7 年前
    推荐文章