如何使用无人值守Ubuntu安装(14.04)进行“select并安装软件”问题

我正在使用Packer为Ubuntu 14.04构build一个VirtualBox图像。 我在这里有一个Packer脚本,它曾经工作,但由于某种原因(以后有几个VirtualBox更新)开始失败。 安装一直卡在“select和安装软件”步骤:

在这里输入图像说明

如果我使用-debug选项运行脚本,我不会从Packer本身获得任何有用的信息:

 ~/Projects/src/github.com/yunojuno/trifecta/packer(master)$ SSH_USERNAME=vagrant SSH_PASSWORD=vagrant packer build -debug template.json Debug mode enabled. Builds will not be parallelized. virtualbox-iso output will be in this color. ==> virtualbox-iso: Downloading or copying Guest additions virtualbox-iso: Downloading or copying: file:///Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso ==> virtualbox-iso: Pausing after run of step 'StepDownloadGuestAdditions'. Press enter to continue. ==> virtualbox-iso: Downloading or copying ISO virtualbox-iso: Downloading or copying: http://releases.ubuntu.com/14.04/ubuntu-14.04.3-server-amd64.iso ==> virtualbox-iso: Pausing after run of step 'StepDownload'. Press enter to continue. ==> virtualbox-iso: Pausing after run of step 'StepOutputDir'. Press enter to continue. ==> virtualbox-iso: Pausing after run of step 'StepCreateFloppy'. Press enter to continue. ==> virtualbox-iso: Starting HTTP server on port 8532 ==> virtualbox-iso: Pausing after run of step 'StepHTTPServer'. Press enter to continue. ==> virtualbox-iso: Pausing after run of step 'StepSuppressMessages'. Press enter to continue. ==> virtualbox-iso: Creating virtual machine... ==> virtualbox-iso: Pausing after run of step 'stepCreateVM'. Press enter to continue. ==> virtualbox-iso: Creating hard drive... ==> virtualbox-iso: Pausing after run of step 'stepCreateDisk'. Press enter to continue. ==> virtualbox-iso: Pausing after run of step 'stepAttachISO'. Press enter to continue. ==> virtualbox-iso: Pausing after run of step 'StepAttachGuestAdditions'. Press enter to continue. ==> virtualbox-iso: Pausing after run of step 'StepAttachFloppy'. Press enter to continue. ==> virtualbox-iso: Creating forwarded port mapping for SSH (host port 4141) ==> virtualbox-iso: Pausing after run of step 'StepForwardSSH'. Press enter to continue. ==> virtualbox-iso: Executing custom VBoxManage commands... virtualbox-iso: Executing: modifyvm ubuntu1404 --memory 4096 virtualbox-iso: Executing: modifyvm ubuntu1404 --cpus 1 ==> virtualbox-iso: Pausing after run of step 'StepVBoxManage'. Press enter to continue. ==> virtualbox-iso: Starting the virtual machine... ==> virtualbox-iso: Waiting 10s for boot... ==> virtualbox-iso: Pausing after run of step 'StepRun'. Press enter to continue. ==> virtualbox-iso: Typing the boot command... ==> virtualbox-iso: Pausing after run of step 'StepTypeBootCommand'. Press enter to continue. ==> virtualbox-iso: Waiting for SSH to become available... 

脚本只是在这一点挂起 – 无人参与的安装失败(见上面的截图)。

引导命令是:

 "boot_command": [ "<esc><esc><enter><wait>", "/install/vmlinuz ", "noapic ", "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg auto ", "locale=en_US ", "kbd-chooser/method=us ", "keyboard-configuration/modelcode=pc105 ", "keyboard-configuration/layout=US ", "keyboard-configuration/variant=US ", "hostname={{ .Name }} ", "fb=false ", "debconf/frontend=noninteractive ", "console-setup/ask_detect=false ", "initrd=/install/initrd.gz -- ", "<enter>" ], 

我不太了解Linux安装来debugging这个 – 我怎么知道什么是真正的失败,并解决它?

我没有看到任何原因与包装模板的这个问题,并preseed你有Github目前回购。

我能够build立该模板,并得到一个工作的Linux安装。

你应该看到的是预装的pkgsel行,因为当你要求安装程序安装一个不存在的软件包(在configuration的软件仓库中)的时候,你并没有进入交互式安装模式, 。

预先设定的function是超级强大的,你基本上可以做任何安装。 debugging可能是非常不透明的,但是使用Packer,一旦安装完成,我们也会放入debugging器。

在这种情况下,它是shell脚本, https://github.com/yunojuno/trifecta/blob/master/packer/template.json#L61-L66

我build议保持preseed超级基本,并在您的供应商下面做定制,创build一个新的shell脚本来添加新的软件包,做你想要的其他定制到图像 – 甚至删除预先安装的东西。

进入configuration阶段后,您可以使用Packer中的-debug开关,以更切实的方式进行debugging,因为configuration程序是通过正在运行的已安装虚拟机上的ssh连接运行的shell脚本(如果遇到您也可以连接到该ssh或通过Virtualbox GUI进行连接,并在清理之前debugging正在运行的计算机。

Bento项目有很好的Packer模板,你可能想用它作为参考 – https://github.com/chef/bento/blob/master/ubuntu-14.04-amd64.json和https://github.com/chef/bento /blob/master/http/ubuntu-14.04/preseed.cfg – 他们由厨师创build和维护,但厨师没有实际安装,他们基本上是一个香草stream浪者箱子。

基本上 – 目前您的包装名称是preseed中的一个是假的。

我希望这有帮助!

编辑:

我认为定义一些术语可能会有所帮助:

派克 HashiCorp软件,自动化图像的build设。 基本工作stream程是Builder – > Provisioner – > Post Process

  • 生成器 :针对不同的虚拟化平台,例如Virtualbox,Vmware,AWS EC2,Digital Ocean等。每个平台都有不同的图像格式,因此我们需要为每个平台生成一个图像。
    build设者通常使用正在安装无人值守自动化工具的操作系统来提供一致的基础,例如Debian / Ubuntu 预置 ,RHEL / Centos Kickstart等。

  • 提供者 :Shell,Ansible,Chef,Salt,Puppet等。这些运行在所有已安装的基本映像上,并且用于configuration,安装软件等。

  • 后处理器 :stream浪汉,阿特拉斯,亚马逊等。让你的形象准备好它的部署目标。

(在Packer中有几个可选的工作stream程步骤,但这些是基础知识。)

除了@rjocoleman的很好的回答之外,还有一种方法可以从正在运行的安装程序中访问/ var / log / syslog。 您可以使用主菜单中的“保存debugging日志”来提取它。 这有助于在绝对必要时debugging工作stream的Builder部分。