Hiera Lookups Fail with variables

52 views
Skip to first unread message

John Baird

unread,
Jul 19, 2016, 3:16:10 AM7/19/16
to Puppet Users
Attempting to use hiera to hold all of my node-specific variables.  It has been some time since I have run a puppet server, but I know it's not THAT hard.  That being said, my modules run fine, but hiera is not looking them up correctly.  It appears that any lines that contain any variables in the hiera.yaml are ignore and are not searched.  Any assistance would be great!  I'm sure it's something small, but sooooooo confused...


HIERA.YAML
------------------
---
:backends:
  - yaml
:yaml:
  :datadir: "/opt/local/modules/hieradata"
:hierarchy:
  - '%{calling_module}/%{::hostname}'
  - '%{calling_module}/common'
  - common


hiera -d 'dhcpd::package_name' environment=production
DEBUG: 2016-07-18 20:48:38 -0400: Hiera YAML backend starting
DEBUG: 2016-07-18 20:48:38 -0400: Looking up dhcpd::package_name in YAML backend
DEBUG: 2016-07-18 20:48:38 -0400: Looking for data source common
DEBUG: 2016-07-18 20:48:38 -0400: Cannot find datafile /opt/local/modules/hieradata/common.yaml, skipping
nil


---
:backends:
  - yaml
:yaml:
  :datadir: "/opt/local/modules/hieradata"
:hierarchy:
  - '%{calling_module}/%{::hostname}'
  - '%{calling_module}/common'
  - common
  - puppet_test

hiera -d 'dhcpd::package_name' environment=production
DEBUG: 2016-07-18 20:49:30 -0400: Hiera YAML backend starting
DEBUG: 2016-07-18 20:49:30 -0400: Looking up dhcpd::package_name in YAML backend
DEBUG: 2016-07-18 20:49:30 -0400: Looking for data source common
DEBUG: 2016-07-18 20:49:30 -0400: Cannot find datafile /opt/local/modules/hieradata/common.yaml, skipping
DEBUG: 2016-07-18 20:49:30 -0400: Looking for data source puppet_test
DEBUG: 2016-07-18 20:49:30 -0400: Cannot find datafile /opt/local/modules/hieradata/puppet_test.yaml, skipping
nil

Rob Nelson

unread,
Jul 19, 2016, 6:48:59 AM7/19/16
to puppet...@googlegroups.com
It cannot find the files. Do they exist and are they readable to the user you are running hiera/the puppet master service as?
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/34a20f55-02a2-49c7-88d2-28885636dab2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

John Baird

unread,
Jul 19, 2016, 1:14:55 PM7/19/16
to Puppet Users
All files should be readable as they are either 755 or 644.  Even if they don't exist, hiera should still attempt to "Search" that path and show me what directories it is searching when doing so with debug on.  Since it is not showing the directories with variables, it, for some reason, is skipping them alltogether.

another example:

---
:backends:
  - yaml
:yaml:
  :datadir: "/opt/local/modules/hieradata"
:hierarchy:
  - common1/%{calling_class}
  - common2/%{calling_class}
  - common3
  - puppet_test

hiera -d 'dhcpd::package_name' environment=production
DEBUG: 2016-07-19 13:12:49 -0400: Hiera YAML backend starting
DEBUG: 2016-07-19 13:12:49 -0400: Looking up dhcpd::package_name in YAML backend
DEBUG: 2016-07-19 13:12:49 -0400: Looking for data source common3
DEBUG: 2016-07-19 13:12:49 -0400: Cannot find datafile /opt/local/modules/hieradata/common3.yaml, skipping
DEBUG: 2016-07-19 13:12:49 -0400: Looking for data source puppet_test
DEBUG: 2016-07-19 13:12:49 -0400: Cannot find datafile /opt/local/modules/hieradata/puppet_test.yaml, skipping
nil

common1 and common2 are completely ignored.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.


--

Gavin Williams

unread,
Jul 19, 2016, 1:27:57 PM7/19/16
to Puppet Users
John

I'm pretty sure when you're running hiera on the command line, you need to 'provide' the fact values. See https://docs.puppet.com/hiera/3.2/command_line.html#fact-sources

HTH

Gav

Rob Nelson

unread,
Jul 19, 2016, 3:12:25 PM7/19/16
to puppet...@googlegroups.com
That is correct, when those values are not found, hiera doesn't search those tiers at all. The debug information could be more helpful about it, though.
Gav
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@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.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/93956c01-6dd7-4b44-b535-d6e31e22693d%40googlegroups.com.

John Baird

unread,
Jul 19, 2016, 5:29:41 PM7/19/16
to Puppet Users
If you look at the hiera debug output from the last reply I posted, it clearly shows that several folders with variables are not looked at when it should be.  Even if it doesn't find data in those folders, hiera should still explicitly show that it is TRYING to look there, but that doesn't happen.  It clearly is not searching where it should be, which is why everything is failing unless it's all hard-coded, which is obviously not ideal.

Gavin Williams

unread,
Jul 19, 2016, 5:59:50 PM7/19/16
to Puppet Users
John

Yes, the 'common1' and 'common2' tiers are being ignored because 'calling_class' doesn't expand to anything when running on the command line.

Try running
hiera -d 'dhcpd::package_name' environment=production calling_class=x
replacing x with the corresponding class_name you'd expect to be resolving... 

Gav

John Baird

unread,
Jul 19, 2016, 6:43:57 PM7/19/16
to Puppet Users
I was using calling_class as an example.  %{calling_module} used to work, but now does not.  Are you aware of what should be used instead?  Things like %{::hostname} do not work either.  

My other real concern is that when using something like "%{calling_module}/random_thing", there is no lookup for "/random_thing" when calling_module is not interpolated as I would expect it to since it should see it as a nil value.

Rob Nelson

unread,
Jul 19, 2016, 7:36:03 PM7/19/16
to puppet...@googlegroups.com
If the value is nil, then it skips that tier entirely. 
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/096a7c43-6461-4f69-a9ee-d683fb71edb9%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--

Reply all
Reply to author
Forward
0 new messages