简体   繁体   中英

Can a Packer script change an output image built from an ISO?

I'm trying to use Packer to build a Vagrant box from an ISO , using a boot2docker ISO . All goes well until I try to run vagrant up, which fails with "Error: Authentication failure. Retrying...". The box is OK - I can get in with vagrant ssh by supplying a password. But ssh authentication doesn't work.

This turns out to be a known problem with a known solution - add a public key to .ssh/authorized_keys on the box. If I do this manually after I've accessed the box with a password, I don't need the password for future access. So I updated my Packer script to do that - and found that changes made to the boot volume are discarded without effect. Packer script changes to other volumes work, but not to the boot volume, which is the one I need to update. It looks like it can only ever be an image of the ISO.

Is my only option to create my own ISO with the public key preinstalled? Is there any way to use Packer to apply the key to the output box?

This is an old question but since there's no answer, I'll contribute.

I was having the same problem; no matter what I changed in my Kickstart or provisioner scripts, my changes to the vagrant user's authorized_keys were not visible in the final box as built by Packer. Until I realized that Vagrant kept using a cached (and older!) version of my Vagrant box built instead of the latest one.

The reason is that the box was copied once by Vagrant as "my-box", and even if the box itself was changing as I was testing fixes for this, Vagrant kept using the old one without my fixes because it caches it, and does not frequently check for updates. The easiest solution is to add

config.vm.box_check_update = true

to your Vagrantfile. Alternatively, you could have your Vagrantfile give a different name to your box every time in config.vm.box via some Ruby code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM