Debian 启动打包程序创建DigitalOcean映像时未设置主机名

Debian 启动打包程序创建DigitalOcean映像时未设置主机名,debian,vagrant,digital-ocean,packer,Debian,Vagrant,Digital Ocean,Packer,我有一个非常简单的配置,可以从DigitalOcean的Debian 8映像生成一个映像: { "builders": [ { "type": "digitalocean", "image": "debian-8-x64", "region": "nyc3", "size": "512mb", "snapshot_name": "debian-8-x64-with-sudo-{{timestamp}}" } ],

我有一个非常简单的配置,可以从DigitalOcean的Debian 8映像生成一个映像:

{
  "builders": [
    {
      "type": "digitalocean",
      "image": "debian-8-x64",
      "region": "nyc3",
      "size": "512mb",
      "snapshot_name": "debian-8-x64-with-sudo-{{timestamp}}"
    }
  ],
  "provisioners": [
    {
      "type": "shell",
      "inline": [
        "apt-get update",
        "apt-get install -y sudo"
      ]
    }
  ]
}
启动实例时,运行
hostname
提供:

封隔器-5694292c-afbf-6df6-06e2-304624c76287

运行
hostname-f
会导致此错误消息:

hostname:名称或服务未知

但是,查看
/etc/hosts
/etc/hostname
显示服务器应该具有我在
文件中指定的主机名:

macmini-test-ae179a2c3b6a274e1c024fa3aee47b99cb234f5967a7c50b4db47119f4e1fda5


如何修复
hostname-f
错误以消除FQDN错误?我也不知道系统上的
packer-5694292c-afbf-6df6-06e2-304624c76287
主机名在哪里。我知道packer在构建过程中使用了这一点,但我不确定它现在在系统上的位置。

Vagrant可能正在填充/etc/hostname和/etc/hosts文件,但需要运行hostname-s,以便在框运行后实际设置它:

root@vagrant-ubuntu-trusty-64:~# echo coolhostyo > /etc/hostname
root@vagrant-ubuntu-trusty-64:~# hostname
vagrant-ubuntu-trusty-64
root@vagrant-ubuntu-trusty-64:~#

我的主机名无效,因为它太长。引用维基百科:

每个标签的长度必须介于1到63个字符之间