Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant Box Breaking After Knife Cookbook Installs

I'm a Vagrant n00b who's having issues getting Vagrant and Chef's knife command to play nice together as I'm setting up a pretty simple CentOS LAMP box using chef-solo.

Here's a quick rundown of ths issue:

  1. I've created a basic Vagrantfile using the CentOS 6.3 w/ Chef base box on vagrantbox.es. You can see the basics in this gist.
  2. I've downloaded all the cookbooks via knife cookbook site install nameofcookbook using a configuration that puts them in ./chef/cookbooks.
  3. I've successfully run vagrant up to You can see the basics in this gist.
  4. I've tested apache, php, etc. All good.
  5. Now comes the trick: with the VM running, I run knife to add another package (in this case i3).
  6. From here on, Vagrant fails to perform various tasks in the VM:
  7. When I run vagrant provision I get an error like this

    The chef binary (either `chef-solo` or `chef-client`) was not found on
    the VM and is required for chef provisioning. Please verify that chef
    is installed and that the binary is available on the PATH.
    
  8. When I run vagrant halt I get an error that the ssh command exited with a non-zero error code.

  9. I am able to run vagrant ssh however, and confirm that (a) chef-solo does, in fact, exist in the box and (b) I can shutdown via the commandline in the box.
  10. When I run vagrant up I get an error like this:
    The following SSH command responded with a non-zero exit status.
    Vagrant assumes that this means the command failed!
    mkdir -p /vagrant</li>
    

I'm stumped. I've had this happen on two boxes already, and I know that Knife and Vagrant should be able to play well together.

What am I doing wrong?

Any help much appreciated, I've very excited about digging into Vagrant!

like image 567
Ethan Winn Avatar asked Oct 29 '12 15:10

Ethan Winn


1 Answers

chef.add_recipe "sudo"

Nuked your sudo file after the first run.

Add the appropriate json to your vagrant file for your vagrant user.

Something like:

config.vm.provision :chef_solo do |chef|

  # add your recipes
  # chef.add_recipe "foo"
  # chef.add_role   "bar"
  chef.json = {
    "authorization" => {
        "sudo" => {
            "users" => [ "vagrant" ],
            "passwordless" => true,
        }
    }
  }
end
like image 94
EnabrenTane Avatar answered Oct 21 '22 05:10

EnabrenTane