SSH failed when building RancherOS with Packer

百般思念 提交于 2019-12-07 10:22:21

问题


I have an issue with Packer and RancherOS. I'm trying to build a custom rancherOS image with a cloud-config file. I'm working on MacOSX.

I have this build.json file

{
    "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"
            ]
        }
    ]
}

Along side I have a cloud-config.yml containing only my SSH key

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

When I launch the building command packer build build.json

I get

    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.

If I understand correctly. My script is working but when the VM reboot, the new SSH key is not working.

I don't know how to solve this. Maybe someone would help me.

Best regards


回答1:


I found a solution

Just add a -no-reboot flag on the sudo ros install -d /dev/sda -f -t generic -c /tmp/cloud-config.yml command do the trick.

So no reboot will be done during the generation.



来源:https://stackoverflow.com/questions/38606092/ssh-failed-when-building-rancheros-with-packer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!