简体   繁体   English

Packer脚本可以更改从ISO构建的输出映像吗?

[英]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 . 我正在尝试使用Packer使用boot2docker ISO 从ISO构建Vagrant框 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. 这个盒子还行-我可以通过提供密码来使用vagrant ssh。 But ssh authentication doesn't work. 但是ssh身份验证不起作用。

This turns out to be a known problem with a known solution - add a public key to .ssh/authorized_keys on the box. 事实证明这是已知解决方案的已知问题-在包装盒上的.ssh / authorized_keys中添加公共密钥。 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脚本以执行此操作-并发现对引导卷所做的更改被丢弃而没有任何效果。 Packer script changes to other volumes work, but not to the boot volume, which is the one I need to update. Packer脚本对其他卷的工作有所更改,但对引导卷却没有更改,这是我需要更新的内容。 It looks like it can only ever be an image of the ISO. 看起来它只能是ISO的映像。

Is my only option to create my own ISO with the public key preinstalled? 我唯一的选择是使用预安装的公钥创建自己的ISO吗? Is there any way to use Packer to apply the key to the output box? 有什么方法可以使用Packer将密钥应用于输出盒吗?

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. 无论我在Kickstart脚本或预配器脚本中进行了什么更改,我对无业游民用户的authorized_key的更改在Packer构建的最后一个框中都不可见。 Until I realized that Vagrant kept using a cached (and older!) version of my Vagrant box built instead of the latest one. 直到我意识到Vagrant一​​直使用所构建的Vagrant盒的缓存(和更旧!)版本而不是最新版本。

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. 原因是该盒子被Vagrant复制了一次,称为“我的盒子”,即使在我测试此修复程序时盒子本身发生了变化,Vagrant仍然使用没有我的修复程序的旧版本,因为它缓存了它,并且确实不经常检查更新。 The easiest solution is to add 最简单的解决方案是添加

config.vm.box_check_update = true

to your Vagrantfile. 到您的Vagrantfile。 Alternatively, you could have your Vagrantfile give a different name to your box every time in config.vm.box via some Ruby code. 另外,您也可以通过一些Ruby代码让您的Vagrantfile每次在config.vm.box为框指定一个不同的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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