POST
Detecting NICs that match certain IP addresses
This file contains hidden or 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}"; | |
} |
- Tags:
- cfengine
- Related:
- Limited Time Promotion! 50% off "Learning CFEngine 3"
- New Release of "Learning CFEngine 3"
- CFEngine talks at PICC'12 conference
- Learning CFEngine 3 has been released
- CFEngine posts moving to cf-learn.info
- cf-cmd: A command-line tool for running CFEngine snippets
- New website for "Learning CFEngine 3"
- "Learning CFEngine 3" Early Release now available -use AUTHD to get 40-50% off
- "Security in the Third Wave of IT Engineering"
- What's New in CFEngine 3: Making System Administration Even More Powerful - O'Reilly Radar
- "Introduction to CFEngine 3 Nova" webinar
- New job, new book
- Installing cfengine on Mac OS X
- Editing sshd configuration files with cfengine3
- Cfengine3 lexer for Pygments
- Storing CFEngine configuration in CVS
- Hierarchical copying with cfengine3
- The State of Open Source System Automation
- Editing whitespace-separated config files with cfengine
- cfengine Community Open Promise Body Library on GitHub
- Implementing "single-copy nirvana" in cfengine3
- Installing cfengine on Windows 7 under cygwin