Hi, Using cfengine community 3.0.4, I am trying to determine which network interface in a system matches a certain IP address pattern, and assign its name to a variable.
So far, I am able to display the name of the matching interface, but can't figure out how to assign it to a variable. Please see the example below. I have tried to use ifvarclass in the vars: section, but that gives me errors. Thanks for any help. --Diego body common control { bundlesequence => { "test" }; } # bundle agent test { vars: "nics" slist => getindices("sys.ipv4"); "ipregex" string => "192\.168\..*"; # This doesn't work # "matchednic" string => "${sys.ipv4[${nics}]}" # ifvarclass => "ismatch_${nics}"; classes: "ismatch_${nics}" expression => regcmp("${ipregex}", "${sys.ipv4[${nics}]}"); reports: linux:: "NICs found: ${nics}"; "Matched NIC: ${nics} (${sys.ipv4[${nics}]})" ifvarclass => "ismatch_${nics}"; } _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine