Using Vagrant to deploy a server and website

I took on some DevOps challenges that include one to:

Create a vagrantfile that brings up a server with a working data driven website.  The vagrant file is expected to use a configuration management framework such as Chef, Puppet, Ansible, Salt or Docker.

I started by banging out a sample website. See A mini Data Driven site in PHP and MySQL.  I thought that might be the easy part of the challenge.

Next in just a few days, I did an initial dive starting with the getting started guide. I was delighted to learn that Vagrant will not only allow one to configure a real server, but will also allow one to install a virtual server on one’s personal computer.  That simplified the problem in that I would not need to bring Amazon Web Services or something else into the mix for this challenge.

I then did a quick survey of the various configuration management frameworks mentioned above.  I was looking for how to copy files from GitHub using one of the above configuration management software, called from a vagrantfile.  I decided instead to write a Linux shell script function imbedded in the vagrantfile.

I took the approach of doing my own simple configuration management with shell script because I wanted to hit my first goal of bringing up a website from scratch with a vagrantfile as quickly as possible and Vagrant software suggests in a few places to start with a shell script (here,  here, and here).  Also Vagrant has a catalog of pre-configured servers some of which have a ready to go web server stack and GitHub installed as well!  So all I needed to add was script to call GitHub on the server and do some file copying.

I may very well go back and use Docker or some other configuration management software to copy in the website files to my virtual server as a second pass.  Stay tuned.

Conclusion: I was surprised at the relative ease of use Vagrant provides to deploy a server with a single configuration file on one’s personal computer.  I know I just scratched the surface with Vagrant.  However if you’d like to try out Vagrant and bring up a website with a single vagrantfile and the command “vagrant up”, check out my solution at:


Trouble Shooting Section:

On 2/4/2016 after a reboot, running vagrant up in my test folder failed to make my web page available as expected at  Uninstalling and re-installing vagrant seemed to resolve the problem.

Leave a Reply