blog.dasrecht.net

With a min of max the opt!

Vagrant : Using the Git configuration of the host machine


As we continue to use our Vagrant Setup at Amazee Labs for our Projects, we face the problem that the git configuration is not added to the box itself, which leads to many commits from “vagrant@localhost” which makes my inner DevOps-me very angry.

Vagrant has a built-in “file” provisioner, which I want to run if a file is present on the host machine. After some playing around, I found issue 3021 on Github and got the information needed to spot the Home Directory (yes, by using the environment variable of the user) and just copied the config to the box.

config.vm.provision :file, source: '~/.gitconfig', destination: '/home/vagrant/.gitconfig' if File.exists?(ENV['HOME'] + '/.gitconfig')

Yay! No vagrant@localhost commits anymore!


One response to “Vagrant : Using the Git configuration of the host machine”