Vagrant Provision, Chef Error: You must specify at least one cookbook repo path - vagrant

I'm trying to set up Vagrant for web development, on Windows 8.1. I've already hit the problem undefined method “cheffish” for nil:NilClass, so am using Vagrant 1.7.4 with Chef 12.3.0.
I can't solve this error:
ERROR: You must specify at least one cookbook repo path
from:
c:\web\project>vagrant provision
==> default: The cookbook path 'c:/web/project/cookbooks' doesn't exist. Ignoring...
==> default: The cookbook path 'c:/web/project/site-cookbooks' doesn't exist. Ignoring...
==> default: Chef 12.3.0 Omnibus package is already installed.
==> default: Running provisioner: chef_solo...
==> default: Detected Chef (latest) is already installed
Generating chef JSON and uploading...
==> default: Running chef-solo...
==> default: stdin: is not a tty
==> default: [2015-07-21T10:08:00+00:00] INFO: Forking chef instance to converge...
==> default: Starting Chef Client, version 12.3.0
==> default: [2015-07-21T10:08:00+00:00] INFO: *** Chef 12.3.0 ***
==> default: [2015-07-21T10:08:00+00:00] INFO: Chef-client pid: 1813
==> default: [2015-07-21T10:08:01+00:00] INFO: Setting the run_list to ["recipe[apt]", "recipe[nodejs]", "recipe[postgresql]", "recipe[postgresql::ser
ver]", "recipe[postgresql::client]"] from CLI options
==> default: [2015-07-21T10:08:01+00:00] INFO: Run List is [recipe[apt], recipe[nodejs], recipe[postgresql], recipe[postgresql::server], recipe[postgr
esql::client]]
==> default: [2015-07-21T10:08:01+00:00] INFO: Run List expands to [apt, nodejs, postgresql, postgresql::server, postgresql::client]
==> default: [2015-07-21T10:08:01+00:00] INFO: Starting Chef Run for vagrant-ubuntu-trusty-64
==> default: [2015-07-21T10:08:01+00:00] INFO: Running start handlers
==> default: [2015-07-21T10:08:01+00:00] INFO: Start handlers complete.
==> default: Running handlers:
==> default: [2015-07-21T10:08:01+00:00] ERROR: Running exception handlers
==> default: Running handlers complete
==> default: [2015-07-21T10:08:01+00:00] ERROR: Exception handlers complete
==> default: [2015-07-21T10:08:01+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: Chef Client failed. 0 resources updated in 0.736170145 seconds
==> default: [2015-07-21T10:08:01+00:00] ERROR: You must specify at least one cookbook repo path
==> default: [2015-07-21T10:08:01+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Use Ubuntu 14.04 Trusty Tahr 64-bit as our operating system
config.vm.box = "ubuntu/trusty64"
# Configurate the virtual machine to use 2GB of RAM
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
# Forward the Rails server default port to the host
config.vm.network :forwarded_port, guest: 8000, host: 8000
# config.omnibus.chef_version = :latest
config.omnibus.chef_version = "12.3.0"
# Use Chef Solo to provision our virtual machine
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = ["cookbooks", "site-cookbooks"]
chef.add_recipe "apt"
chef.add_recipe "nodejs"
chef.add_recipe "postgresql"
chef.add_recipe "postgresql::server"
chef.add_recipe "postgresql::client"
chef.json =
{
postgresql: {
users: [
{
"username" => "postgres",
"password" => "password",
"superuser" => true,
"replication" => false,
"createdb" => true,
"createrole" => false,
"inherit" => true,
"replication" => false,
"login" => true
}
]
}
}
end
end
Cheffile
site "http://community.opscode.com/api/v1"
cookbook 'apt'
cookbook 'nodejs'
cookbook 'build-essential'
cookbook 'postgresql', git: 'https://github.com/phlipper/chef-postgresql'
This vagrant-berkshelf issue looked similar, but deleting .vagrant.d, reloading and provisioning again didn't solve it.
What's causing this?
Thanks!

I installed Chef Dev Tools as this is the simplest way to install Berkshelf 3.0 on Windows. I set up a Berksfile in my project, based on my Cheffile, and enabled Berkshelf in the Vagrantfile. Now it provisions using Berkshelf, and it works.
Given there was no indication that Vagrant was using Berkshelf, I'm still not convinced that Berkshelf was the issue.
It would still be helpful to know how to install the latest Berkshelf version without Chef Dev Tools on Windows.

Related

I want to run a basic Windows guest on OSX with Vagrant, but I keep getting authentication failures

I'm trying to run a Windows 10 guest on an OSX host.
I've installed the latest versions of Vagrant, VirtualBox. I set up a very basic Vagrantfile as follows:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "Microsoft/EdgeOnWindows10"
config.vm.box_version = "1.0"
end
When I try to start Vagrant by executing "vagrant up", I get the following console output which ends with a neverending series of Authentication failure error messages.
TCR-C02X29QPJHC9:automation salimfadhley$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'Microsoft/EdgeOnWindows10'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'Microsoft/EdgeOnWindows10' version '1.0' is up to date...
==> default: Setting the name of the VM: automation_default_1548152471264_36082
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2200
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
I don't need Edge - I just need Windows and possibly some dot-Net runtimes. I'd like to get started by getting any Windows image up and running.
You probably just need to use the following in your Vagrantfile:
config.vm.communicator = "winrm"
This option is described here, and you can further configure winrm with the settings listed here.

Vagrant 'pre-boot' VM customization error

What is the cause of this particular error?
I have the latest version of VirtualBox (5.2.22-126460) and Vagrant (2.2.2).
Those are running on a freshly installed Windows 10 operating system.
Whenever I try to 'vagrant up' my machine I get this following output:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Vagrant has detected a configuration issue which exposes a
==> default: vulnerability with the installed version of VirtualBox. The
==> default: current guest is configured to use an E1000 NIC type for a
==> default: network adapter which is vulnerable in this version of VirtualBox.
==> default: Ensure the guest is trusted to use this configuration or update
==> default: the NIC type using one of the methods below:
==> default:
==> default: https://www.vagrantup.com/docs/virtualbox/configuration.html#default-nic-type
==> default: https://www.vagrantup.com/docs/virtualbox/networking.html#virtualbox-nic-type
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 1080 (guest) => 1080 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
A customization command failed:
["modifyvm", :id, "--cableconnected0", "on"]
The following error was experienced:
#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["modifyvm", "22fda01f-9b13-43f9-bf0d-4deb81c688c8", "--cableconnected0", "on"]
Stderr: VBoxManage.exe: error: Invalid NIC number 0
>
Please fix this customization and try again.
Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "local.1400degrees.com"
config.vm.hostname = "local.website.com"
config.vm.synced_folder ".", "/vagrant", :mount_options => ["dmode=777,fmode=777"]
config.vm.network "forwarded_port", guest: 1080, host: 1080
config.vm.network "private_network", ip: "192.168.33.13"
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.ssh.username = 'vagrant'
config.ssh.password = 'vagrant'
config.ssh.insert_key = false
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
end
end
Per this github issue a solution can be to
1.first of all destroy the virtual box with vagrant destroy
2.navigate to C:\Users\YOUR_USERNAME
3.delete the .vagrant.d folder
4.go into VirtualBox VMs folder and delete everything inside it.
5.start it again with vagrant up
You can get more in depth logs by using vagrant up --debug or if you would like to save it to a file vagrant up --debug &> vagrant.log. Also, a great thing about this is you can always tear it down and start over :)
I believe the real reason this is happening is due to this: https://github.com/hashicorp/vagrant/issues/10481
The fix was already merged to the vagrant master branch, however it will probably be included in version 2.2.5 or later. Latest vagrant version as of writing this up is 2.2.4 and the bug is still present.
The fix that was done:
In plugins/providers/virtualbox/action/set_default_nic_type.rb
They changed the code from E1000_SUSCEPTIBLE = Gem::Requirement.new("<= 5.2.22").freeze to E1000_SUSCEPTIBLE = Gem::Requirement.new("< 5.2.22").freeze

Cannot use chef provisioning in vagrant

I created a basic vagrant box and config provisioning as below
config.vm.provision :chef_solo do |chef|
chef.add_recipe "apache2"
chef.json = { :apache => { :default_site_enabled => true } }
end
I also add cookbook to my project
git submodule add https://github.com/svanzoest-cookbooks/apache2/ cookbooks/apache2
But when I run vagrant provision, I get this
==> default: [2015-03-26T14:55:52+00:00] INFO: Forking chef instance to converge...
==> default: [2015-03-26T14:55:52+00:00] INFO: *** Chef 12.1.2 ***
==> default: [2015-03-26T14:55:52+00:00] INFO: Chef-client pid: 1130
==> default: [2015-03-26T14:55:54+00:00] INFO: Setting the run_list to ["recipe[apache2]"] from CLI options
==> default: [2015-03-26T14:55:54+00:00] INFO: Run List is [recipe[apache2]]
==> default: [2015-03-26T14:55:54+00:00] INFO: Run List expands to [apache2]
==> default: [2015-03-26T14:55:54+00:00] INFO: Starting Chef Run for precise32
==> default: [2015-03-26T14:55:54+00:00] INFO: Running start handlers
==> default: [2015-03-26T14:55:54+00:00] INFO: Start handlers complete.
==> default: [2015-03-26T14:55:54+00:00] ERROR: Running exception handlers
==> default: [2015-03-26T14:55:54+00:00] ERROR: Exception handlers complete
==> default: [2015-03-26T14:55:54+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2015-03-26T14:55:54+00:00] ERROR: Cookbook iptables not found. If you're loading iptables from another cookbook, make sure you configure the dependency in your metadata
==> default: [2015-03-26T14:55:54+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Maybe iptables cookbook is required, so I add it. And then I get this message
==> default: [2015-03-26T14:58:32+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2015-03-26T14:58:32+00:00] ERROR: Cookbook logrotate not found. If you're loading logrotate from another cookbook, make sure you configure the dependency in your
==> default: [2015-03-26T14:58:32+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
logrotate cookbook is required?
Why does it continuously require cookbook? What is metadata here?
Can anyone help me?
Cookbooks can have dependencies to other cookbooks. This allows them to rely on functionality provided by these other cookbooks.
In your case, your apache2 cookbook depends on the iptables and the logrotate cookbooks. You can check this in each cookbook's metadata.rb file. In case of your apache2 cookbook, you can find the metadata.rb file on GitHub.
Note that cookbooks can also have recursive dependencies, i.e. they can have further dependencies which must all be fulfilled. Because if this, it is often recommended to manage your cookbooks with a tool like Berkshelf or Librarian which can download all cookbook dependencies automatically and consistent.

Vagrant Omnibus Plugin Not Working on My Windows 7 PC

I want to spin up a Fedora-20 VM using Vagrant and Chef on my Windows 7 PC and provision it as a LAMP server. I have Vagrant 1.6.5. and the vagrant-omnibus plugin (1.4.1) is installed.
My Vagrantfile includes the "config.omnibus.chef_version = :latest" statement, but after running "vagrant up", expected provisioning does not occur. Instead,
==> default: Running provisioner: chef_solo...
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.
It appears that the omnibus plugin did not install Chef on the VM. What else do I need to do to get this working on my PC?
This is my Vagrant file:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "chef/fedora-20"
config.omnibus.chef_version = :latest
config.vm.network "forwarded_port", guest: 80, host: 4567
config.vm.synced_folder "shared-files", "/var/www"
config.vm.provision "chef_solo" do |chef|
chef.cookbooks_path = "chef-recipes/cookbooks"
chef.roles_path = "chef-recipes/roles"
chef.add_role "lamp_stack"
end
end
and here is STDOUT:
C:\Users\wbj\f20>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'chef/fedora-20'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'chef/fedora-20' is up to date...
==> default: Setting the name of the VM: f20_default_1413836754304_46591
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 80 => 4567 (adapter 1)
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /var/www => C:/Users/wbj/f20/shared-files
default: /vagrant => C:/Users/wbj/f20
default: /tmp/vagrant-chef-3/chef-solo-2/roles => C:/Users/wbj/f20/chef-recipes/roles
default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks => C:/Users/wbj/f20/chef-recipes/cookbooks
==> default: Running provisioner: chef_solo...
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.
Thank you!
I ran into this exact problem. The solution was to downgrade to Vagrant 1.6.2 until Vagrant version 1.7.1 was released. Both versions fixed the problem for me.

Http 404 error using Hosted Chef and Vagrant

I’m trying to get started with Chef and Vagrant and Chef is experiencing a 404 Http error when I launch the vagrant instance, full output is shown below. Does anyone have any idea?
[default] VM already created. Booting if it's not already running...
[default] Clearing any previously set forwarded ports...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] -- 3000 => 3000 (adapter 1)
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Mounting shared folders...
[default] -- v-root: /vagrant
[default] Running provisioner: Vagrant::Provisioners::ChefClient...
[default] Creating folder to hold client key...
[default] Uploading chef client validation key...
[default] Generating chef JSON and uploading...
[default] Running chef-client...
stdin: is not a tty
[Sat, 23 Jun 2012 04:46:51 -0700] INFO: Starting Chef Run
/usr/lib/ruby/1.8/net/http.rb:2101:in `error!'
:
404 "Not Found"
(
Net::HTTPServerException
)
from /usr/lib/ruby/1.8/chef/rest.rb:233:in `run_request'
from /usr/lib/ruby/1.8/chef/rest.rb:95:in `post_rest'
from /usr/lib/ruby/1.8/chef/client.rb:221:in `create_registration'
from /usr/lib/ruby/1.8/chef/client.rb:199:in `register'
from /usr/lib/ruby/1.8/chef/client.rb:73:in `run'
from /usr/lib/ruby/1.8/chef/application/client.rb:186:in `run_application'
from /usr/lib/ruby/1.8/chef/application/client.rb:178:in `loop'
from /usr/lib/ruby/1.8/chef/application/client.rb:178:in `run_application'
from /usr/lib/ruby/1.8/chef/application.rb:57:in `run'
from /usr/bin/chef-client:25
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
chef-client -c /tmp/vagrant-chef-1/client.rb -j /tmp/vagrant-chef-1/dna.json
The contents of my vagrant file:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = "lucid32-rvm-ruby193"
config.vm.forward_port 3000, 3000
config.vm.provision :chef_client do |chef|
chef.chef_server_url = "https://api.opscode.com/organizations/xxx"
chef.validation_key_path = "xxx-validator.pem"
chef.validation_client_name = "xxx-validator"
end
end
That's the error you should get when you've typed the chef_server_url wrong. For example if you put:
chef.chef_server_url = "https://www.opscode.com/organizations/xxx"
Note the www instead of API, you would get that error. Had there not been a valid server to return a 404 you would get another error (probably name resolution if it's from a typo). Check the /tmp/vagrant-chef-1/client.rb file to verify it has the right URL, and double check your Vagrantfile to be sure you're using the right url.

Resources