ripienaar / puppet-module-data

Hiera backend that stores data in a module
74 stars 43 forks source link

"Can't convert nil into hash" error #18

Closed fatmcgav closed 10 years ago

fatmcgav commented 10 years ago

I seem to be hitting an issue when using this module in combination with hash resources.

The error I'm seeing is:

Error: can't convert nil into Hash at /home/vagrant/puppet/modules/test/manifests/test.pp:99 on node rpbo.test.local Wrapped exception: can't convert nil into Hash Error: can't convert nil into Hash at /home/vagrant/puppet/modules/test/manifests/test.pp:99 on node rpbo.test.local

The code around there is:

  #hiera_resources("res")
  $res = hiera_hash('res')
  notify { 'res':
    message => "Res = ${res}"
  }

As you can see, I've tried both hiera_resources and hiera_hash, and both return the same result.

And my common.yml contains:

res:
  notify:
    'module1':
       message: 'Data in module 1'

From a bit of debugging, I've tracked it to: module_data_backend.rb#83.

If I add an additional line before that with:

answer ||= {}

then it all works as expected.

Is this a known issue? Way I'm using it? Or a genuine bug?

Cheers Gav

fatmcgav commented 10 years ago

I'm guessing it's a bug actually, as the Hiera yaml backend has that line present: https://github.com/puppetlabs/hiera/blob/master/lib/hiera/backend/yaml_backend.rb#L43-L44

ripienaar commented 10 years ago

yeah, make a PR and I'll merge that

thanks