Vagrant Box with Trellis/Bedrock - trellis

I recently set up a Trellis/Bedrock/Sage environment. I like it so far but have been running into the issue that if I step away from my computer, I can’t reconnect to my local production environment and have to start up my wordpress install from scratch. Is there a way to “save” a vagrant box so I can close my computer and not have to vagrant destroy, then vagrant up each time?
Thanks,

You could probably Save State directly in VirtualBox to accomplish what you want:
Also, I was able to find this comment to help answer your question here which also may do the trick:
In order to keep the same VM around and not loose its state, use the
vagrant suspend and vagrant resume commands. This will make your VM
survive a host machine reboot with its state intact.
https://serverfault.com/users/210885/

Related

Is it possible to SSH in AWS instances using any IDEs such PYCHARM?

I am stuck in a technical issue on a project and I think you the forum could help me out.
I have an EC2 Instance Type:p2.xlarge running on AWS, I cloned a repository in this instance which requires pytorch and cuda dependencies(this point has been taken care of).
Now, The issue is that I wanna work & run this code-base(which is is AWS instance now) somehow in my local pyCHARM IDE. In short, I didn't have proper resources on my laptop to run the repository, so I have to run in an AWS instance but for debugging purposes the local IDE would be a great option.
Is it possible to do that?. In other words, we can do SSH into AWS instance and run code, but all will be done through command line, if we could SSH through PYCHARM and can see the code in AWS here in local machine within PYCHARM and change, debug or run it as it was local but actually it gets executed in the instance.
Please suggest a solution to it.
Thanks in advance.
EDIT-1:
After following, #Cromulent suggestion, I have arrived here
Setting the remote:
Upload happening within the local & remote repo.
I still didn't understand the requirement of syncing the local and remote folders, when I only want to open the remote folder in my PYCHARM IDE and work on it.
I think after this setup, I have to change the code in local copy and the PYCHARM will sync the code in remote copy. How will I be running(using resources-GPUs of the remote Instance, not my local machine.) the remote code in PYCHARM in this scenario, I am just syncing it, for running again I have to ssh through command line and run the script(This does not serve the purpose)?
EDIT-2:
After #Cromulent suggestions.
Actually, it did work, but still, I am not able to run the remote code locally.
I am getting the below error while running any remote script. If I run the same script using ssh in the terminal, the scripts run normally. I tried to fix the problem using this post on StackOverflow, but it didn't work too.
ssh://ubuntu#ec2-52-41-247-169.us-west-2.compute.amazonaws.com:22/home/ubuntu/anaconda3/bin/python -u <08ad9807-3477-4916-96ce-ba6155e3ff4c>/home/ubuntu/InsightProject/scripts/download_flownet2.py
/home/ubuntu/anaconda3/bin/python: can't open file '<08ad9807-3477-4916-96ce-ba6155e3ff4c>/home/ubuntu/InsightProject/scripts/download_flownet2.py': [Errno 2] No such file or directory
The below is the screenshot for the above problem:
PyCharm Professional supports remote Python interpreters (either the globally installed Python interpreter or a virtualenv). It works by creating an SSH connection to the server and then running the code on the remote host. The results are then displayed locally in PyCharm Professional. You can also do remote debugging as well.
You MUST be using the professional version of PyCharm though. The free community version does not support this feature.
You can find the documentation here:
https://www.jetbrains.com/help/pycharm/configuring-remote-interpreters-via-ssh.html
One more solution is to deploy a Jupyter Notebook on your remote server. Then you will be able to use it from PyCharm Professional Edition.
Don't forget to make rules for the jupyter ports (e.g. allow all 8888) in your AWS console and in your instance.
To configure a remote interpreter for your notebook do this (source):
Open the Jupyter Notebook page of the Settings/Preferences dialog.
On this page, select or clear the Markdown cells rendering enabled option, and specify the username and password. Note that for the
single-user notebooks these fields are optional - leave them blank.
Fill in the username (for JupyterHub) and password.
Click the link Configure remote interpreter. You'll find yourself at the Project Interpreter page.
Configure the remote interpreter, as described in the section Configuring Python Interpreter.
You will want to configure a remote interpreter.
I tried the above approach but it didn't work for me. I have edited my post so that I can get additional input from the community, but I didn't any after the first answer was posted.
My friend actually figured out a secondary way to fix the issue. He actually uses "NOMACHINE" on the local machine and open connection to the remote desktop. Then you can directly install PYCHARM in the remote machine and work in there. I hope this will help others.
The solution is in his blog post. (Thanks to Shaobo Guan)
Another solution would be to use VNC instead of NoMachine

VMWare Workstation won't suspend from command line

