Why hiera-puppet-hepler not able to find the variable?

asked 2014-08-29 03:38:52 -0600

Manish gravatar image

I am trying to follow an example given here,https://github.com/bobtfish/hiera-puppet-helper.

I could get the hieradata example working fine, however not able to heiraconfig.

Here is my test (spec/classes/init_spec.rb) code...

describe "kp_ls" do
let(:node) { 'testhost.example.com' }

let(:hiera_config) do
    { :backends => ['yaml'],
        :hierarchy => [
            '%{fqdn}/%{calling_module}',
            '%{calling_module}'],
         :yaml => {
             :datadir => File.expand_path(File.join(__FILE__, '..', '..', 'hieradata')) }}
end

#let(:hiera_data) { { :foo_message => "bar" } }

it { should contain_notify("foo1").with_message("bar") }
end

My directory structure looks as follows

./spec
./spec/classes/init_spec.rb
./spec/spec_helper.rb
./hieradata
./hieradata/testhost.example.com
./hieradata/testhost.example.com/testhost.example.com.yaml
./hieradata/testhost.example.com.yaml
./Rakefile
./manifests
./manifests/init.pp

I tried various combinations of yaml files by moudle name, hostname name, but every time the test fails with,

  1) kp_ls
     Failure/Error: it { should contain_notify("foo1").with_message("bar") }
     Puppet::Error:
       Could not find data item foo_message in any Hiera data file and no default supplied at /opt/source/t3_git/config/puppet/baseconf/modules/kp_ls/spec/fixtures/modules/kp_ls/manifests/init.pp:11 on node testhost.example.com
     # ./spec/classes/init_spec.rb:26:in `block (2 levels) in <top (required)>'

Am I missing something obvious?

edit retag flag offensive close merge delete

Comments

I made some progress. When I specific %{fqdn}/%{fqdn} it is able to find the path correctly. But not with calling_module.

Manish gravatar imageManish ( 2014-08-29 04:33:30 -0600 )edit

I couldn't get hiera_data to work either. Did you have to do anything to make it work?

Chams gravatar imageChams ( 2015-10-30 12:34:08 -0600 )edit