Last active
August 29, 2015 14:07
-
-
Save athoune/2c35c28a81b95c9ad55c to your computer and use it in GitHub Desktop.
Finding the first active ethernet interface with ansible
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
def first_eth(v, **kw): | |
'''Finding the first active ethernet interface''' | |
for n in range(10): | |
name = 'ansible_eth%i' % n | |
if name not in v: | |
return | |
eth = v[name] | |
if eth['active']: | |
return eth | |
class FilterModule(object): | |
def filters(self): | |
return dict(first_eth=first_eth) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need a setting in your ansible.cfg :