This Hugo Blog in a Vagrant Environment

Vagrant from Hashicorp is great way to abstract away from virtualization or infrastructure technology like Virtualbox, VMware, Microsoft HyperV, Cloud Providers etc. You just declare what you need and like magic everything is ready for use after some minutes.

Cutting to the chase here is my setup to edit this Blog. Of course I need Vagrant installed, but this is not a problem as I use it in my everyday Job also.

myboxname = "gabi"

Vagrant.configure("2") do |config| = "ubuntu/xenial64"
  config.vm.hostname = myboxname
  config.vm.box_check_update = false "private_network", ip: ""
  config.vm.synced_folder "./data", "/data"

  config.vm.provider "virtualbox" do |vb|
     vb.gui = false = myboxname
     vb.memory = "512"
     vb.linked_clone = true

  # Provides updated git
  config.vm.provision "git", type: "shell" do |s|
    s.inline = <<-SHELL
      apt-get update
      apt-get install -y apt-transport-https ca-certificates software-properties-common
      apt-get update
      add-apt-repository -y ppa:git-core/ppa
      apt-get install -y git
      git --version

  # Install Hugo binary (no Go interpreter needed)
  config.vm.provision "hugo", type: "shell" do |s|
    s.inline = <<-SHELL
      cd /usr/local/bin
      TARFILE=hugo_${HUGOVER}_Linux-64bit.tar.gz CHKFILE=hugo_${HUGOVER}_checksums.txt
      wget -q --no-check-certificate${HUGOVER}/$TARFILE -O $TARFILE
      wget -q --no-check-certificate${HUGOVER}/$CHKFILE -O $CHKFILE 
      sha256sum --ignore-missing -c $CHKFILE || exit 1
      tar xf $TARFILE
      rm -f $TARFILE $CHKFILE
      hugo version

What do you have?

  • Ubuntu Xenial with up to date Git installation & Hugo 0.46 binary.
  • Mounts the path data to /data where you can clone your blog.
  • You can edit the Blog from within the vagrant box or from the host machine using the mounted path.

See my notes here to get more details.