4

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

4

1 回答 1

6

我找到了解决方案

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

所以在生成期间不会重新启动。

于 2016-08-01T15:30:28.090 回答