Home
About
Social
Characters
Jaded's Pub
YouTube

We (the company I work for) have a suite of sites that have been having performance issues. We’ve done a few optimization passes and they’ve helped, but not enough and we were seeing diminishing returns. Finally I got approval to beef up hosting for them. I was over-joyed because for once here was a solution to the problem that wasn’t going to be a big headache.

Boy was I wrong. I didn’t factor in that the newer hosting plan was running more recent versions of Ubuntu, PHP and MySQL. The ISP moved the sites for us…and they blew up. *sigh* Fortunately they were able to roll things back, but now it’s up to me to figure out how to get these sites running on newer software.

I didn’t want to update my dev server and potentially blow up a bunch of other sites, so I turned to Vagrant. I’ve been looking for a good reason to use it and this seemed like the ideal situation. I know the cool kids all use Docker now but I still haven’t really wrapped my head around Docker yet. Vagrant feels reasonably intuitive to me.

Soon enough I was off to a good start. I pulled down the ‘official’ (Canonical-supplied) Ubuntu 16 Vagrantbox, installed Apache, PHP and MySQL. Everything was looking good; it was serving pages through a forwarded port. The next step was to create a custom box from the server as it was running. The idea is that you create this Vagrant box with all the software configured the way you want it, then you can spin up identical virtual machines really easily. You can give a less tech-savvy co-worker (yes, they do exist even though I’m a NOOB) a copy of the box and with a minimum of instruction they can spin up an identical setup.

So I did that…and something went wrong. When I spun up a Vagrant VM from my box, I couldn’t SSH to it. Seemed to be an issue with the SSH keys or something. It wasn’t a complete train wreck…Apache was still serving pages via a directory shared between Windows and the VM, so I could have forged ahead but I knew that sooner or later I was going to want to SSH into the virtual machine for something.

Off to Google to find out what I’d done wrong. And oy, did I find a lot of info. I wasn’t the first one to have this issue, but some of the bug report threads started in 2014 and ran up to last week. I found a dozen or more fixes, none of which seemed to work for everyone. Most of the fixes involved SSHing into the VM using a username and password, which, I read time and time again, is vagrant/vagrant (obviously these aren’t production boxes). But try as I might I couldn’t log in with username and password. I could connect to the port so I knew SSH was running but I couldn’t authenticate.

I went further and further down the rabbit hole, eventually uninstalling Vagrant and VirtualBox and starting from scratch, all to no avail.

About 5 hours into this process, I found a new post about it. Apparently the official Ubuntu 16 boxes don’t use vagrant/vagrant as the username and password, even though they are ‘supposed’ to according to Vagrant’s guidelines. Instead they use ubuntu as a username and no one seems to know what the password is.

To say I was frustrated to learn this would be quite an understatement. The fix for the bug is apparently to use the v0rtex/xenial box which is set up with a vagrant/vagrant account. You can read more about the bug here.

So now I’m back to square one and tomorrow I’ll install a LAMP stack on the vortex/xenial box, then try packaging it again. Still think I’m doing something wrong with my packaging, unfortunately. Today was wasted by a bug that was preventing me from fixing a different problem, more or less. That’s going to look great on my weekly productivity report. /sigh

Maybe I should’ve tried Docker after all…

[Update: SOLVED (I hope)]

OK I finally got a working box, here’s what I did, based on the info in this thread.

You start in your existing VM — the one you’re going to build from.

Add
config.ssh.insert_key = false
to the Vagrant file

vagrant up
to start the machine.

vagrant ssh
to SSH in.

Run these commands:

wget https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub -O .ssh/authorized_keys
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
chown -R vagrant:vagrant .ssh

Exit your SSH session.

Now create your new box. I followed these instructions

For me the command was

vagrant package --base arcus_default_1484688088638_34762 --output ../arcusv2.box

where “arcus_default_1484688088638_34762” is the name of the VM I wanted to base the box off of..you get this from VirtualBox. And I was naming my new box arcusv2.box and putting it one level up in my directory tree.

Then create a new directory, move into it.

Do something like this to add the new box
vagrant box add arcusv2 ../arcusv2.box

Then
vagrant init
to create the initial vagrantfile. Add
config.vm.box = "arcusv2"
config.ssh.insert_key = false

(obviously substitute whatever you named your new box for ‘arcusv2’)

And finally

vagrant up

And if you’re lucky like I was, the box will start up without authentication errors.



Comments:
2
  • Ugh Docker. When my company moved over to Docker the devs lost almost a week and a half of productive time due to issues and debugging.

    It’s pretty dumb of Vagrant to not have the correct documentation and default usernames and passwords.

    Also, I really don’t miss having to do server administration and worrying about versions of OS’s and such. I feel for you. Good luck tomorrow.

  • It’s strange that it’d ignore a convention that breaks ssh for… everyone but them, apparently. Hopefully there aren’t any other gotchas down the road. This kind of thing IS worth it, it just might be unappreciated until you literally come back with “5 of the sites crash X% less”. Ask for a raise on that same day.

    For sprint purposes, investing a little time now to save a lot more later on is a no-brainer, so no worries there… »\_(?)_/»