I'm trying to automate VMWare Desktop on Windows 7 to suspend all vm's before I do a backup job each night. I used to have a script that did this but I've noticed now that it won't suspend anymore with the same command that used to work.
If I do vmrun list I get a list of the running vms with no issue.
If I do vmrun suspend "V:\Virtual Machines\RICHARD-DEV\RICHARD-DEV.vmx" it just hangs and I have to kill the command with CTRL+C.
I've even tried a newer command using -T to specify it's workstation, ie vmrun -T ws suspend "V:\Virtual Machines\RICHARD-DEV\RICHARD-DEV.vmx" and still no love.
If I have the vm already stopped, I can issue vmrun start "V:\Virtual Machines\RICHARD-DEV\RICHARD-DEV.vmx" and it starts fine.
As well as the suspend command, the stop command also does not work. I'm running VMWare Workstation 11.1.3 build-3206955 on Windows 7.
Any ideas?
Update:
I installed latest VMWare Tools on the guest, as well as the latest Vix on the Host so everything should be up to date.
I can start a vm using vmrun with no problem using vmrun -T ws start <path to vmx> but the command doesn't come back to the command prompt, so I'm assuming it's not getting confirmation from the vm that it is now running.
If I cancel the 'start' command and now try and suspend I'm getting the same lack of communication from the guest. If I manually suspend the vm, once it's suspended I get an 'Error: vm is not running' and the 'suspend' command finally times out and comes back.
So, it looks to me like there is no communication from vmrun to the guest about what state it's in etc. Is there a way to debug the communication from the host to the guest using vmrun or other means? Are there ports I need open in the guest OS?
So, I never did get vmrun to work properly on my main system, although I did get it behave ok on my laptop so there is something weird happening on this machine. I also installed a trial of the latest VMWare 12 and the same thing happens.
As a workaround, I ended up changing the power management settings in my guest OS so that it would 'sleep' after 1 hr of inactivity. When this happens VMWare detects it and automatically suspends the guest which is really what I'm looking for. Not the most slick solution but it does manage to unlock the files I need to be backed up in a nightly backup.

VirtualBox error "Failed to open a session for the virtual machine"

I have a virtual machine with Windows XP with a clean installation. I set it as immutable to create a differential machine, so I create a new virtual machine, select the immutable hard disk and create a new snapshot in the new virtual machine folder.
However, when I try to start the virtual machine I get this error:
"failed to open a session for the virtual machine".
Código Resultado:
VBOX_E_INVALID_OBJECT_STATE (0x80BB0007)
Componente:
ProgressProxy
Interfaz:
IProgress {c20238e4-3221-4d3f-8891-81ce92d9f913}
What is the problem? until now I can use differential virtual machines without problems. I have installed the last version or VirtualBox v4.3.4 and the problem persists.
If I set the hard driver as normal and I create a new virtual machine and select this hard drive I don't have any problem.
EDIT: I use the same virtual disk and do the same steps in another computer and it works fine. I think that the problem is the VirtualBox of my computer with the problem, but I try to uninstall the program and reinstall it and the problem persists, so I don't know how to solve the problem.
EDIT 2: if I set the virtual harddrive as multiattached instead of immutable, then it works fine. In my case is enough, but I know that it would be work as immutable because it was work until now and it works in another computer.
I try to create a new user in windows to try if the problem if with the configuration of my account, but the problem persists. So I think that some general configuration of VirtualBox has been corrupted and I am not be able to repair it.
I would like to know if there is any solution to use a immutable hard drive, because I would like to solve the problem with VirtualBox, although by the moment the multiattached hard disk is enough.
I had the same issue, I tried editing the VM but it wasn't letting me save it. So I tried the following:
Tried editing the VM to change RAM/CPU etc, but it wasn't letting me save it
Deleted the vm (not the data) and tried adding it again, didn't fix it
Tried moving the vbox file to another directory and import it, but it didn't let me move the vbox file so I realized there's a virtualbox process running that's holding a lock on it. So I killed that process and started it again and my VM booted
Killing VM process dint work in my case.
Right click on the VM and click on "Discard Saved State".
This worked for me.
For windows users
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
I had the same issue, and this trick works for me
Goto control panel
Open Uninstall program
Click on turn windows features on or off
Scroll down and find the hyper-V folder.
Uncheck the Hyper-V.
Apply changes and restart your system.
Now here you go... Open your virtual box and start the os you want.
Hope this helps..
Updating VirtualBox to newest version fixed my issue.
If you are in Windows and the error message shows VT-x is not available make sure Hyper-V is disabled in Windows components.
maybe it is caused by privilege, please try this:
#sudo chmod 755 /Applications
#sudo chmod 755 /Applications/Virtualbox.app
Something that I tried and work for me is simply you create a new virtual machine and you use the existing virtual hard disk file and everything is like you left it.
On Ubuntu, this can also be caused by incorrect permissions. I chmod 755 Logs/ which fixed the issue.
In my case I gave administrator privilege to Virtualbox and it solved my problem.
i.e., run run as administrator on windows 10
In may case, "VM VirtualBox Extension Pack" was broken. So I uninstalled it and reinstalled it.
For MAC users
After some research, this worked for me:
Quit VirtualBox
Right click "Applications" folder
Click on "Get Info"
Change "Everyone" Permission to "Read Only"
Open VirtualBox, and now it should work.
Normally this error occurs when it try to load the previous state. This happened in Mac Virtual box.
I tried after restarting the virtual box but again also i've encountered this issue.
Right Click on the operating system in the virtual box and then Click on the Discard Saved State.. .This fixed the issue.
try this
sudo update-secureboot-policy --enroll-key
and restart your system, when restart it shows option and select Mok key and you will work fine.
The only thing that solved the issue for me is to unmount the second hard disk on my laptop.
My current setup contains 1 HDD on SATA0 port and 1 SSD on SATA1 port. I've the OS and Oracle VirtualBox installed on the SSD drive.
When I deleted the partition on the HDD, the issue was solved.
This solved my problem:
open a cmd with admin privilige
bcdedit /set hypervisorlaunchtype off
reboot
Error gone and VMs are working again.
This worked for me:
In the Oracle VM Manager - right click on your virtual maching (for example kali linux).
In the menu choose "discard saved state".
Then press discard and restart your virtual machine.
Ubuntu based system, solution that worked for me...
Delete virtualbox and download the latest deb package from the virtualbox website.

