Developing on Windows -> Deploying on a Virtual Machine? - windows

Is there an easy way to integrate with VirtualBox such that I could develop under the host, Windows, and deploy and run scripts via a mounted folder in a guest linux system?
I'm looking to develop for Linux under Windows, kind of.

You can use VirtualBox's Shared Folders feature to enable your Ubuntu virtual machine to mount a directory of your Windows host. However, you're likey to be deal with some impedance mismatches like different line endings. I hope that is the least of your worries.

You might want to check out vagrant http://vagrantup.com/
It provides a nice and easy system to create a VM from a template in Virtual Box, and will automatically mount the project folder in the guest VM. The config can also easily be included in your project so others can use it.

I develop in PHP. And I use Debian as guest OS, and Win7 as host OS.
You can done automaticly mount share folder by:
new a file in /etc/init.d/ named mnt_win_sf, than you edit it:
It must has the same info head with /etc/init.d/apache2. And you need just one line of command:
mount -t vboxsf share_folder_name mount_point
We also need to excute this script before apache2, so we edit /etc/init.d/apache2. In the Require Start line, add mnt_win_sf
update them by:
sudo update-rc.d mnt_win_sf defaults
sudo update-rc.d apache2 defaults

Related

Docker: Mount volume from Windows host

I use 1.12 version of Docker on Windows, since I can't use the Hyper-V feature with the newer "native" version - so I have my quickstart terminal and communicate to docker host via the invisible underlying virtual box.
Now I have the problem, that I need to mount a local folder to a container, which worked successfully from within the docker-machine by adding
--volume="`pwd`:/root/data"
to the docker run command, but it does not when I launch the same command from my Windows quickstart terminal (even though pwd command works correctly in the terminal).
I tried to find the Windows specific settings for the directory and tested several combinations of format, but no luck. Can anyone help me out on how to correctly specify a Windows folder (e.g. C:\Users\alexander.ruehl) for the volume parameter?
You can use relative path for your volume : --volume="./mydata:/root/data"
Also make sure that you have given the permission for read/write to Docker.

Use Windows with Virtual Box as Host and VM guest for managing with Vagrant and Ansible

Is there a way for next scenario as I am planing to setup lab environment:
physical desktop running Windows 8 platform
on Windows 8, I plan to install ONLY Virtual Box 5.1
then on VirtualBox to setup CentOS system
and then on CentOS will be running Vagrant and Ansible (no VirtualBox installation)
Question: Is there any way that this setup will work to create new environments via CentOS as Vagrant-Ansible manage servers?
------------------------edit----------------------
Thank you for your answer. I try to setup as I mentioned above without luck. I am new user of Vagrant and Ansible so I am having trouble to make it work. I setup Linux system on VB, install vagrant, install Ansible but when I hit 'vagrant up' I am getting error that "No usable default provider could be found for your". I am following documentation form official sites but can;t make it work. Then I try to install VirtualBox inside Linux system and now it is working but defined machines with Vagrant installs inside Linux machine (where are Vagrant and Ansible installed) and not on Host VirtualBox. Any advice? I hope it is clearer now. Thanks
I have had some success in using a Windows Ansible Host and running using Vagrant with this host.
I have scripted how to setup Win Ansible and the shims at:
https://github.com/taliesins/win-ansible
The important bit is to setup shims that call bash scripts running under cygwin.
Another important thing to consider is, is that it is probably better to generate your own inventory file (put it in the vagrant file before you create VMs) then to use an auto-generated inventory file.
If you environment is not simple consider not using Vagrant provisioner for Ansible, but rather call Ansible via command line at the end of the vagrant file (after you have created the VMs).

Running Composer on guest VM with Vagrant and rsync only keeps

I searched about this topic and could not find anything so here I go with my question: I have Linux running in Vagrant as guest, Windows as host; I shared folders with rsync to speed up development with Rails (using NFS or SMB is extremely slow); some of my PHP dependencies get installed with Composer within my project, so when I run Composer via SSH from the guest it downloads and installs them, however, when I restart my VM I lost the dependencies downloaded and need to start over.
So is there anything I could do to run Composer remote or locally, and not loose my changes? so far I've tried changing the sync type to SMB, run Composer, and then go back to rsync, however, I need to switch on and off and I'd like something more automated...
Thank you for your help!
Carlos.
From the docs:
The rsync synced folder does a one-time one-way sync from the machine running to the machine being started by Vagrant.
So this is intentional: If you don't get the result of ANY changes (not just Composer) out of the vagrant machine onto your copy on Windows, it will always get lost inside the VM.
Use SMB or shared folders and bear the performance penalty. Or try and get a NFS server for Windows and install the files inside the VM via NFS.

Is it possible to create a windows batch file script that can finish a virtual machine installation on virtualbox and install guest additions?

I have created a windows batch file that can create a virtual machine on virtualbox with a specific configuration to suit my needs (using vboxmanage). However, you still have to manually start up the virtual machine and answer the virtual OS's prompts (language, hostname) to complete the virtual OS installation. I would like to have my batch file do this for me. In addition, I would like my batch file to install Guest Additions as well. I've read that I could mount the Guest Additions iso file to my virtual machine somehow, but I wouldn't know what to do after that.
I doubt that this can be done since the installation is done on the virtual OS's side and not the host/virtualbox's. Just want to make sure.
It is much easier to do it using both Vagrant and Ansible. Checkout this repository for a shopping system and see how they did it: https://github.com/shopwareLabs/shopware-vagrant
After you test it then play with the ansible roles to set up the achine the way you want and then you can create a bach file that does run the command vagrant up

How do share the same VM between Windows and Linux when using Vagrant?

I have two hosts, one Windows and one Linux, both with Vagrant and VMware Workstation installed and everything works perfectly fine in their own environment. However, when I create an guest VM in Linux and I do vagrant up in Windows, then Vagrant will delete(!) everything in the .vagrant directory and attempt to fetch the base image. The same thing happens if I do a vagrant init and vagrant up in Windows and then a vagrant up in Linux. How do I prevent this from happening? Is there anyway to share the same VMs between Windows and Linux using Vagrant?
I'm running Windows 7, Ubuntu 14.04, Vagrant 1.6.5, VMware Workstation 10.0.3. This problem occurs for all guest operating systems.
The content of the .vagrant directory can be OS specific, and the internal state of VMware for sure.
I don't think there is easy way to share the same VM instance between the two hosts. The Vagrant way is to provision the VM so you only share the base box and then each user/OS spins up their own instance.
Another option would be to use vagrant package and vagrant box add to transfer the configured box, but that doesn't work with the VMware provider.
Yet another approach would be to use a cloud provider like AWS or Digital Ocean and just ssh into the box. Or maybe even use the vagrant-managed-servers plugin. Your question didn't hint what you use the Vagrant VM for, so it's difficult to tell what would be the best solution.
The following has been tested using the VirtualBox Vagrant provider with Windows 10 and Ubuntu 18.04 in a dual boot setup with a shared NTFS drive where D:\ in Windows is accesible as /mnt/d/ in Linux.
First (but not indispensable if I'm not wrong), set the VAGRANT_HOME environment variable in both Windows and Linux to the same place, e.g.:
Windows, D:\.vagrant.d
Linux, /mnt/d/.vagrant.d
Then create a new machine from one of the OSes, from Linux in the following example:
$ cd /mnt/d/vagrant_machines/machine1
$ vagrant init
$ vagrant up
Then boot in Windows and first backup D:\vagrant_machines\machine1\.vagrant just in case case its contents get accidentally deleted.
Then register from VirtualBox the existing VM, e.g. D:\virtualbox_machines\machine1_default_1587262647987_91775\machine1_default_1587262647987_91775.vbox.
Then run the following:
>vagrant.exe status
The VirtualBox VM was created with a user that doesn't match the
current user running Vagrant. VirtualBox requires that the same user
be used to manage the VM that was created. Please re-run Vagrant with
that user. This is not a Vagrant issue.
The UID used to create the VM was: 1000
Your UID is: 0
And update D:\vagrant_machines\machine1\.vagrant\machines\default\virtualbox\creator_uid to your current UID (0 in this example).
Then start the machine:
>vagrant status
>vagrant up
Finally, note that you will require to update the creator_uid each time that you switch OSes, which you might want to automate.

Resources