I am into my first full day back after WordCamp Atlanta (#wcatl) and have caught up on most of my inbox, Twitter, and Facebook communications. As I head into a new week of WordPress plugin production I decided now is as good a time as any to update my work flow.
I learned a lot of new things at WordCamp and if there is one thing I’ve learned from past experience it is DO NOT WAIT. I find the longer I take to start implementing an idea the less chance I have of executing.
My first WordCamp Atlanta 2014 work flow improvement starts right at the base level. Setting up a clean local development box. I had started this process last week by manually configuring a baseline CentOS box and was about to setup MySQL, PHP, and all the other goodies by hand. That was before I learned more about exactly what Vagrant can do. I had heard of Vagrant but did not fully internalize how it can help me. Not until this past weekend, that is.
My Work Environment
Before I outline my experience with the process I will share my plugin development work environment.
- Host System: Windows 8.1 64-bit on an HP Zbook laptop with 16GB of RAM with a 600GB SATA drive
- Guest System: CentOS 6.5 (latest build) with 8GB RAM on an Oracle VirtualBox virtual machine
- Linux Kernel 2.6.32-431
- PHP v5.4.23
- MySQL v 14.14 dist 5.5.35
- Dev Took Kit: NetBeans, SmartGit, Apigen and phpDoc, MySQL command line, vim
While that is my TYPICAL development environment, every-so-often I swap something out such as the MySQL version or PHP version and it is a HUGE PAIN. This is where Vagrant should help. I can spin up different virtual boxes such as a single-monitor versus three-monitor configuration when I am on the road or a box with a different version of PHP. At least that is the theory anyway. For now I want to focus on getting a “clean” CentOS 6.5 build with my core applications running so I can get back to releasing the Store Locator Plus Enhanced Results add-on pack this week.
Getting Started With Vagrant
The Rockin’ Local Development With Vagrant talk that Russel Fair gave on Saturday had me a bit worried as he was clearly on the OS/X host and the examples looked great from a command line standpoint. Being a Linux geek I love command line, but I am not about to run virtual development boxes in in a VirtualBox guest. Seems like a Pandora’s box to me… or at least a Russian doll that will surely slow down performance. Instead I want to make sure I have Vagrant running on my Windows 8.1 bare metal host. That is very much against my “full dev environment in a self-contained and portable virtual environment” standard, but one “helper tool” with configurations backed up to my remote Bitbucket repository shouldn’t be too bad, as long as I don’t make it a habit to put dev workflow tools on my host box. Yes, Vagrant does have a Windows installer and I’m fairly certain I won’t need to be running command-line windows to make stuff work. If I’m running Windows I expect native apps to be fully configurable via the GUI. Worst case I may need to open a text editor to tweak some files, but no command line please.
Here is the process for a Windows 8.1 install.
- Download Vagrant.
- Install needs to be run as admin and requires a system reboot.
- Ok… it did something… but what? No icons on the desktop or task bar or … well… anywhere that I can find!
Well… sadly it turns out that Vagrant appears to be a command line only port of the Linux/OSX variants. No desktop icons, no GUI interface. I get it. Doing that is the fast and easy process, but to engage people on the Microsoft desktop you really do need a GUI. Yes, I’m geek enough to do this and figure it out. I can also run git command line with no problem but I am FAR more efficient with things like the SmartGit GUI interface.
Maybe I’m not a real geek, but I don’t think using command line and keyboard interaction as the ONLY method for interacting with a computer makes you a real techie. There is a reason I use a graphical IDE instead of vim these days. I can do a majority of my work with vim, but it is FAR more efficient to use the GUI elements of my code editor.
Note to Vagrant: if you are doing a windows port at least drop a shortcut icon on the desktop and/or task bar and setup a Windows installer. Phase 2: consider building a GUI interface on top of the command line system.
It looks like Vagrant is a lower-level command line tool. It will definitely still have its place, but much like git, this is a too on which other “helpers” need to be added to make my workflow truly efficient. Time to see what other tools are out there.
Kinda GUI Vagrant : PuPHPet
Luckily some other code geeks seem to like the idea of GUI configuration system and guess what? Someone created a tool called PuPHPet (which I also saw referenced at WordCamp so it must be cool) and even wrote an article about Vagrant and Puppet. Puppet is a “add on”, called a provisioner, to setup the guest software environment.
PuPHPet is an online form-based system that builds the text-file configuration scripts that are needed by Vagrant to build and configure your Virtualbox (or VMWare) servers. It is fairly solid for building a WordPress development environment, but it does mean reverting back to CentOS 6.4 as CentOS 6.5 build scripts are not online. Though I am sure I can tweak that line of the config files and fix that, but that takes me one-step away from the “point and click” operation I am looking for.
Either way, PuPHPet, is very cool and definitely worth playing with if you are going to be doing any WordPress-centric Vagrant work.
Puppet Makes Vagrant and PuPHPet Smarter
Now that I have Vagrant installed and I discovered PuPHPet I feel like I am getting closer to a “spin me up a new virtual dev box, destroy-as-desired, repeat” configuration. The first part of my workflow improvement process. BUT…. I need one more thing to take care of it seems… get Puppet installed. I managed to wade through the documentation (and a few videos) to find the Windows installers.
Based on what is coming up in the install window it looks like the installer will roll out some Apache libs, ruby, and the windows kits that help ruby run on a windows box.
Again, much like Vagrant, Puppet completes the installation with little hint of what it has done. Puppet is another command line utility that runs at a lower-level to configure the server environments. It will need some of the “special sauce” to facilitate its use. A little bit of digging has shown that the Puppet files are all installed under the C:\Program Files (x86)\Puppet Labs folder. On Windows 8.1 the “Start Menu” is MIA, so the documentation about finding shortcuts there won’t help you. Apparently those shortcuts are links to HTML doc pages and some basic Windows shell scripts (aka Batch Files) so nothing critical appears to have gone missing.
The two files that are referenced most often are the puppet and facter scripts, so we’ll want to keep track of those. I’ll create a new folder under My Documents called “WP Development Kit” where I can start dumping things that will help me managed my Windows hosted virtual development environment for WordPress. While I’m at it I will put some links in there for Vagrant and get my PuPHPet files all into a single reference point.
Now to get all these command line programs to do my bidding.
Getting It Up
After a few hours or reading, downloading, installing, reading some more, and chasing my son around the house as the “brain eating dad-zombie”, I am ready to try to make it all do something for me. Apparently I need to use something called a “command line”. On Windows 8.1.
I’m giving in with the hopes that this small foray into the 1980’s world of command line system administration will yield great benefits that will soon make me forget that DOS still exists under all these fancy icons and windows. Off to the “black screen of despair”, on of the lesser-known Windows brethren of the “blue screen of death”. Though Windows 8 tries very hard to hide the underpinnings of the operating system, a recent Windows 8 patch and part of Windows 8.1 since “birth” is the ever-useful Windows-x keyboard shortcut. If you don’t know this one, you should. Hold down the Windows key and press x. You will get a Windows pop-up menu that will allow you to select, among many other things, the Command Prompt application.
If you right-click on the “do you really want to go down this rabbit hole” confirmation box that comes up with the Command Prompt (admin) program you will see that it is running C:\Windows\system32\cmd.exe. This will be useful for creating a shortcut link that will allow me to not only be in command mode but also to be in the “source” directory of my PuPHPet file set. I’m going to create a shortcut to that application in my new WP Development Kit directory along with some new parameters:
- Search for cmd.exe and find the one in the Windows\system32 directory.
- Right-click and drag the file over to my WP Development Kit folder, selecting “create shortcuts here” when I drop it.
- My shortcut to cmd.exe is put in place, but needs tweaking…
- Right-click the shortcut and set the “Start in” to my full WP Development Kit folder.
Now I can double-click the command prompt shortcut in my WP Development Kit folder and not need to change directory to a full path or “up and down the directory tree” to get to my configuration environment.
A few key presses later and I’ve managed to change to my downloaded PuPHPet directory and execute the “vagrant up” command. Gears starting whirring, download counters started ticking, and it appears the PuPHPet/Vagrant/Puppet trio are working together to make something happen. At the very least it is downloading a bunch of stuff from far away lands and filling up my hard drive. Hopefully with useful Virtualbox disk images and applications required to get things fired up for my new WordPress dev box.