A very simplified use case fails, I must be doing something terribly wrong, already tried community help with no luck.
I would like to pack an image based on ubuntu 16.04.1 iso with virtualbox-iso provider and provision a few packages (jq and subversion) using shell provisioner (by calling apt). After Vagrant Box is produced, I use that box with Vagrant, sshing into the box shows that the installed packages are not there!!
I thought that this could be file system sync issue and added a few sync commands around and then wait for 30 seconds with no luck.
Please find the repo reproducing the issue below. I am also attaching the packer log file, it actually shows below error but still creating the box as if it is a soft or unrelated error.
2016/11/18 21:06:45 packer: 2016/11/18 21:06:45 stderr: VBoxManage: error: No storage device attached to device slot 1 on port 0 of controller 'IDE Controller'
2016/11/18 21:06:45 packer: VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component SessionMachine, interface IMachine, callee nsISupports
2016/11/18 21:06:45 packer: VBoxManage: error: Context: "DetachDevice(Bstr(pszCtl).raw(), port, device)" at line 393 of file VBoxManageStorageController.cpp
2016/11/18 21:06:45 ui: [1;32m==> virtualbox-iso: Unregistering and deleting virtual machine...[0m
Reproduction:
Clone the repository: https://github.com/gokhansengun/packer-shell-provision-issue
Issue the following commands. You will see that the jq
and svn
packages that are installed with jq-svn-setup.sh
script provisioner, is not available in the image.
HOST $ PACKER_LOG=1 packer build ubuntu1604.json
HOST $ vagrant up virtualbox
HOST $ vagrant ssh virtualbox
VM$ jq
The program 'jq' is currently not installed. You can install it by typing:
sudo apt install jq
VM$ svn
The program 'svn' is currently not installed. You can install it by typing:
sudo apt install subversion
Try:
vagrant destroy -f
vagrant up virtualbox
vagrant ssh virtualbox
Sorry, did not mention that but I am starting the test with everything clean vagrant destroy -f
and rm -rf builds/*
. Issue persists.
I have seen this issue as well. I build a packer box with virtualbox as the provider and post-processed it to vagrant but the vagrant.box has none of the shell provisioner packages i had installed. Despite the .ovf having all the correct packages.
This sequence of commands works as expected:
packer build -only=virtualbox-iso ubuntu1604.json
vagrant destroy -f
vagrant up --provider virtualbox virtualbox
vagrant ssh virtualbox -c "svn --version"
[email protected]'s password:
svn, version 1.9.3 (r1718519)
compiled Mar 14 2016, 07:39:01 on x86_64-pc-linux-gnu
[...]
(Your vagrant box is missing the default ssh key)
Closing this since there is no bug here. If you still have problems follow up this on the mailing list.
@rickard-von-essen, issue still persists for me. Could you please tell which OS and VirtualBox version you are using? As I mentioned I was already doing vagrant destroy -f
.
VirtualBox 5.1.6r110634
Vagrant 1.8.6
macOS Sierra 10.12.1
OK I found the issue myself, this is more of a Vagrant issue. For those who will encounter with this issue later, here is what happens.
When you use the box file produced with Packer inside Vagrant like below, Vagrant automatically add this box to its list of boxes vagrant box list
.
virtualbox.vm.box = "file://builds/virtualbox-ubuntu1604.box"
Further builds in the Packer produces new boxes locally but when they are referenced in Vagrant, Vagrant does not check whether the box it added before has changed or not, it goes ahead and uses the old box which is causing a lot of mess.
Removing the box with vagrant box remove <box_name>
fixed the issue for me.
:+1:
I know the last comment on this issue was over ~2.5yrs ago; but I've also run into surprising behaviour as described by @gokhansengun -- Does anyone know if there is a way to tell Vagrant to check for new updates to the box? Perhaps config.vm.box_url
helps here?
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
OK I found the issue myself, this is more of a Vagrant issue. For those who will encounter with this issue later, here is what happens.
When you use the box file produced with Packer inside Vagrant like below, Vagrant automatically add this box to its list of boxes
vagrant box list
.virtualbox.vm.box = "file://builds/virtualbox-ubuntu1604.box"
Further builds in the Packer produces new boxes locally but when they are referenced in Vagrant, Vagrant does not check whether the box it added before has changed or not, it goes ahead and uses the old box which is causing a lot of mess.
Removing the box with
vagrant box remove <box_name>
fixed the issue for me.