Bug 1236143 - use of %{::osfamily} in the hierarachy does not seem to expand to RedHat
Summary: use of %{::osfamily} in the hierarachy does not seem to expand to RedHat
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: hiera
Version: 7.0 (Kilo)
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: 8.0 (Liberty)
Assignee: Emilien Macchi
QA Contact: yeylon@redhat.com
URL:
Whiteboard:
Depends On:
Blocks: 1238807
TreeView+ depends on / blocked
 
Reported: 2015-06-26 16:31 UTC by Giulio Fidente
Modified: 2016-04-18 06:55 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-10-08 13:30:55 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
hiera_osfamily_lookup.txt (1.15 KB, text/plain)
2015-06-26 16:31 UTC, Giulio Fidente
no flags Details

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.


Note You need to log in before you can comment on or make changes to this bug.