Ask Your Question

Using hash-array in yaml.

asked 2015-06-08 05:41:45 -0500

TomKeegasi gravatar image

I'd like to uses the facter variable os=>name and os0>lsb=>distcodename inside my hiera.yaml, but I can't get it working. :-/

Here is my example config:

  - yaml
  - json
  :datadir: /media/sf_VirtualShare/ILIAS-EA/hiera
  :datadir: /media/sf_VirtualShare/ILIAS-EA/hiera
- "node/%{::fqdn}"
- "os/Linux/%{::os:name}/%{::os:lsb:distcodename}"
- defaults

I tried every combination of


but nothing works.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-06-08 17:33:08 -0500

GregLarkin gravatar image

Looking through the hiera.yaml documentation, I don't see any references to this type of variable expansion. Based on your experiments, if it were going to work, one of those should have - most likely the last one.

However, all is not lost if you're willing to do a little extra work. You should be able to write a custom fact to extract the specific member of a structured fact (example: and create a new fact name with a simple string value. Then use the new fact name in your hiera.yaml.

edit flag offensive delete link more


Doing another "factor | grep -i Jessie" I found there is also a "lsbdistcodename"-fact (so doing %{::lsbdistcodename} works). Really don't know why I didn't see this the first time around. :-/ Thanks for the hint anyway. ;)

TomKeegasi gravatar imageTomKeegasi ( 2015-06-09 01:13:27 -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-06-08 05:41:45 -0500

Seen: 522 times

Last updated: Jun 08 '15