How to parse yaml in hiera?

Good afternoon.
There is a yaml file with the following hierarchy:
iptables::test:
ip:
 1.1.1.1 : 'adm-1'
 2.2.2.2 : 'adm-2'
 3.3.3.3 : 'adm-3'

You need to parse the hiera in puppet.
How to transfer a layered yaml and substitute the correct value for key, value
$variable1 = hiera('iptables::test:')
$variable2 = inline_template("<% @variable1.each do |key,value| %>Allow From <%=key %> #<%=value %>\n<% end -%>")
April 3rd 20 at 18:34
1 answer
April 3rd 20 at 18:36
Solution
@alvena_Bartoletti4 well, actually, in your code a few mistakes.

iptables::test:
ip:
 1.1.1.1: 'adm-1'
 2.2.2.2: 'adm-2'
 3.3.3.3: 'adm-3'


$variable1 = hiera('iptables::test.ip')
 $variable2 = inline_template( "<% @variable1.each do |key,value| %>Allow From <%=key %> #<%=value %>\n<% end -%>")
 notify { "result: ${variable2}": }


result: 
Allow From 1.1.1.1 #adm-1
Allow From 2.2.2.2 #adm-2
Allow From 3.3.3.3 #adm-3
Thank You for the reply, but when I add in .the ip in
$variable1 = hiera('iptables::test.ip'

I get this error:
Error 400 on SERVER: Could not find data item iptables::test.the ip in any Hiera data file and no default supplied - alvena_Bartoletti4 commented on April 3rd 20 at 18:39
Not true. I got an old version of puppet that does not support a point in hiera.
Dared so:

$tmp = hiera('iptables::ip_tt_test')
$ips = $tmp['ip'] - alvena_Bartoletti4 commented on April 3rd 20 at 18:42
@alvena_Bartoletti4 "not true" - please translate

the Pro version papita thank you this is really the problem
please mark as a solution which option is more appropriate

the options are really:
deep_data:
group_key1:
 key1: 'value1'
 key2: 'value2'
group_key2:
 key3: 'value3'
 key4: 'value4'
 key5: 'value5'
group_key3:
 key6: 'value6'

$group_data = hiera('deep_data.group_key1')
 $frag1 = inline_template( "<% @group_data.each do |key,value| %> key: <%=key %> value: <%=value %>\n<% end -%>")

$deep_data = hiera('deep_data')

 $frag2 = inline_template( "<% @deep_data['group_key2'].each do |key,value| %> key: <%=key %> value: <%=value %>\n<% end -%>")

 $flat_data = $deep_data['group_key3'] 
 $frag3 = inline_template( "<% @flat_data.each do |key,value| %> key: <%=key %> value: <%=value %>\n<% end -%>")
- Leora33 commented on April 3rd 20 at 18:45

Find more questions by tags PuppetYAML