chef-boneyard / chef-provisioning

A library for creating machines and infrastructures idempotently in Chef.
Apache License 2.0
524 stars 164 forks source link

NoMethodError: undefined method `has_key?' #418

Open rj-reilly opened 9 years ago

rj-reilly commented 9 years ago

Hi i have a new ubuntu setup installed chefdk, vagrant, chef-provisioning chef-provisioning-vagrant virtualbox, I can vagrant up no problem but if i use the example at the top of the doc https://github.com/chef/chef-provisioning and I get the following error: [2015-08-18T20:24:00-04:00] INFO: Started chef-zero at chefzero://localhost:8889 with repository at /home/rreilly/chef-repo One version per cookbook

[2015-08-18T20:24:00-04:00] INFO: Forking chef instance to converge...
[2015-08-18T20:24:00-04:00] INFO: *** Chef 12.4.1 ***
[2015-08-18T20:24:00-04:00] INFO: Chef-client pid: 11583
[2015-08-18T20:24:01-04:00] INFO: Run List is []
[2015-08-18T20:24:01-04:00] INFO: Run List expands to []
[2015-08-18T20:24:01-04:00] INFO: Starting Chef Run for devnill
[2015-08-18T20:24:01-04:00] INFO: Running start handlers
[2015-08-18T20:24:01-04:00] INFO: Start handlers complete.
[2015-08-18T20:24:01-04:00] INFO: HTTP Request Returned 404 Not Found: Object not found: 
[2015-08-18T20:24:01-04:00] INFO: Loading cookbooks []
[2015-08-18T20:24:01-04:00] WARN: Node devnill has an empty run list.
[2015-08-18T20:24:01-04:00] INFO: Processing vagrant_box[precise64] action create (@recipe_files::/home/rreilly/chef-repo/cookbooks/provision/vagrant_linux.rb line 3)
[2015-08-18T20:24:01-04:00] WARN: Class Chef::Provider::VagrantBox does not declare 'resource_name :vagrant_box'.
[2015-08-18T20:24:01-04:00] WARN: This will no longer work in Chef 13: you must use 'resource_name' to provide DSL.

================================================================================
Error executing action `create` on resource 'vagrant_box[precise64]'
================================================================================

NoMethodError
-------------
undefined method `has_key?' for nil:NilClass

Resource Declaration:
---------------------
# In /home/rreilly/chef-repo/cookbooks/provision/vagrant_linux.rb

  3: vagrant_box 'precise64' do
  4:   url 'http://files.vagrantup.com/precise64.box'
  5: end
  6: 

Compiled Resource:
------------------
# Declared in /home/rreilly/chef-repo/cookbooks/provision/vagrant_linux.rb:3:in `from_file'

vagrant_box("precise64") do
  action [:create]
  retries 0
  retry_delay 2
  default_guard_interpreter :default
  declared_type :vagrant_box
  cookbook_name "@recipe_files"
  recipe_name "/home/rreilly/chef-repo/cookbooks/provision/vagrant_linux.rb"
  url "http://files.vagrantup.com/precise64.box"
  vagrant_provider "virtualbox"
end

[2015-08-18T20:24:01-04:00] INFO: Running queued delayed notifications before re-raising exception
[2015-08-18T20:24:01-04:00] ERROR: Running exception handlers
[2015-08-18T20:24:01-04:00] ERROR: Exception handlers complete
[2015-08-18T20:24:01-04:00] FATAL: Stacktrace dumped to /home/rreilly/chef-repo/.chef/local-mode-cache/cache/chef-stacktrace.out
[2015-08-18T20:24:01-04:00] ERROR: vagrant_box[precise64] (@recipe_files::/home/rreilly/chef-repo/cookbooks/provision/vagrant_linux.rb line 3) had an error: NoMethodError: undefined method `has_key?' for nil:NilClass
[2015-08-18T20:24:02-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
rj-reilly commented 9 years ago

got past this and now it seems to fail on opening the box because it fails to download it

[2015-08-19T03:21:27-04:00] ERROR: machine[mario] (@recipe_files::/home/rreilly/chef-repo/cookbooks/provision/cluster.rb line 3) had an error: RuntimeError: vagrant up mario --provider virtualbox failed!
STDOUT:Bringing machine 'mario' up with 'virtualbox' provider...
==> mario: Box 'precise64' could not be found. Attempting to find and install...
    mario: Box Provider: virtualbox
    mario: Box Version: >= 0
==> mario: Box file was not detected as metadata. Adding it directly...
==> mario: Adding box 'precise64' (v0) for provider: virtualbox
    mario: Downloading: precise64

STDERR:An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.

Couldn't open file /home/rreilly/chef-repo/.chef/vms/precise64

[2015-08-19T03:21:28-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
rj-reilly commented 9 years ago

I have wr on that dir

rreilly@vbox01:~/chef-repo/.chef/vms$ ls -al
total 20
drwxr-xr-x 3 rreilly root    4096 Aug 19 03:27 .
drwxr-xr-x 4 rreilly rreilly 4096 Aug 18 23:24 ..
-rw-r--r-- 1 rreilly root     161 Aug 18 23:24 mario.vm
drwxr-xr-x 3 rreilly root    4096 Aug 18 23:24 .vagrant
-rw-r--r-- 1 rreilly root     107 Aug 18 23:24 Vagrantfile
rreilly@vbox01:~/chef-repo/.chef/vms$ 
yazgoo commented 9 years ago

Hi @devilldog,

How did you get past the first issue ? I have the same problem.

yazgoo commented 9 years ago

Turns out this is caused by the wrapper around vagrant box list which does not work when there is no box installed. The trick is to add one. For example I did a:

vagrant box add hashicorp/precise64

And got rid of that first error.