带有打包程序的可能的配置流浪汉

问题描述 投票:0回答:1

我想在打包程序脚本中添加软件包(例如:apache2),以创建包含已安装的apache2服务器的Vagrant(virtualbox-iso)。

为此,我使用可以正常运行的示例项目(但没有我的软件包apache2): Vagrant Ubuntu的Packer项目

我只是在base.sh脚本中添加了2条命令

  • DEBIAN_FRONTEND=noninteractive
  • apt-get -y install apache2

构建打包程序正确运行,而Vagrant也正确运行,但是当使用ssh输入vagrant时,我始终找不到apache2安装

但是,构建日志告诉我apache2软件包已正确安装。 为此,团队包装工不想帮助我,因为她认为这是一个流浪汉的问题,而不是包装工

日志

    2016/01/09 17:43:07 ui:     virtualbox-iso: The following extra packages will be installed:
2016/01/09 17:43:07 ui:     virtualbox-iso: apache2-bin apache2-data libapr1 libaprutil1 libaprutil1-dbd-sqlite3
2016/01/09 17:43:07 ui:     virtualbox-iso: libaprutil1-ldap ssl-cert
2016/01/09 17:43:07 ui:     virtualbox-iso: Suggested packages:
2016/01/09 17:43:07 ui:     virtualbox-iso: www-browser apache2-doc apache2-suexec-pristine apache2-suexec-custom
2016/01/09 17:43:07 ui:     virtualbox-iso: apache2-utils openssl-blacklist
2016/01/09 17:43:07 ui:     virtualbox-iso: The following NEW packages will be installed:
2016/01/09 17:43:07 ui:     virtualbox-iso: apache2 apache2-bin apache2-data libapr1 libaprutil1 libaprutil1-dbd-sqlite3
2016/01/09 17:43:07 ui:     virtualbox-iso: libaprutil1-ldap ssl-cert
2016/01/09 17:43:07 ui:     virtualbox-iso: 0 upgraded, 8 newly installed, 0 to remove and 69 not upgraded.
2016/01/09 17:43:07 ui:     virtualbox-iso: Need to get 1,285 kB of archives.
2016/01/09 17:43:07 ui:     virtualbox-iso: After this operation, 5,348 kB of additional disk space will be used.
2016/01/09 17:43:07 ui:     virtualbox-iso: Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main libapr1 amd64 1.5.0-1 [85.1 kB]
2016/01/09 17:43:07 ui:     virtualbox-iso: Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main libaprutil1 amd64 1.5.3-1 [76.4 kB]
2016/01/09 17:43:07 ui:     virtualbox-iso: Get:3 http://us.archive.ubuntu.com/ubuntu/ trusty/main libaprutil1-dbd-sqlite3 amd64 1.5.3-1 [10.5 kB]
2016/01/09 17:43:07 ui:     virtualbox-iso: Get:4 http://us.archive.ubuntu.com/ubuntu/ trusty/main libaprutil1-ldap amd64 1.5.3-1 [8,634 B]
2016/01/09 17:43:07 ui:     virtualbox-iso: Get:5 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main apache2-bin amd64 2.4.7-1ubuntu4.8 [840 kB]
2016/01/09 17:43:08 ui:     virtualbox-iso: Get:6 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main apache2-data all 2.4.7-1ubuntu4.8 [160 kB]
2016/01/09 17:43:08 ui:     virtualbox-iso: Get:7 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main apache2 amd64 2.4.7-1ubuntu4.8 [87.6 kB]
2016/01/09 17:43:08 ui:     virtualbox-iso: Get:8 http://us.archive.ubuntu.com/ubuntu/ trusty/main ssl-cert all 1.0.33 [16.6 kB]
2016/01/09 17:43:08 ui:     virtualbox-iso: Preconfiguring packages ...
2016/01/09 17:43:08 ui:     virtualbox-iso: Fetched 1,285 kB in 1s (859 kB/s)
2016/01/09 17:43:08 ui:     virtualbox-iso: Selecting previously unselected package libapr1:amd64.
2016/01/09 17:43:08 ui:     virtualbox-iso: (Reading database ... 61917 files and directories currently installed.)
2016/01/09 17:43:08 ui:     virtualbox-iso: Preparing to unpack .../libapr1_1.5.0-1_amd64.deb ...
2016/01/09 17:43:08 ui:     virtualbox-iso: Unpacking libapr1:amd64 (1.5.0-1) ...
2016/01/09 17:43:08 ui:     virtualbox-iso: Selecting previously unselected package libaprutil1:amd64.
2016/01/09 17:43:08 ui:     virtualbox-iso: Preparing to unpack .../libaprutil1_1.5.3-1_amd64.deb ...
2016/01/09 17:43:08 ui:     virtualbox-iso: Unpacking libaprutil1:amd64 (1.5.3-1) ...
2016/01/09 17:43:08 ui:     virtualbox-iso: Selecting previously unselected package libaprutil1-dbd-sqlite3:amd64.
2016/01/09 17:43:08 ui:     virtualbox-iso: Preparing to unpack .../libaprutil1-dbd-sqlite3_1.5.3-1_amd64.deb ...
2016/01/09 17:43:08 ui:     virtualbox-iso: Unpacking libaprutil1-dbd-sqlite3:amd64 (1.5.3-1) ...
2016/01/09 17:43:08 ui:     virtualbox-iso: Selecting previously unselected package libaprutil1-ldap:amd64.
2016/01/09 17:43:08 ui:     virtualbox-iso: Preparing to unpack .../libaprutil1-ldap_1.5.3-1_amd64.deb ...
2016/01/09 17:43:08 ui:     virtualbox-iso: Unpacking libaprutil1-ldap:amd64 (1.5.3-1) ...
2016/01/09 17:43:08 ui:     virtualbox-iso: Selecting previously unselected package apache2-bin.
2016/01/09 17:43:08 ui:     virtualbox-iso: Preparing to unpack .../apache2-bin_2.4.7-1ubuntu4.8_amd64.deb ...
2016/01/09 17:43:08 ui:     virtualbox-iso: Unpacking apache2-bin (2.4.7-1ubuntu4.8) ...
2016/01/09 17:43:09 ui:     virtualbox-iso: Selecting previously unselected package apache2-data.
2016/01/09 17:43:09 ui:     virtualbox-iso: Preparing to unpack .../apache2-data_2.4.7-1ubuntu4.8_all.deb ...
2016/01/09 17:43:09 ui:     virtualbox-iso: Unpacking apache2-data (2.4.7-1ubuntu4.8) ...
2016/01/09 17:43:09 ui:     virtualbox-iso: Selecting previously unselected package apache2.
2016/01/09 17:43:09 ui:     virtualbox-iso: Preparing to unpack .../apache2_2.4.7-1ubuntu4.8_amd64.deb ...
2016/01/09 17:43:09 ui:     virtualbox-iso: Unpacking apache2 (2.4.7-1ubuntu4.8) ...
2016/01/09 17:43:09 ui:     virtualbox-iso: Selecting previously unselected package ssl-cert.
2016/01/09 17:43:09 ui:     virtualbox-iso: Preparing to unpack .../ssl-cert_1.0.33_all.deb ...
2016/01/09 17:43:09 ui:     virtualbox-iso: Unpacking ssl-cert (1.0.33) ...
2016/01/09 17:43:09 ui:     virtualbox-iso: Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
2016/01/09 17:43:09 ui:     virtualbox-iso: Processing triggers for ureadahead (0.100.0-16) ...
2016/01/09 17:43:09 ui:     virtualbox-iso: ureadahead will be reprofiled on next reboot
2016/01/09 17:43:09 ui:     virtualbox-iso: Processing triggers for ufw (0.34~rc-0ubuntu2) ...
2016/01/09 17:43:09 ui:     virtualbox-iso: Setting up libapr1:amd64 (1.5.0-1) ...
2016/01/09 17:43:09 ui:     virtualbox-iso: Setting up libaprutil1:amd64 (1.5.3-1) ...
2016/01/09 17:43:09 ui:     virtualbox-iso: Setting up libaprutil1-dbd-sqlite3:amd64 (1.5.3-1) ...
2016/01/09 17:43:09 ui:     virtualbox-iso: Setting up libaprutil1-ldap:amd64 (1.5.3-1) ...
2016/01/09 17:43:09 ui:     virtualbox-iso: Setting up apache2-bin (2.4.7-1ubuntu4.8) ...
2016/01/09 17:43:09 ui:     virtualbox-iso: Setting up apache2-data (2.4.7-1ubuntu4.8) ...
2016/01/09 17:43:09 ui:     virtualbox-iso: Setting up apache2 (2.4.7-1ubuntu4.8) ...
2016/01/09 17:43:09 ui:     virtualbox-iso: Enabling module mpm_event.
2016/01/09 17:43:09 ui:     virtualbox-iso: Enabling module authz_core.
2016/01/09 17:43:09 ui:     virtualbox-iso: Enabling module authz_host.
2016/01/09 17:43:09 ui:     virtualbox-iso: Enabling module authn_core.
2016/01/09 17:43:09 ui:     virtualbox-iso: Enabling module auth_basic.
2016/01/09 17:43:09 ui:     virtualbox-iso: Enabling module access_compat.
2016/01/09 17:43:09 ui:     virtualbox-iso: Enabling module authn_file.
2016/01/09 17:43:09 ui:     virtualbox-iso: Enabling module authz_user.
2016/01/09 17:43:09 ui:     virtualbox-iso: Enabling module alias.
2016/01/09 17:43:10 ui:     virtualbox-iso: Enabling module dir.
2016/01/09 17:43:10 ui:     virtualbox-iso: Enabling module autoindex.
2016/01/09 17:43:10 ui:     virtualbox-iso: Enabling module env.
2016/01/09 17:43:10 ui:     virtualbox-iso: Enabling module mime.
2016/01/09 17:43:10 ui:     virtualbox-iso: Enabling module negotiation.
2016/01/09 17:43:10 ui:     virtualbox-iso: Enabling module setenvif.
2016/01/09 17:43:10 ui:     virtualbox-iso: Enabling module filter.
2016/01/09 17:43:10 ui:     virtualbox-iso: Enabling module deflate.
2016/01/09 17:43:10 ui:     virtualbox-iso: Enabling module status.
2016/01/09 17:43:10 ui:     virtualbox-iso: Enabling conf charset.
2016/01/09 17:43:10 ui:     virtualbox-iso: Enabling conf localized-error-pages.
2016/01/09 17:43:10 ui:     virtualbox-iso: Enabling conf other-vhosts-access-log.
2016/01/09 17:43:10 ui:     virtualbox-iso: Enabling conf security.
2016/01/09 17:43:10 ui:     virtualbox-iso: Enabling conf serve-cgi-bin.
2016/01/09 17:43:10 ui:     virtualbox-iso: Enabling site 000-default.
2016/01/09 17:43:10 ui:     virtualbox-iso: * Starting web server apache2
2016/01/09 17:43:11 ui:     virtualbox-iso: *
2016/01/09 17:43:11 ui:     virtualbox-iso: Setting up ssl-cert (1.0.33) ...
2016/01/09 17:43:11 ui:     virtualbox-iso: Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
2016/01/09 17:43:11 ui:     virtualbox-iso: Processing triggers for ureadahead (0.100.0-16) ...
2016/01/09 17:43:11 ui:     virtualbox-iso: Processing triggers for ufw (0.34~rc-0ubuntu2) ...
2016/01/09 17:43:12 ui:     virtualbox-iso: [sudo] password for vagrant: Generating grub configuration file ...
2016/01/09 17:43:12 ui:     virtualbox-iso: Found linux image: /boot/vmlinuz-3.19.0-25-generic
2016/01/09 17:43:12 ui:     virtualbox-iso: Found initrd image: /boot/initrd.img-3.19.0-25-generic
2016/01/09 17:43:13 packer-builder-virtualbox-iso.exe: 2016/01/09 17:43:13 remote command exited with '0': echo 'vagrant'|sudo -S sh '/tmp/script_7943.sh'
2016/01/09 17:43:13 packer-builder-virtualbox-iso.exe: 2016/01/09 17:43:13 [INFO] RPC endpoint: Communicator ended with: 0
2016/01/09 17:43:13 [INFO] RPC client: Communicator ended with: 0
2016/01/09 17:43:13 [INFO] RPC endpoint: Communicator ended with: 0
2016/01/09 17:43:13 [INFO] 12338 bytes written for 'stdout'
2016/01/09 17:43:13 [INFO] 179 bytes written for 'stderr'
2016/01/09 17:43:13 ui:     virtualbox-iso: done

