Ask Your Question

sub sub folders in hieradata

asked 2015-11-03 02:12:30 -0500

masterdam79 gravatar image

updated 2015-11-08 02:43:34 -0500

Hey comm,

I'm using Puppet 4 Open Source.

Being boggled about the following. I simply would like to have subfolders in my hiera datadir like the following.


So that I can make an array of packages and have a specific package installed on CentOS 7 (but not on Debian 7 for example)

I'm trying to construct my hiera.yaml :hierarchy: with different variables from facter like: "osmajrel/%{}/%{::os.release.major}".

I tried the following in my hiera.yaml :hierarchy: to no avail:

  • "osmajrel/%{}%{::os.release.major}" (file containing base_package array in /hieradata/osmajrel/CentOS7.yaml)
  • "osmajrel/%{}%-{::os.release.major}" (file containing base_package array in /hieradata/osmajrel/CentOS-7.yaml)
  • "osmajrel/%{}%/{::os.release.major}" (file containing base_package array in /hieradata/osmajrel/CentOS/7.yaml)

It works only if my hiera.yaml :hierarchy: contains:

  • "osname/%{}" (file containing base_package array in /hieradata/osname/CentOS.yaml)
  • "osmajrel/%{::os.release.major}" (file containing base_package array in /hieradata/osmajrel/7.yaml)

I've got a notify in my packages class to show me which packages would be installed by the agent.

Any idea why merging variables don't seem to work in hiera.yaml?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2016-03-02 16:05:17 -0500

masterdam79 gravatar image

Got it working by upgrading Puppet Server from version 4.x.x to 4.3.2 (unfortunately I don't know on which Puppet version this was an issue). It all works now as intended, seems like a bug in early versions of Puppet 4 CE.

My syntax:

 - "osmajver/%{}-%{::os.release.major}"

And my file in hieradata is located osmajver/CentOS-7.yaml which for now installs a package on all CentOS 7 machines, but not on Debian 7 machines, which was my goal.


edit flag offensive delete link more



answered 2015-11-03 19:29:00 -0500

lupin gravatar image

The format should read like


on the hiera.yaml then on a corresponding data yaml file with interpolated value.

E.g if your fact is os=solaris release=10 then you define like

"%{os}-%{release}"  with a /var/lib/hiera/solaris-10.yaml file.

If you wanted directory then you just create the directory structure.

"%{os}-%{release}/%{release}"  with a /var/lib/hiera/solaris-10/10.yaml
edit flag offensive delete link more


Thanks for your reply, the double quotes I already have in my code. Although it doesn't show in my OP under "I tried the following" I did mention the quotes in the first paragraph. I'll adjust the original post so it'll reflect double quotes consistently all over.

masterdam79 gravatar imagemasterdam79 ( 2015-11-08 02:38:23 -0500 )edit

Unfortunately as the presented solution is identical to the points under the header "I tried the following" in the OP I can't flag the answer as a solution.

masterdam79 gravatar imagemasterdam79 ( 2015-11-08 03:03:31 -0500 )edit

Strangely enough everywhere I read the top scope facter variables should be usable in this manner but I can't seem to get it to work, so I'll have to look if I can get hiera itself to increase verbosity or log to a logfile somewhere.

masterdam79 gravatar imagemasterdam79 ( 2015-11-08 03:13:17 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-11-02 15:14:39 -0500

Seen: 356 times

Last updated: Mar 02 '16