Take the 2-minute tour ×

I have a vagrant/chef/Berksfile configuration (at https://github.com/jaycrossler/geoevents-chef-repo/blob/master/cookbooks/geoevents/attributes/default.rb#L5) that is set to pull code from a checked-in github repo. It works great, and every time I run 'vagrant provision', it updates the code from github into the VM.

default['geoevents']['git_repo']['location'] = 'https://github.com/jaycrossler/geo-events.git'

How do I point the chef recipe to instead point to a local git instance, such as ~/app/geo-events.git so that when I make local changes, I can push to the VM for testing? Also, is this the best workflow?

share|improve this question

1 Answer 1

If you either copy your repository below the cookbook folder or add an additional synced folder to Vagrant, you have access to the code on your host.

Newer versions of Chef (at least 11.8, maybe already 11.6) have the whole file-based providers rewritten and they should also accept file:/// urls. If you did not add an additional synced folder, you can access your code through file:///vagrant/geoevents-repo, which is below the vagrant synced folder pointing to your cookbook folder, existing by default. This has now to be set as the new location by passing JSON data to the chef provisioner in Vagrantfile:

config.vm.provision :chef_solo do |chef|
  chef.json = {
    :geoevents => {
      :git_repo => {
        :location => "file:///vagrant/geoevents-repo"

If you add an additional synced folder, you, of course, have to adjust the URL.

EDIT: As you write that it does not work with chef.json, try the following chef role, place it e.g. in roles/geoevents_local.rb and add it to your run list (in the Vagrantfile):

name "geoevents_local"

  "geoevents" => {
    "git_repo" => {
      "location" => "file:///vagrant/geoevents-repo"
share|improve this answer
Thanks - I tried that approach and it only partially worked for me. I set up [config.vm.synced_folder "../geoevents", "/vagrant/geoevents-repo"], which worked great (thanks!), but when I did the chef.json piece you recommend, it still points to the online repo. Things do work if I either ssh in and create a simlink to that new directory, or put that location in the recipe directly... but the Vagrantfile setting doesn't seem to overwrite the one in attributes/default.rb –  JayCrossler Jan 15 at 17:09
That's weird. I would expect that it overrides, wouldn't make so much sense otherwise. Can you create a chef role that overrides this attribute?. –  StephenKing Jan 15 at 21:57
Did you "reload" the instance after you setup the shared folder? Vagrant only adds the shares at boot. –  sethvargo Jan 16 at 3:35
He wrote that the synced folder thing worked for him. But did you really reload the VM and provision it? Newer versions of Vagrant (IIRC 1.3+) do not automatically provision on reload anymore. That might be why the repo still points to the old location (without looking up, I'm not even sure, if the git resource will change the source, if the ref already matches, so better also delete the old repo in the VM). –  StephenKing Jan 16 at 7:05
Yeah, I rebuilt the entire server to test. 'vagrant destroy', 'vagrant up', 'vagrant provision'. I'm reading through the role documentation now, looks like the best solution. Will let you know - thanks for all the guidance. –  JayCrossler Jan 16 at 15:37

Your Answer


