Run vagrant VM with different user - windows

I know this question overlaps with some other StackExchange sites, however since I want a development environment this matches for StackOverflow.
I'm setting up an VM with vagrant to extend a Linux service on a windows host. It works fine so far just softlinks don't work on shared folders. This is a known bug of VirtualBox. There is a workaround if you run virtual box on an account without admin permissions. However this is no option for me. AFIK I can modify the group permissions of a standard user so that they can create a symlink (on NTFS), but this does not work for admin users. So I need to run the VM with a different user account. Any idea how I can setup vagrant to run a VM with a different user?

Related

Vagrant vs VBox folder share

I have been using Vagrant for few months. Also I have started using Virtual box without Vagrant with sharing folders from host OS and it works well so far.
My question is why is Vagrant needed if Virtual Box can share folders without Vagrant?
Maybe I don't use Vagrant's other features so I don't need them so far.
Just a few things, but will probably not be exhaustive:
Vagrant operates multiple provider, not only Virtualbox, you can run vagrant with Virtualbox, VMWare, HyperV ... (docker as well even if there are different pros and cons) so vagrant abstracts this for you
vagrant can setup shared folders as you experienced, but can easily set different shared folder types (nfs, rsync ..) depending your setup
vagrant will manage all the networking of the VM, if you need a static IP, it will associate hostname and static IP and setup all the routes for you.
vagrant works well with many provisioning tools (puppet, chef, ansible ...) so you can easily create and re-created multiple times the same environment
On top of all this, why is vagrant good to use ? In team. If you work in team, you share a vagrant file (just a ruby script file) and "magically" all your team members share the same environment to work.

Is it possible to run a Vagrant box inside an Ubuntu Virtual box machine?

I currently have a windows 10 which I like for everything, except when it comes to development. So whenever I need to work, I run an Ubuntu virtual box machine and I code there.
I recently started working with a team that uses Vagrant boxes (For development environments) and Ansible (For provisioning). My question is, is it possible to run a Vagrant box inside my Ubuntu virtual machine to provision it with Ansible? (Since it is only available on Linux distros).
I realize that this is a bit confusing since I am running a virtual machine inside another. Is there any way I can go around this?
Vagrant is able to run on windows, you can set a nice directory sharing and you can access that directory from your other VM. If provision is part of the Vagrantfile, you don't have to worry whether this will work in windows or not because most of the provisioners run inside the created machine already.
For Ansible, you should use Ansible Local provisioner. That will let it run on guest machine completely and you won't need Ansible on the host machine.

Does Genymotion require admin privileges?

On a Surface Pro 3 with Win8.1, already have VirtualBox 5.0.6 installed (works fine with Linux images), just installed Genymotion 2.5.4.
Every time I try to start Genymotion, it asks for admin privileges to invoke something on VirtualBox. Why does this need admin? Any way to avoid this?
According to Unable to create Genymotion Virtual Device a number of people think it shouldn't and I can't find any reference on Genymotion's website that they need admin.
The admin privilege appears when Genymotion creates or configure network interfaces though VirtualBox. This network configuration is unfortunately mandatory for the software to work correctly.
The last changes on Windows and VBox obliges us to do it more frequently so that's the reason why you see it each time you start the program.
I encountered this problem with my non privileged user accounts using Windows 10. When Genymotion runs for the first time as the current user, it will create a virtual interface if it does not see one defined in the users profile. If your account has Administrator privileges, it will create the interface without issue. As a non privileged user, you will get prompted for admin credentials so that a new virtual interface can be created and defined.
My workaround was to run Genymotion with an account that has administrator privileges so that the virtual interface is defined and the Genymotion interface starts up. After that, I preserve the following directories in:
C:\Users\%USERNAME%.VirtualBox and
C:\Users\%USERNAME%\AppData\Local\VirtualStore
When I have a new user that needs to run Genymotion, I have them run a script that restores these directories to their profile. They can then run Genymotion without needing Admin credentials.

Is Vagrant Provision suppose to wipe out all your data

I just ran vagrant provision in a futile attempt at getting my customized synced_folders directive to work and now my whole guest box is wiped out.
Is this normal? I don't see any references to Vagrant docs about this behavior.
As per the doc:
Provisioners in Vagrant allow you to automatically install software, alter configurations, and more on the machine as part of the vagrant up process.
The only thing I have in my config provision shell commands are installation commands. Nothing about wiping anything out.
I do have app.vm.provision for puppet that sets fqdn, user name and box name (along with the normal module_path, manifests_path and manifests_file). Maybe this caused things to be reset?
The Answer
Is Vagrant Provision suppose to wipe out all your data?
No. Vagrant should never harm your "data" (i.e., websites, code, etc.).
...now my whole guest box is wiped out. Is this normal?
Yes. Your Vagrant environment (in other words, the guest operating system created in a virtual environment by Vagrant) is volatile, and you should be able to destroy and recreate it at will without having any impact on your working files (because those should be kept in your local, or host, file system).
Explanation
On Vagrant's website, the very first thing they tell you is this:
Create and configure lightweight, reproducible, and portable development environments.
Your development environment allows you to work. You work on your data, in your development work environment. When you are done with your "development work environment," you should be able to delete it freely without affecting your data in the least.
Further, you should be able to send a collaborating developer your Vagrantfile so that they can create the exact same development environment you used to create your data (i.e., write your program, build your website, and so forth). Then, when you provide them with your code, they can use it in an environment identical to the one that your code was created in without having to reconfigure their own setup.
For more details about how your data files (code, working files, etc.) are kept safely in your computer while making them accessible to your guest system created by Vagrant, see my answer to this question.
So what appears to have happened was that when I set up a synced folder, it wiped out everything because there was nothing on my host machine in that synced folder. Unless there is a way to recover the lost data, there should be an unmistakable WARNING in their docs that this can happen.
I setup the synced_folder to be on my whole home directory. When I created a new machine, I cloned the one project I had saved and decided to just sync my individual projects instead of my whole user directory this time. When I reloaded, the project directory was empty since it was empty on my host machine.
So I guess, make sure the directories on your host machine are already setup with the data before configuring your Vagrantfile with synced_folder information.

Is it possible to export/import a virtual box machine in one file?

I have a Vagrant set up with 3 virtual machines. Each machine has its own shell script for provisioning.
Now I would like to share the exact same status of my set up with somebody else. Since the provisioning procedure takes really (!!) long for each machine, I hope there is another solution.
Ideally I would be able to save each machine as it is in one file, which the other person then could import into Virtualbox. Is there a way to do that?
If I understand you correctly you would like to make a Vagrant base box from provisioned by Vagrant VMs. This is not recommended way to go. How you can approach this is:
Create new VM manually with required OS in the VBox.
Adjust it so Vagrant can connect to it as described here and here.
Provision it using your shell scripts.
Install all the things you would find useful to have on this VM.
Use Vagrant to package it as a base box as described here.
After packaging it with Vagrant you will get a Vagrant base box file with .box extension. You can then pass this to your team mates (usb, network share, ftp etc.) and they can add it to their Vagrant installation and use it. Whenever they will do Vagrant up they will get fully provisioned VM in VBox with all the stuff you have packaged to it. Vagrant also gives you versioning capabilities. If properly configured whenever you will create new version of base box everybody who is using it will be notified and would be able to download and use new version of your box.
Hope I understood your problem correctly and this will help to solve it.

Resources