【问题标题】:SSH failed when building RancherOS with Packer使用 Packer 构建 RancherOS 时 SSH 失败
【发布时间】:2016-12-01 01:24:37
【问题描述】:

我对 Packer 和 RancherOS 有疑问。我正在尝试使用 cloud-config 文件构建自定义 rancherOS 映像。 我正在使用 MacOSX。

我有这个build.json 文件

{
    "variables": {
        "vm_name" : ""
    },
    "builders": [
        {
            "type": "vmware-iso",
            "iso_url": "rancheros.iso",
            "guest_os_type": "other",
            "iso_checksum_type": "md5",
            "iso_checksum": "467caa8394684ba54e8731aed8480652",
            "output_directory": "output_rancheros",
            "ssh_wait_timeout": "30s",
            "shutdown_command": "sudo shutdown -h now",
            "disk_size": 20000,
            "ssh_username": "rancher",
            "ssh_password": "rancher",
            "ssh_port": 22,
            "ssh_wait_timeout": "90m",
            "vm_name": "{{ user `vm_name` }}",
            "boot_wait": "10s",
            "vmx_data": {
                "memsize": "4096"
            }
        }
    ],
    "provisioners": [
        {
            "type":"file",
            "source": "cloud-config.yml",
            "destination": "/tmp/cloud-config.yml"
        },
        {
            "type": "shell",
            "inline": [
                "sudo ros install -d /dev/sda -f -t generic -c /tmp/cloud-config.yml"
            ]
        }
    ]
}

我还有一个 cloud-config.yml 只包含我的 SSH 密钥

#cloud-config
ssh_authorized_keys:
    - ssh-rsa AAAA....d admin@example.com

当我启动构建命令packer build build.json

我明白了

    vmware-iso: + umount /mnt/new_img
    vmware-iso: time="2016-07-27T05:52:35Z" level=fatal msg=EOF
    vmware-iso: Continue with reboot [y/N]:
==> vmware-iso: Stopping virtual machine...
==> vmware-iso: Deleting output directory...
Build 'vmware-iso' errored: Script exited with non-zero exit status: 1

==> Some builds didn't complete successfully and had errors:
--> vmware-iso: Script exited with non-zero exit status: 1

==> Builds finished but no artifacts were created.

如果我理解正确的话。我的脚本正在运行,但是当 VM 重新启动时,新的 SSH 密钥不起作用。

我不知道如何解决这个问题。也许有人会帮助我。

最好的问候

【问题讨论】:

  • 您遇到过打包器 ssh 超时的问题吗?我使用几乎相同的 json(除了使用 vbox 而不是 vmware)并且我无法通过 ssh 进入它。错误:“构建'virtualbox-iso'错误:ssh:握手失败:ssh:无法验证,尝试的方法[密码键盘交互式无],没有支持的方法”
  • 我从未尝试过使用 VirtualBox,您可以在 StackOverflow 上创建一个帖子以便我提供帮助吗?我至少需要 template.json 文件。

标签: packer rancher


【解决方案1】:

我找到了解决办法

只需在sudo ros install -d /dev/sda -f -t generic -c /tmp/cloud-config.yml 命令上添加-no-reboot 标志即可。

所以在生成过程中不会重新启动。

【讨论】:

    猜你喜欢
    • 2019-07-30
    • 2021-09-06
    • 1970-01-01
    • 1970-01-01
    • 2020-12-28
    • 2022-06-21
    • 1970-01-01
    • 2018-10-13
    • 1970-01-01
    相关资源
    最近更新 更多