gpt4 book ai didi

packer - 使用 Packer 构建 RancherOS 时 SSH 失败

转载 作者:行者123 更新时间:2023-12-02 07:01:24 26 4
gpt4 key购买 nike

我对 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"
]
}
]
}

旁边有一个仅包含我的 SSH key 的 cloud-config.yml

#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.

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

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

致以诚挚的问候

最佳答案

我找到了解决办法

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

因此在生成期间不会进行重新启动。

关于packer - 使用 Packer 构建 RancherOS 时 SSH 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38606092/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com