Can I bring up the GUI for a Vagrant managed Virtual box while the box is running?

I know that I can configure my Vagrantfile to boot my machine with a GUI according to http://docs.vagrantup.com/v2/virtualbox/configuration.html with:
config.vm.provider "virtualbox" do |v|
v.gui = true
end
But if I've started a box headless, is there any way to bring up a GUI while the machine is running? Virtualbox provides the small preview, so I suspect it is possible but I haven't found any documentation on how to do this.
Edit: Terry pointed out that I can vagrant reload after changing the setting above to get a gui, but that reboots the box. I'm still hoping there's a easy way to enable the gui without a reboot.
There are 3 ways I've found to get a gui on a running headless machine if you can see it in the VirtualBox Manager:
You can suspend the machine (Close|Save State or vagrant suspend) and then start it again. When you restart it, you will see the GUI.
or, if you don't want to stop the machine at all:
You can go to display settings and enable the Remote Display Server while it's running (you may want to change the default port), and then use an RDP viewer (On Windows use Remote Desktop Connection) to access the GUI.
[Edit July 2015] With VirtualBox 5.0, click on the headless VM, choose "Show", and it will bring up the gui.
You'll have to do vagrant reload after enabling gui.
But there is a trick (a bit risky in my opinion)
1. save the state of the VM VBoxManage controlvm NAME_OR_UUID savestate
2. star vbox gui and resume
BTW: BTW: Why do you need GUI for Vagrant managed (headless) running VMs? If you prefer GUI to manage headless VMs, try phpVirtualBox.
From my experience with vagrant once you start completely headless there is no way to boot the GUI, you have to boot it on start with the line you mention above.
If it's running on VirtualBox (what vagrant typically uses) :
preface: you can't without (shortly) interrupting the VM! So you can't just open it for a running instance in VirtualBox.
You may find http://www.toptensoftware.com/VBoxHeadlessTray/ helpful, it has minor bugs if you ask me but nice to have to save what you can do ...
... On console: you might simply do what #terry-wang wrote:
suspend machine by VBoxManage controlvm <NAME_OR_UUID> savestate
restart with gui option VBoxManage startvm <NAME_OR_UUID> --type gui
alternative: start gui manager yourself as terry wrote
revert / make headless from gui: VBoxManage startvm <NAME_OR_UUID> --type headless
Update on VirtualBox 5: VirtualBox GUI has the function to start in Background nativly included now, so still the tool is a shortcut but not even more needed to not be forced using the console
I use:
VBoxManage startvm <NAME_OR_UUID> --type separate
The type separate is experimental according to the documents, but it seems to work in bringing up the GUI after the VM has already been started headless.

Vagrant reset my VM and now I am frightened I lost my work

I have a horrible situation and I hope you can help.
This morning, the terminal opened in my VM hanged, I tried to access Virtualbox and it went unresponsive. I killed Virtualbox manually and typed vagrant up. Vagrant (vagrant ssh) booted on a VM that pretty much seems the default one and I am terrified that all my work has been lost.
Typing vmboxmanage list vms shows:
wasp_1375609265" {29663113-786b-4b8a-adc8-2edecf06bcff}
which is the same UUID I find on the .vagrant file.
I am on a Mac OSX Montain Lion, the version of vagrant I am using is 1.0.6 and Virtualbox is 4.2.16.
Is there any way I can access the image at the previous state it had before I manually killed it? I can't believe that vagrant or Virtualbox purposely overwrote the image with a default one
It turned out that I am an idiot and the image was not lost. For some reasons Virtualbox saved it with a cryptic name and vagrant reverted to the default vagrant box wasp_32... when I run it again. I found the image I was looking for simply running all the *.vmdk I found under ~/VirtualBox VMs.
After that I followed the instructions I found here to make vagrant booting the correct image