Skip to content

Instantly share code, notes, and snippets.

@athoune
Last active Aug 29, 2015
Embed
What would you like to do?
Finding the first active ethernet interface with ansible
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)
@athoune
Copy link
Author

athoune commented Oct 8, 2014

You need a setting in your ansible.cfg :

[defaults]
filter_plugins = ./filter_plugins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment