Instead of running a vagrant box in the background (via vagrant ssh in a terminal shell), is there a way to run it using a daemon? This could be used for having people connect to your box (via vagrant connect).
Right now I'm just having a terminal window stay on vagrant share --ssh.
I can't do
vagrant share --ssh &
because it requires my password and I couldn't put in my password.
In essence, whenever you start a Vagrant box with vagrant up, it will already be running in the background (in VirtualBox or VMWare, for example). You don't need to worry about keeping an ssh session connected to it.
Related
Usually you have to run vagrant provision from outside your VM to create the VM to begin with. I then do a vagrant ssh to inspect the resultant VM.
If I wish to make small tweaks to the VM (using chef zero recipes in my case), I have to either switch to an other tab that is on my physical host, or exit the SSH session. it would be nice if you could do this run-and-inspect inside the previously created VM.
Why I'm asking: I have too many terminal tabs open for development and am looking for ways to prune, and avoid mental context switching (not to mention trying to figure out which tab is which).
No, you can not run a vagrant provision from inside the same vagrant machine.
Vagrant is running on your host and provisioning the VM according to the specified vagrantfile. Any changes that you want to have applied during the provisioning must somehow come from the vagrantfile.
What you can do is modify a running vagrant machine in any way you want from inside the vagrant machine, and then export the VM using vagrant package to a new vagrant box which then can be used as base for new vagrant VMs.
PS: Not sure how you're dev environment looks like, but I suggest you look into terminal multiplexers like GNU screen or tmux, that might be able to help you with your "tab issues".
I have created a vagrant machine which is using the LAMP. So, every time I restart the computer I have to use vagrant up to run VM. Is this possible to keep running vagrant machine so when I restart the computer it should remain running in the background? As to keep running Docker container we use -d to detach it with the process. Is this possible in Vagrant?
I have a Cassandra instance running inside virtualbox using vagrant in my windows PC, And my other dev/application settings are in another VM. I don't always need a prompt/UI/CI for the cassandra vm because it's confusing to switch between, is there a way to bring the vagrant without a UI/CI prompt?
Now i'm ding vagrant up
I am setting up a Ubuntu 15.04 VM on Win7 using Vagrant 1.7.4 and VBox 5.0.0.
On the first vagrant up I can ssh into the machine using vagrant putty and everything is setup correctly and works. When I run vagrant halt, the VM shuts down gracefully without error messages.
However, when I try to restart the VM using vagrant up; vagrant putty, the machine is in a strange state. For example, the default synced folder /vagrant is empty, even though the second vagrant up call prints this message:
default: /vagrant => C:/Users/ArneUser/numecs/dev_env
Also, this vagrant up call prints the following message in PowerShell:
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=
Stdout from the command:
Stderr from the command:
stdin: is not a tty
bash: line 2: /sbin/initctl: No such file or directory
I am running a really basic setup just to test for this error, so I don't think the mistake is in my provisioning script. Some pointers in the right direction would be appreciated.
Open VirtualBox GUI and turn off machine manually, then run again the vagrant up command.
That solved the problem in my case :)
/vagrant is empty
/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=
From these two lines I suspect that MOUNTPOINT should be /vagrant but its due to /vagrant being empty that SSH is now working.
I've seen similar issues because of Virtualbox 5.
Try to downgrade Virtualbox to 4.3.x and ensure you have the latest Vagrant (1.7.4).
https://github.com/mitchellh/vagrant/issues/5572
Initctl is part of the Upstart init daemon. As far as I'm aware Ubuntu 15.04 is the first version of Ubuntu to abandon Upstart in favor of SystemD, so /sbin/initctl isn't expected to exist in your operating system. I believe this would need to be something that is fixed in the box you're using.
The point of "/sbin/initctl emit ..." is to notify other Upstart units that the vagrant shared folder has been mounted and is available for read/write operations. Since upstart is no longer in use it may be safe to assume that there is no need for this call. It's a rather crude hack, but you could make an empty script at /sbin/initctl. This should allow the vagrant startup process to continue properly and provision your box.
In my case it seems as Marc Young suggested that by opening Virtualbox GUI, the virtual machine itself seems to be hung. I saw these error messages on the virtual box console:
Thus it seems to not to be Vagrant related problem, but the virtual machine (Linux Kernel) itself seems to be hung.
I have Vagrant installed on my iMac but I would also like to install and run it on my MacBook. Is it possible to run the same Vagrant box across two Macs?
I have done a Vagrant up command within a shared Dropbox folder - so i'm guessing that all I need to do is install vagrant on the second mac and then navigate to the Dropbox shared folder and do vagrant up.
Would this work?
Known solution:
ssh to the host machine
user#MacBook: ssh user#imac
then vagrant up; vagrant ssh.
user#imac: vagrant up; vagrant ssh
vagrant#vagrantvm:
This would be the most straight forward way I can think of.
Another option:
RDP to imac and run vagrant up;vagrant ssh as normal
Yet another option:
If your vagrant file is complete enough you should be able to vagrant up on any host to give you the same vagrant env. This relies on your use case but is how I use vagrant.
Vagrant stores the state of the machine and machine id inside the .vagrant folder. The running machine (vm) itself is handled by virtualbox/vmware or any provider your using. Lets say the virtualbox box is stored somewhere else on your system and referenced by Vagrant.
If you access the folder from two systems your basically remote controlling two different machine on two different systems. Not a good solution. Furthermore, you will run into problems if the states are different, e.g. its "up" on system one but "destroyed" on system two.
Additionally to the above solutions I propose the following:
Vagrant Share! Enable Vagrant http-/ssh-Share between your systems.
Vagrant machines should be repeatable and destroyable. Therefore, put your Vagrantfile under version control and checkout on the two systems.
Configure your provider to store the box itself on the dropbox.