Search code examples
vagrantchef-infrachef-solovagrantfile

Chef Vagrant, Can't Find Folder


Chef is really confusing me. Can you help me understand why it's not working?

Cliff Notes

  • I'm using Chef-Solo (not Berkshelf or anything else)
  • Everything works when I set it up from scratch, I can vagrant provision
  • But if I reboot the HOST (My main operating system) it breaks!
  • It appears to be looking inside a .chef folder which I did not specify in my vagrant configuration.
  • I have to do a vmboxmanage box destroy ubuntu/trusty64 and redownload everything and redo vagrant up if I reboot.
  • Vagrant Version 1.7.2
  • Virtual Box Version 4.3.20r96996

Inside Vagrant SSH Error:

Note: The files are not pointing to the .chef folder, but they are here?

[2015-01-30T16:23:44+00:00] WARN: Did not find config file: 
/etc/chef/solo.rb, using command line options.

[2015-01-30T16:23:50+00:00] FATAL: None of the cookbook paths set in
Chef::Config[:cookbook_path], 
["/vagrant/.chef/cookbooks", "/vagrant/.chef/site-cookbooks"], 
contain any cookbooks

$vagrant up and $ vagrant provision error:

==> default: Mounting shared folders...
default: /vagrant => /home/jesse/if/indieflix/vagrant
default: /home/vagrant/chef-recipes => /home/jesse/projects/if/vagrant/chef-recipes
default: /home/vagrant/chef-resources => /home/jesse/projects/if/vagrant/chef-resources

==> default: Running provisioner: chef_solo...
==> default: Detected Chef (latest) is already installed
Shared folders that Chef requires are missing on the virtual machine.
This is usually due to configuration changing after already booting the
machine. The fix is to run a `vagrant reload` so that the proper shared
folders will be prepared and mounted on the VM.

And, vagrant reload does nothing.

Vagrantfile

# ...
config.vm.synced_folder "chef-recipes", "/vagrant/chef-recipes"
config.vm.synced_folder "chef-resources", "/vagrant/chef-resources"
# ...
config.vm.provision "chef_solo" do |chef|
    # Relevant to the Vagrantfile path
    chef.cookbooks_path = ["chef-recipes"]

    # This is just required by Chef, so it's minimal
    chef.environments_path = "chef-resources/environments"

    # This is the internal flag.
    chef.environment = "development"

    # This defines the cookbooks to run
    chef.roles_path = "chef-resources/roles"
    chef.add_role("development")
end

Folder Structure

chef-recipes/    (Git Submodule)
----python/
--------recipes/
------------default.rb
------------pip.rb
chef-resouces/   (Git Submodule)
----environments/
--------development.json
----roles/
--------development.json
Vagranfile

Solution

  • Anthony suggested in a comment I answer my question since it was answered in comments. Here it is!

    Instead of using curl to install, I used omnibus which adds another step before provisioning:

    $ vagrant plugin install vagrant-omnibus 
    

    Second, Chef-Solo/Vagrant has an issue with mounting files from the Host. The only workaround I have found is:

    $ rm .vagrant/machines/default/virtualbox/synced_folders vagrant reload --provision 
    

    Optional: I created a bash script to make the above a little quicker:

    reprovision.sh

    #/bin/bash
    rm .vagrant/machines/default/virtualbox/synced_folders
    vagrant reload --provision
    

    And of course chmod +x reprovision.sh and to run ./reprovision.sh