Hiera lookup fail : doesan't find json file

66 views
Skip to first unread message

chris

unread,
Jun 20, 2016, 8:52:21 AM6/20/16
to Puppet Users

Given this /etc/puppetlabs/code/hiera.yaml


---

:backends: 
  - json

:hierarchy: 
  - "%{hostname}.%{nt_environment}.%{nt_location}"
  - "%{nt_type}.%{nt_environment}.%{nt_location}"
  - "%{nt_type}.%{nt_environment}"
  - "%{nt_environment}.%{nt_location}"
  - "%{nt_environment}"
  - "%{nt_location}"
  - world
  - default

:logger: console # debug

:json:
    :datadir: '/etc/puppetlabs/code/environments/%{::environment}/hieradata' # this is the default anyway

and there exists /etc/puppetlabs/code/environments/prod/hieradata/sac.json, this cmd


puppet lookup --debug icinga_servers --environment prod


produces


Debug
: hiera(): Looking for data source puppetmaster.ops Debug: hiera(): Looking for data source ops.sac Debug: hiera(): Looking for data source ops Debug: hiera(): Looking for data source sac Debug: hiera(): Looking for data source world Debug: hiera(): Looking for data source default

(& lots more of course).


Why can't it find the /etc/puppetlabs/code/environments/prod/hieradata/sac.json file which contains the key I'm looking for ?
(Puppet server 2.4)


Thanks

Chris

Mike Sharpton

unread,
Jun 20, 2016, 12:52:22 PM6/20/16
to Puppet Users
You would need to have sac in your hiera.yaml hierarchy unless you are defining this somewhere in a variable?  Is that what nt_location is?  Also, if you changed hiera.yaml, you have to restart puppetserver.

chris

unread,
Jun 21, 2016, 1:17:12 AM6/21/16
to Puppet Users
Yes, nt_location is 'sac', so sac.json as mentioned.
Not sure how to check the 'value' of that var... %{nt_location}. This is a bit new to me.
Should have mentioned its copied from a working(!) 3.2 master; want to 'upgrade' with minimal changes.

chris

unread,
Jun 21, 2016, 2:07:33 AM6/21/16
to Puppet Users
Dang; wanted to add to my last..
<br/>
Anyway, ran 'facter -p' on the node and those values are filled correctly. How can I check what the master sees when the node checks in?

chris

unread,
Jun 22, 2016, 9:06:54 PM6/22/16
to Puppet Users
So, here's a bit more of the debug o/op:

Debug: Performing a hiera indirector lookup of icinga_servers with options {:variables=>Scope(Class[main]), :merge=>#<Puppet::Pops::FirstFoundStrategy:0x00000001024e18 @options_t=#<Puppet::Pops::Types::PStructType:0x00000000fa4150 @elements=[#<Puppet::Pops::Types::PStructElement:0x00000000fa4218 @key_type=#<Puppet::Pops::Types::POptionalType:0x00000000fa4268 @type=#<Puppet::Pops::Types::PStringType:0x00000000fa42b8 @size_type=nil, @values=["strategy"]>>, @value_type=#<Puppet::Pops::Types::POptionalType:0x00000000fa4448 @type=#<Puppet::Pops::Types::PPatternType:0x00000000fa44e8 @patterns=[#<Puppet::Pops::Types::PRegexpType:0x00000000fa46f0 @pattern="first", @regexp=/first/>]>>>]>, @options={}>}
Debug: hiera(): Looking up icinga_servers in JSON backend
Debug: hiera(): Looking for data source puppet4test101.ops.sac
Debug: hiera(): Cannot find datafile /etc/puppetlabs/code/environments/prod/hieradata/puppet4test101.ops.sac.json, skipping
Debug: hiera(): Looking for data source puppet4test.ops.sac
Debug: hiera(): Cannot find datafile /etc/puppetlabs/code/environments/prod/hieradata/puppet4test.ops.sac.json, skipping
Debug: hiera(): Looking for data source puppet4test.ops
Debug: hiera(): Cannot find datafile /etc/puppetlabs/code/environments/prod/hieradata/puppet4test.ops.json, skipping

Debug: hiera(): Looking for data source ops.sac
Debug: hiera(): Looking for data source ops
Debug: hiera(): Looking for data source sac

and according to facter -p on node nt_location is sac (as expected).
Also, the file /etc/puppetlabs/code/environments/prod/hieradata/sac.json definitely exists.
Its odd that it doesn't throw an error, it just doesn't find it.

chris

unread,
Jun 23, 2016, 1:45:33 AM6/23/16
to Puppet Users


On Thursday, 23 June 2016 11:06:54 UTC+10, chris wrote:

So as you can see from above, it prefixes each keyname with the dir and appends '.json', as it should BUT only if keyname/data src has a numeric digit in it! Is this a bug in puppet??
Or am I missing something?

Henrik Lindberg

unread,
Jun 23, 2016, 11:31:22 AM6/23/16
to puppet...@googlegroups.com
> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-users...@googlegroups.com
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/d2c42889-29a2-47f4-9dcd-b4d14917b611%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/d2c42889-29a2-47f4-9dcd-b4d14917b611%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

What happens if you change '.' to '_' for that particular file?
(I wonder if there is a bug in the handling of '.')

- henrik

--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/
Reply all
Reply to author
Forward
0 new messages