Ask Your Question
0

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:

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

I tried every combination of

%{::os:lsb:distcodename}
%{::os::lsb::distcodename}
%{::os[lsb][distcodename]}
%{::os['lsb']['distcodename']}

but nothing works.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

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: https://docs.puppetlabs.com/facter/2.4/custom_facts.html#using-other-facts) 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

Comments

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

Stats

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

Seen: 450 times

Last updated: Jun 08 '15