I recently got hands on an abandonned laptop that was better than the one I was currently using for my personnal hackings, so I decided to switch to this one. I felt this was the time to learn Vagrant and save me some time later on. I settled on creating a Vagrant environment for this Octopress blogging. That proved a lot longer than I thought it would.
If you want to jump to the solution, just have a look at this git change. Here is the slightly longer version.
Add a Vagrantfile and setup a VM. There are explainations about how to do this all over the web, that was easy.
Provision your VM. That proved a lot more complex. There are a lot of examples using variants of Chef, but the steep learning curve for Chef seemed unneccessarily complex compared to what I wanted to do. Eventually, I figured it out using simple shell provisioning.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
Setup port forwarding. That should have been simple … after forwarding port 4000 to 4000, I could still not manage to access my blog preview from the host machine. After searching throughout the web for a long time, I eventually fixed it with by adding
--host 0.0.0.0to the rackup command line in Octopress Rackfile
Setup ssh forwarding. In order to be able to deploy to github pages with my local ssh keys, I added the following to my Vagrantfile.
1 2 3 4 5 6 7 8 9 10 11
- Fix virtual box synced folder. When I tried to pimp my favicon up, changing the png in the host machine did not update it on the guest ! I lost almost 3 hours figuring this out … searching google, I eventually found that Virtual Box synced folders can have issues, and that installing the guest additions is recommended. For this, just enter the following in the command line from your project’s working dir :
I’ll tell you if this does not do the trick.
I admit it was a lot longer than I expected it to be, but at least now it’s repeatable !
Next steps will be to use Docker providers and Dockerfile to factorize provisioning and speedup up VM startup.