流浪汉的哪个过程会导致这种奇怪的行为? (缓存系统,virtualbox缓存...。)

我尝试

  • 删除项目的.builds目录
  • 在virtualbox中删除映像虚拟机
  • 删除项目中的packer_cache目录
  • 创建自己的模板中添加的脚本
  • 从头开始一个新的打包程序项目,结果相同

这似乎是一个非常非常奇怪的问题,不仅与脚本有关,而且与无业游民和virtualbox运行的机制有关。

为什么安装的软件包在我的流浪汉中找不到?

配置

  • 操作系统主机:Windows 7 Pro
  • 操作系统访客:Ubuntu 14.04 LTS
  • VM技术:VirtualBox 5.0.10
  • VM技术:Vagrant 1.7.4
  • VM工具构建器:Packer 0.8.6
vagrant virtualbox
1个回答
1
投票

因此,这是我们所知道的关键细节。 我们可以从Packer构建的输出中看到,显然已经安装了Apache。 因此,生成的Box文件包括Apache安装,使用它创建Vagrant VM会导致该VM安装了Apache。 但是,在您的情况下,Vagrant VM 安装Apache。

使用消除的过程,这就是我认为发生的事情。 您必须已经使用Packer中的box文件添加了一个名称相同的Vagrant框,然后才能运行Vagrant。 当您做一个vagrant upvagrant up将查看Vagrantfile中的框名(在这种情况下为config.vm.box ),检查它是否已经具有该名称的框,如果存在则使用它。 否则,Vagrant将使用框URL(此处为config.vm.box_url )查找新框,然后使用提供的名称将其添加。

您知道Packer中的box文件已安装Apache。 您只需要确保Vagrant可以导入该框,而不要使用已经具有的相同名称的框。 为此,您需要先删除它,然后再运行Vagrant ...

vagrant box remove ubuntu-14.04-amd64
vagrant up

然后,您的Vagrant VM将使用Packer创建的已安装Apache的框。

© www.soinside.com 2019 - 2024. All rights reserved.