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

severin.julien
  • 1,314
  • 15
  • 27
  • have you had an issue with packer ssh timeouts? I use almost the same json (except using vbox instead of vmware) and I'm not able to ssh into it. The error: " Build 'virtualbox-iso' errored: ssh: handshake failed: ssh: unable to authenticate, attempted methods [password keyboard-interactive none], no supported methods remain" – Roman Mik Mar 05 '18 at 22:16
  • I have never tried with VirtualBox, can you create a post on StackOverflow so I can help ? I need at least the template.json file. – severin.julien Mar 06 '18 at 09:19
  • thanks. https://stackoverflow.com/questions/49133676/handshake-failed-ssh-unable-to-authenticate-attempted-methods-none-password – Roman Mik Mar 06 '18 at 14:53

1 Answers1

6

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.

severin.julien
  • 1,314
  • 15
  • 27