My end goal is to iterate through a puppet hash and configure multiple VRFs.
I was able to do that when the hash is locally defined using below code:
$tenant_vrf_info =
{
1=>{vrf=>"evpn-tenant-1", l3_vni=>"5010", rd=>"2000:5010", import=>"2000:5010"},
2=>{vrf=>"evpn-tenant-2", l3_vni=>"5020", rd=>"2000:5020", import=>"2000:5020",
}
$tenant_vrf_info.each |$tenant,$value|
{
$tenant_id = "$tenant"
$tenant_vrf_context = "${value[vrf]}"
$tenant_l3_vni = "${value[l3_vni]}"
cisco_command_config
{
$tenant_id:
command => "
vrf context $tenant_vrf_context
vni ${value[l3_vni]}
address-family ipv4 unicast
"
}
}
I decided to get this data from Hiera. This is when the nightmare began...
I cannot get the data out of the hash. I just want the data out hiera so I can iterate through it using .each.
Below is my setup. When I run below code I get this error: Evaluation Error: Empty string title at 0. **Title strings must have a length greater than zero.**
**YAML File:**
---
vrfs:
vrf-evpn-tenant-2:
l3_vni: 20101
rd: '2000:20101'
vrf-evpn-tenant-3:
l3_vni: 20102
rd: '2000:20102'
**HIERA:**
hiera -d vrfs
{"vrf-evpn-tenant-2"=>{"l3_vni"=>20101, "rd"=>"2000:20101"},
"vrf-evpn-tenant-3"=>{"l3_vni"=>20101, "rd"=>"2000:20101"}}
**Puppet Manifest:**
class rbc_vrf
{
include install
include stdlib
$tenant_vrf_info_hiera = hiera('vrfs')
notify{"${tenant_vrf_info_hiera['l3_vni']}":}
}
↧