I need to get ipv4 address in a var to write it into config file.
There are variety of interface configurations, but all machines has ip
from subnet 10.0.50.0/24 which is management subnet. Unfortunately
this ip can be assigned to different interfaces: somewhere to eth0,
somewhere to eth1 etc...
This is how I am trying to get it:
bundle agent test {
var:
"mngmt_ip" slist => grep("10\.0\.50","sys.ipv4");
command:
"/bin/echo my management ip is $(mngmt_ip)"
}
But it doesnt work, as ipv4 is array and if I try to use it with no
index it returns only first element. "@sys.ipv4" doesnt work either =(
I was thinking about different approached but cant find missing bits
to complete them:
1. using getindices
bundle agent test {
var:
"iface" slist => getindices("sys.ipv4");
command:
"/bin/echo my management ip is"
args => "$(array[$(ifaces)])";
//dont know how to do following (pseudocode):
condition => match("10\.0.\50","$(array[$(iface)])");
}
The idea is to apply regexp condition to promise and evaluate it.
Probably "ifvarclass" can help, but I dont know how to use it
properly. I've tried to add simple "ifvarclass => "ipv4_10_0_50" but
got syntax error =(
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine