Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Hiera: Using mapped_paths with a hashmap

40 views
Skip to first unread message

Dirk Heinrichs

unread,
Sep 4, 2024, 6:01:05 AM9/4/24
to puppet...@googlegroups.com
Hi,

the Hiera documentation says that the "mapped_paths" method can be used with either an Array or Hash: "A fact that is a collection (array or hash) of values. Hiera expands these values to produce an array of paths."

Using it with an Array is quite easy, since the documentation also has an example for this. However, if the given fact is a hash, then

  - name: Foo
    mapped_paths: [facts.foo, name, "foo/%{name}.yaml"]

produces paths like:

.../foo/["key", "value"].yaml

How can I access the key and/or value separately, or only operate on an Array of keys (or values)

Thanks...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

Dirk Heinrichs

unread,
Sep 4, 2024, 6:33:16 AM9/4/24
to puppet...@googlegroups.com
Am Mittwoch, dem 04.09.2024 um 10:00 +0000 schrieb 'Dirk Heinrichs' via Puppet Users:

However, if the given fact is a hash, then

  - name: Foo
    mapped_paths: [facts.foo, name, "foo/%{name}.yaml"]

Got it: The path template must look like "foo/%{name.0}.yaml" to access the key.

Bye...
Reply all
Reply to author
Forward
0 new messages