Forum: CFEngine Help
Subject: Replace underscores in interface names (creating routes)
Author: alan.hatch
Link to topic: https://cfengine.com/forum/read.php?3,26010,26010#msg-26010
We are using interface aliases with periods that are being converted into
underscores in certain cases. I am trying to create a file called
route-bond0.748 using only cfengine goodness so servers on two different
administrative networks talk accross the correct interface:
bundle agent test_linux {
vars:
"local_ip_addresses" slist => { @(sys.ip_addresses) };
"nics" slist => getindices("sys.ipv4");
"interfaces" slist => { @(sys.interfaces) };
classes:
"core_ip_dc1_$(nics)" expression =>
regcmp("(10\.152\.48\..*)","$(sys.ipv4[$(nics)])");
"core_ip_dc2_$(nics)" expression =>
regcmp("(10\.154\.48\..*)","$(sys.ipv4[$(nics)])");
reports:
test01lp::
"NICS: $(nics)";
"INTERFACE: $(interfaces)";
"ROUTE: 10.152.48.0/24 via $(sys.ipv4[$(nics)]) dev $(nics)"
ifvarclass => "core_ip_dc2_$(nics)";
"ROUTE: 10.154.48.0/24 via $(sys.ipv4[$(nics)]) dev $(nics)"
ifvarclass => "core_ip_dc1_$(nics)";
}
Which shows:
R: NICS: bond0_724
R: NICS: bond0_748
R: INTERFACE: bond0.724
R: INTERFACE: bond0.748
R: ROUTE: 10.152.48.0/24 via 10.154.48.9 dev bond0_748
So I can access the actual interface name in a list, but the same entry in the
required associative array has an underscore.
I need to be able to create the file named "route-interface" at a minimum.
Changing the interface names is probably not an option.
Any help would be appreciated.
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine