Bug 1236143

Summary: use of %{::osfamily} in the hierarachy does not seem to expand to RedHat
Product: Red Hat OpenStack Reporter: Giulio Fidente <gfidente>
Component: hieraAssignee: Emilien Macchi <emacchi>
Status: CLOSED NOTABUG QA Contact: yeylon <yeylon>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0 (Kilo)CC: apevec, dprince, emacchi, gfidente, lbezdick, lhh, mburns, srevivo, yeylon
Target Milestone: ---   
Target Release: 8.0 (Liberty)   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-10-08 13:30:55 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1238807    
Attachments:
Description Flags
hiera_osfamily_lookup.txt none

Description Giulio Fidente 2015-06-26 16:31:33 UTC
Created attachment 1043602 [details]
hiera_osfamily_lookup.txt

Description of problem:
it looks like use of %{::osfamily} in the hierarchy does not expand to RedHat on RHEL, while the same works on Fedora; see use case attached to bug


Version-Release number of selected component (if applicable):
hiera-1.3.4-1.el7.noarch

Comment 3 Mike Burns 2015-09-25 19:17:25 UTC
FWIW, this doesn't appear to be a hiera problem.  it was reported that this works in fedora, but the hiera version we have in OSP is identical to the version in Fedora.  Same base tarball with no patches applied.

Comment 4 Giulio Fidente 2015-09-28 09:13:02 UTC
We seem to have the same problem with %{::uuid} from #1238807

Comment 5 Giulio Fidente 2015-09-29 16:41:01 UTC
Noticeably if one runs manually:

  facter --puppet osfamily

or

  facter --puppet uuid

these both work and return valid output as in "RedHat" or a valid UUID.

Yet when we enlist in the hiera config a yaml using those variable, for example;

  "%{::osfamily}"

then the contents of RedHat.yaml are not included. Same is for %{::uuid}.

Comment 6 Lukas Bezdicka 2015-09-29 21:10:23 UTC
/etc/puppet/hiera.yaml:
---
:backends:
  - json
  - yaml
:json:
  :datadir: /etc/puppet/hieradata
:yaml:
  :datadir: /etc/puppet/hieradata
:hierarchy:
  - "%{::osfamily}"
  - common

/etc/puppet/hieradata/common.yaml:
a_duck: baaa

/etc/puppet/hieradata/RedHat.yaml:
a_duck: gaaaa

hiera -c /etc/puppet/hiera.yaml a_duck
baaa

hiera -c /etc/puppet/hiera.yaml a_duck ::osfamily=RedHat
gaaaa

facter --yaml > facts.yaml won't be enough as the variables won't have ::

one has to have:
::osfamily: RedHat there


See: https://docs.puppetlabs.com/hiera/1/command_line.html

Comment 7 Giulio Fidente 2015-10-01 10:38:16 UTC
This seems to work as expected when calling hiera() from within a puppet manifest rather than from the cmdline. I am not sure if this is the indended behaviour but if it is maybe we can close this?

Comment 8 Emilien Macchi 2015-10-01 20:22:12 UTC
Giulio: what matters is manifest behavior, though we should have the same result with CLI.

Probably we should report the bug to puppetlabs directly, and investigate with the Puppet community.

If you don't need to run CLI in OSP-d, I suggest we close the bug. You or Puppet team could take care of reporting & following-up the bug upstream in Hiera/Facter.

Comment 9 Giulio Fidente 2015-10-08 13:30:55 UTC
Fedora 22 showing same behaviour, closing as NOTABUG as this works as intended when hiera is called from the manifest. Thanks for helping.