therobyouknow
therobyouknow

Reputation: 6790

Where are cookbooks stored on Vagrant vm? / Setup needed?

As part of diagnosing problems with my Vagrant VM, I issued

vagrant@lucid32:~$ sudo mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` v-csc-1 /tmp/vagrant-chef-1/chef-solo-2/cookbooks

And I get:

/sbin/mount.vboxsf: mounting failed with the error: No such file or directory

Various blogs around the web indicate that this is a path problem, likely to do with where the cookbooks are setup on the VM itself and also where the Vagrantfile (on the host) is instructing Chef to find them. So questions:

Background My problems are stemming from trying to find a definitive, complete end-to-end guide to set up a common all-garden vanilla LAMP stack on a VM on Windows 7 64bit host. I have done much research and used http://iostudio.github.com/LunchAndLearn/2012/03/21/vagrant.html and added the following code from that in my Vagrantfile

 config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = ["cookbooks","site-cookbooks"]
    chef.add_recipe "apt"
    chef.add_recipe "openssl"
    chef.add_recipe "apache2"
    chef.add_recipe "mysql"
    chef.add_recipe "mysql::server"
    chef.add_recipe "php"
    chef.add_recipe "php::module_apc"
    chef.add_recipe "php::module_curl"
    chef.add_recipe "php::module_mysql"
    chef.add_recipe "apache2::mod_php5"
    chef.add_recipe "apache2::mod_rewrite"
    chef.json = {
        :mysql => {
            :server_root_password => 'root',
            :bind_address => '127.0.0.1'
        }
    }
  end

The problem I am seeing is that there is plenty of advice on the web but: - there are varying solutions to the problem - they don't precisely specify their starting point/pre-requisite i.e. the state of their setup before their solution is to be applied so you can't know if your problem is the same as theirs

Upvotes: 1

Views: 1760

Answers (1)

Draco Ater
Draco Ater

Reputation: 21206

So as I said in the comment:

chef.cookbooks_path = ["cookbooks","site-cookbooks"]

This line shows the relative path from the Vagrantfile to cookbooks directory in the host system. If full path to your Vagrantfile is C:\Users\<user>\<folder to hold vagrant setup>\Vagrantfile, then there should be 2 directories:

  1. C:\Users\<user>\<folder to hold vagrant setup>\cookbooks

    This should hold your cookbooks.

  2. C:\Users\<user>\<folder to hold vagrant setup>\site-cookbooks

    This should hold site cookbooks (cookbooks that are downloaded from chef-community in case you hold them separately).

In current setup these are the 2 directories, that vagrant will mount in guest OS and search for cookbooks. You get the error, because there are no such directories in your setup.

You must provide the cookbooks' path, because otherwise vagrant does not know where to take them from. Chek out Setting the Cookbooks Path help page of Vagrant.

Upvotes: 1

Related Questions