Created
August 24, 2010 06:58
-
-
Save zzamboni/547095 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find all network interfaces that match a certain IP address. | |
# Time-stamp: <[netif_find.cf] modified by Diego Zamboni on Tuesday, 2010.08.24 at 01:53:03> | |
body common control | |
{ | |
bundlesequence => { "test" }; | |
} | |
bundle agent test | |
{ | |
vars: | |
"nics" slist => getindices("sys.ipv4"); | |
# Regex we want to match on the IP address | |
"ipregex" string => "192\.168\..*"; | |
# This is heavily based on cfengine3 list expansion. The expression is | |
# evaluated for every value of ${nics}, and if there are any matches, | |
# the corresponding class is defined, which then triggers the printing | |
# of the "Matched NIC" message (of course, in a real example, the class | |
# could be used to trigger some other action). | |
classes: | |
"ismatch_${nics}" expression => regcmp("${ipregex}", "${sys.ipv4[${nics}]}"); | |
reports: | |
linux|windows:: | |
"NICs found: ${nics}"; | |
"Matched NIC: ${nics} (${sys.ipv4[${nics}]})" | |
ifvarclass => "ismatch_${nics}"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment