VAGRANT UP not working when executed via BAMBOO - vagrant

I am trying to work with Vagrant and Bamboo together. I created custom box which I put on a web server from which it is getting downloaded when doing vagrant up. When I do it manually on the computer everything goes as expected.
When I try this via Bamboo however, the folder for local box in c:\Windows\System32\config\systemprofile\.vagrant.d\boxes is not created and subsequently fails as vagrant is not able to do import.
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'http://127.0.0.1:8000/k.box'...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["import", "-n", "C:/Windows/System32/config/systemprofile/.vagrant.d/boxes/http-VAGRANTCOLON--VAGRANTSLASH--VAGRANTSLASH-127.0.0.1-VAGRANTCOLON-8000-VAGRANTSLASH-k.box/0/virtualbox/box.ovf"]
Stderr: 0%...
Progress state: VBOX_E_FILE_ERROR
VBoxManage.exe: error: Appliance read failed
VBoxManage.exe: error: Could not read OVF file 'box.ovf' (VERR_PATH_NOT_FOUND)
VBoxManage.exe: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component ApplianceWrap, interface IAppliance
VBoxManage.exe: error: Context: "enum RTEXITCODE __cdecl handleImportAppliance(struct HandlerArg *)" at line 307 of file VBoxManageAppliance.cpp
Did any of you encountered similar problem?
Thank you.

After some investigation I found the reason for this. The problem is that by default .vagrant.d folder is created in C:\Windows\SysWOW64\config\systemprofile when the vagrant is run via Bamboo. This is the folder where the boxes are stored after download.
The PROFILEUSER environment variable is set to C:\Windows\System32\config\systemprofilefor SYSTEM user. Subsequently after downloading the box it went to look for it into .vagrant.d folder inside PROFILEUSER folder instead of the one that really stored the box.
This problem was solved by setting VAGRANT_HOME environment variable to C:\Windows\SysWOW64\config\systemprofile\.vagrant.d. After this, vagrant looks into correct folder for stored boxes.

Related

vagrant up doesn`t running Progress state: E_INVALIDARG VBoxManage.exe: error: Appliance import failed

Here is cmd error, I can't understand where is error and I'm bumping on it again and again, can`t solve it.
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Preparing master VM for linked clones...
default: This is a one time operation. Once the master VM is prepared,
default: it will be used as a base for linked clones, making the creation
default: of new VMs take milliseconds on a modern system.
==> default: Importing base box 'hashicorp/bionic64'...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["import", "\\\\?\\C:\\HashiCorp\\boxes\\hashicorp-VAGRANTSLASH-bionic64\\1.0.282\\virtualbox\\box.ovf", "--vsys", "0", "--vmname", "ubuntu-18.04-amd64_1574870798285_57998", "--vsys", "0", "--unit", "11", "--disk", "C:/Users/\u256C\u044B\u0445\u0443/VirtualBox VMs/ubuntu-18.04-amd64_1574870798285_57998/ubuntu-18.04-amd64-disk001.vmdk"]
Stderr: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Interpreting \\?\C:\HashiCorp\boxes\hashicorp-VAGRANTSLASH-bionic64\1.0.282\virtualbox\box.ovf...
OK.
0%...
Progress state: E_INVALIDARG
VBoxManage.exe: error: Appliance import failed
VBoxManage.exe: error: Code E_INVALIDARG (0x80070057) - One or more arguments are invalid (extended info not available)
VBoxManage.exe: error: Context: "enum RTEXITCODE __cdecl handleImportAppliance(struct HandlerArg *)" at line 957 of file VBoxManageAppliance.cpp
I experienced the same issue and solved it by changing VirtualBox's base VM folder:
Open VirtualBox
Go to File -> Preferences
In the General tab, change the Default Machine Folder path to an existing path.
Run vagrant up again
In my case VirtualBox's Default Machine Folder was still pointing to my external hard drive which was no longer connected. Manually importing the Vagrant downloaded .ovf file in VBox via File -> Import Virtual Appliance lead me to the above solution. Vagrant does the same thing under the hood.
I got the same issue and stumbled for several hours. Finally, it worked from the following steps.
My C drive didn't have enough memory for the Vagrant to bring up the Virtual box. Cleared the memory for Vagrant. It all worked well without any issues.
free enough space in your drive C :
make sure it's C:\\HashiCorp\\boxes\\hashicorp-VAGRANTSLASH-bionic64\\1.0.282 up to date
I had the same issue. I had follow the instructions to change the default machine folder to the same path as the one set for environment variable for VAGRANT_HOME
Open VirtualBox
Go to File -> Preferences
In the General tab, change the Default Machine Folder path to an existing path.
Run vagrant up again
you can check PATH below,if has blank or special character, change it.
Vagrant install PATH
VirtualBox install PATH
$VAGRANT_HOME PATH
VirtualBox default Virtual Machine location PATH
Also, free enough space $VAGRANT_HOME and VirtualBox default Virtual Machine location

Failed to create the VirtualBox object

I was trying to login into the already existing vm using vagrant in bash. But it says failed to start or it's not running.
This is a already existing vm in the local.
I tried
$vagrant global-status -> to get the vm id.
then,
$vagrant up <id> ->to start the vm.
Got the following error,
There was an error while executing VBoxManage, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["showvminfo", "cd2ec772-3e94-476f-a0d9-59c3d2768fb5"]
Stderr: VBoxManage.exe: error: Failed to create the VirtualBox object!
VBoxManage.exe: error: Code REGDB_E_CLASSNOTREG (0x80040154) - Class not registered (extended info not available)
VBoxManage.exe: error: Most likely, the VirtualBox COM server is not running or failed to start.

How to move the Vagrant environment?

"vagrant init: ...a Vagrant environment by creating an initial
Vagrantfile..."
I moved that folder from E:/ to C:/ in windows, and I'm having this silly error when trying to do a vagrant snapshot restore XXX
==> default: Booting VM...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["startvm", "7aff8d5d-7193-4f6d-966b-4076543c0e90", "--type", "headless"]
Stderr: VBoxManage.exe: error: RawFile#0 failed to create the raw output file E:/Proyectos/do-sf2-dev/ubuntu-xenial-16.04-cloudimg-console.log (VERR_PATH_NOT_FOUND)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole
From I understand, VirtualBox keeps referencing the E:/ drive.
I tried manually editing any references from E:/ to C:/ I can find under that folder, and also in the VirtualBox GUI for the concerning machine but no luck.
This answer is late but will hopefully help the next person to encounter this issue. The error is because the machine is configured to output to a location that doesn't exist anymore. When moving a Vagrant environment to another drive you'll need to update some Vagrant metadata in addition to moving the VM files. You can use vagrant up --debug to see exactly what the error is referring to.
If you move the .vagrant.d directory you'll need to set the environment variable VAGRANT_HOME to its new location. On windows you need to restart for this to take effect. If that doesn't work add one of the following to your vagrantfile:
v.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ]
This disables serial output to the missing log file (ubuntu-xenial-16.04-cloudimg-console.log)
or
v.customize [ "modifyvm", :id, "--uartmode1", "file", File.join(Dir.pwd, "ubuntu-xenial-16.04-cloudimg-console.log") ]
This updates the path of the log file to point to the current directory.
For most vagrant setups this should be enough , however, I also needed to re-create the path to the erring log file before vagrant up would work successfully. After that I ran vagrant provision and was able to delete the old file path without issues.
These posts were also helpful (References):
https://medium.com/#cedricdue/moving-vagrant-boxes-and-related-virtualbox-vms-to-another-drive-f1d7c50d20bc
https://superuser.com/questions/256192/how-to-move-virtualbox-files
https://github.com/joelhandwell/ubuntu_vagrant_boxes/issues/1
https://github.com/hashicorp/vagrant/issues/8275

Restoring Laravel's Homestead after critical error

I'm using Homestead via Vagrant for my Laravel environment. When I ran vagrant up today, there was a critical error saying that the box is inaccessible.
One of the instructions that I found on the web suggested unregistering the VM by using its machine uuid, which I did:
> VBoxManage.exe unregistervm [uuid]
After unregistering the status of Homestead box changed from inaccessible to not created.
Next step was to register the box, which I do like this:
> VBoxManage.exe registervm "C:\Users\Rhino\VirtualBox VMs\homestead\box-disk1.vmdk"
However the command above throws the following error:
VBoxManage.exe: error: Start tag expected, '<' not found.
VBoxManage.exe: error: Location: 'C:\Users\Rhino\VirtualBox VMs\homestead\box-disk1.vmdk', line 1 (0), column 1.
What am I doing wrong?
OK, I figured it out. There was probably a step missing in the guide I found - creation. All the steps again:
(1)Unregister the box with machine uuid. The uuid can be found e.g. in the .vbox-prev file in your homestead virtual machine folder. Run this when you retrieve the uuid:
C:\Program Files\Oracle\VirtualBox> VBoxManage.exe unregistervm [uuid]
(2)Create the box with --register flag:
C:\Program Files\Oracle\VirtualBox> VBoxManage.exe createvm --name "C:\Users\Rhino\VirtualBox VMs\homestead\box-disk1.vmdk" --register
(3)Delete the folder in which your homestead vm is kept (I guess it's by default created in VirtualBox VMs folder)
(4)Run vagrant up

Vagrant up returning "Compressed image is corrupted"

I'm trying to create a vagrant box using Ubuntu 14.04 32bit as a base.
The first VMDK was packaged and tested successfully. Then I realized it takes too long to provision the box with Latex (Tex Live). So I created a new package in the following manner:
Created "full clone" of the original VMDK (Checked "Reinitialize the MAC address of all network cards")
Installed Latex.
Shutdown and started packaging the clone.
Once I added the package to vagrant, I created a new vagrant box. But running it returned the following:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu-latex'...
Progress: 10%There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["import", "/home/me/.vagrant.d/boxes/ubuntu-latex/0/virtualbox/box.ovf", "--vsys", "0", "--vmname", "Ubuntu-HL-Latex_1_1405303855841_84250", "--vsys", "0", "--unit", "11", "--disk", "/home/me/VirtualBox VMs/Ubuntu-HL-Latex_1_1405303855841_84250/box-disk2.vmdk"]
Stderr: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Interpreting /home/me/.vagrant.d/boxes/ubuntu-latex/0/virtualbox/box.ovf...
OK.
0%...10%...
Progress state: VBOX_E_FILE_ERROR
VBoxManage: error: Appliance import failed
VBoxManage: error: Could not create the clone medium '/home/me/VirtualBox VMs/Ubuntu-HL-Latex_1_1405303855841_84250/box-disk2.vmdk'.
VBoxManage: error: VMDK: Compressed image is corrupted '/home/me/.vagrant.d/boxes/ubuntu-latex/0/virtualbox/box-disk2.vmdk' (VERR_ZIP_CORRUPTED)
VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component Appliance, interface IAppliance
VBoxManage: error: Context: "int handleImportAppliance(HandlerArg*)" at line 779 of file VBoxManageAppliance.cpp
The vagrantfile was never changed after vagrant init was executed for both the original and latex boxes.
Would anyone have an idea on what's happening and how to fix this?
I had the same problem and I fixed it like that:
$vagrant box list
$vagrant box remove precise6
$vagrant up

Resources