MySQL 8 Community Edition on Vagrant VM

As I mentioned in my previous blog, I have been working on a personal project that allows us to provision a test Vagrant VM that has MySQL 8 Community Edition installed. The combination between Vagrant and Ansible made this possible.

I put the code up in GitHub for your consumption and feedback.

When you do vagrant init [url], it creates Vagrantfile. The Vagrantfile has the configuration of the Vagrant VM. You can have Ansible file in the Vagrant file to automatically execute when the Vagrant VM starts.

So yeah, please read the README file to start to use it. Any feedback and pull requests are welcome! 🙂

VS Code Remote SSH Development

Though I love Linux Mint, I still have my Surface Pro 7 laptop for my personal mobile use. There is nothing I really need Windows for now but I just have it around when I need to be somewhere else to do my personal work.

I’m away from my desk but I want to continue to work on my personal project I started on my Linux Mint. Sure I can continue to do it through SSH in terminal using vim but I want to use my favorite editor like Visual Studio Code. I looked around how I could edit my code remotely. I found Visual Studio Code Remote Development extension. I was able to connect my VS Code on my Windows via SSH and directly edit the files.

I followed an instruction on remote development using SSH and I was able to start to use it. It’s quite easy to follow so I high recommend it!

Vagrant Error

I came across a situation where “vagrant up” just wasn’t successful. “vagrant halt” and “vagrant destroy” didn’t do it. I even removed everything from ~/.vagrant.d but it still kept on failing with 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: ["import", "/home/hiriumi/.vagrant.d/boxes/oraclelinux-VAGRANTSLASH-7/7.9.289/virtualbox/box.ovf", "--vsys", "0", "--vmname", "OL7U9_x86_64-vagrant-virtualbox-b289_1643606820210_37412", "--vsys", "0", "--unit", "11", "--disk", "/media/hiriumi/extra/OL7U9_x86_64-vagrant-virtualbox-b289_1643606820210_37412/box-disk001.vmdk"]

Stderr: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Interpreting /home/hiriumi/.vagrant.d/boxes/oraclelinux-VAGRANTSLASH-7/7.9.289/virtualbox/box.ovf...
OK.
0%...
Progress state: NS_ERROR_INVALID_ARG
VBoxManage: error: Appliance import failed
VBoxManage: error: Code NS_ERROR_INVALID_ARG (0x80070057) - Invalid argument value (extended info not available)
VBoxManage: error: Context: "RTEXITCODE handleImportAppliance(HandlerArg*)" at line 1119 of file VBoxManageAppliance.cpp

I even opened VirtualBox to check if a leftover VM was still there but there wasn’t. When I navigated to the directory where VirtualBox creates VMs and there was a directory leftover from the failed instance. I manually removed the directory where VirtualBox stores VM files and did “vagrant up” and then things came back to normal.

Hope this helps someone out there. 🙂

Vagrant Images

There are vagrant images out there. I’m starting to look into more images to play with. You can find Oracle Linux vagrant images here.

HashiCorp’s Vagrant Cloud has a selection of available images for different providers. There are not as many as I thought but it’s good enough to spin up test environment.

Now I’m thinking… would Ansible work with Vagrant? I’ll find out!

Vagrant

I had a chance to learn vagrant at work. It is created by Hashicorp which is the creator of Terraform. I love what they have done. You can easily provision a VM locally and manage them. Looks like it requires VirtualBox as its hypervisor. You may want to install it beforehand. I learned that VirtualBox and Hyper-V can co-exist if you are on Windows.

To install Oracle Linux 7 VM, you can…

vagrant init oraclelinux/7 https://oracle.github.io/vagrant-projects/boxes/oraclelinux/7.json

You may want to decide which directory you init it from because it places Vagrantfile which has configurations of the VM. You can make changes to it as you see fit.

To start the vagrant VM, execute…

vagrant up

Just like that you can spin up a VM. To get into the VM via ssh, just enter…

vagrant ssh

You can do port forwarding to the VM so you can spin up test environment on the VM.

This is the best toy I have had in the last year or so. 🙂

Edit: There are other types of providers that Vagrant supports. Hyper-V is one of them, so it should work with Hyper-V as well. https://www.vagrantup.com/docs/providers