Vexed by Vagrant

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.

Any Linux experts in the audience? Problems with Suspend

I had to work last night, and before work I was messing around with a laptop, so very little gaming to speak of. When my frustration peaked I did play a little Diablo 3 which felt pretty cathartic, honestly.

So I’m vexed by Linux and this laptop. I have an old Lenovo V570 that was cheap when I bought it a long time ago (it came with Windows 7 pre-installed, that’s how old it is). I had it set up to dual-boot into Linux Mint and Windows 10 Preview. Since Win10 Preview isn’t a thing any longer, the other day I decided to reformat everything and make the laptop a dedicated Linux machine.

I’ve tried two distributions, Ubuntu and Linux Mint and they both have the same problem: the laptop won’t wake up from Suspend. (Granted Mint is based on Ubuntu so I shouldn’t be surprised they have the same issue.) So I close the laptop, then open it and I just get a black screen. Fans might be running but there’s nothing I can interact with. I have to cut power and restart. For all I know maybe the screen just isn’t waking up…it’s hard to say.

If this was a desktop machine I’d probably just roll with it but for a laptop it’s an issue. I looked at /var/log/pm-suspend.log and I don’t see any errors, so I think the problem isn’t the suspend itself, but waking from suspension. I’ve Googled and tried lots of things but it seems like Linux Suspend issues have been with us a long time and it’s tough to get current info. I’ve checked the size of the swap partition, put esoteric scripts in /etc/pm/sleep.d/, tried installing various kernels… so far nothing works.

Currently I have Mint 18.1 installed. Before wiping the laptop I think I had Mint 16.something and it had no issues with Suspend. Now I wish I’d just re-sized the partition rather than wiping everything.

At one point I did see a tip to add something to grub to force it to wake the keyboard. The theory was that when you opened the laptop when it was suspended, the keyboard didn’t ‘wake up’ so it was effectively dead so there was no way to wake the machine. I lost that page in a reboot though and haven’t found it again yet!

I’m not averse to just trying a different distro, if someone can recommend a good distro for noobs that isn’t based on Ubuntu.

Or if anyone has any suggestions on how to fix this issue I’d appreciate that too. In truth I can only work on it so long before frustration mounts since everything I try has to be tested by Suspending the machine, finding that the fix didn’t work, then killing the power, then booting everything up again. It’s pretty time consuming.

Anyone using andLinux?

I read a piece at Linux.com (Run Windows and Linux without virtualization) about andLinux.org today. It’s an Ubuntu system that is supposed to run alongside of Windows. I’m intrigued, but frankly don’t want to mess with my Windows Vista system (used primarily for gaming) any further than installing programs on it. andLinux *seems* to be non-intrusive, but I’d love to hear from someone with firsthand experience with it.

Technorati Tags: ,

Binging on Linux

You know how life throws odd random events at you sometimes. A friend gave me an Ubuntu LiveCD about a week before I was set to go to LinuxWorld. I was only going to LW because it was local and because we do run a few linux servers at work. I figured I could pick up some tips on security or whatever. Plus, it’s always a nice way to recharge your geek batteries, going to an event like this.

Anyway, so I had this LiveCD and I figured, what the heck. And was pretty darned impressed with what I saw of UbuntuLinux. Next thing I know, I was installing a PowerPC version on an old Mac. Then I was salvaging hard drives out of my old PC’s looking for one of a decent size.

And here I am on my ‘gaming rig’ but now its running Ubuntu (dual boot…I still need to play games and poker in Windows).

Honestly I started out just doing it for the geeky fun of doing it, but for whatever reason, the fonts, at least on my LCD screen, are SO MUCH crisper and cleaner under Ubuntu than under Windows, that I’d keep it just for that. And plus, I was checking out Mono at LinuxWorld and I think I want to poke around with it a bit. Granted, Mono runs under Windows or OS X, but I want to develop with it under linux then see what the porting is really like.

But that’s fodder for another post.