Skip to content

Instantly share code, notes, and snippets.

@athoune
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save athoune/2c35c28a81b95c9ad55c to your computer and use it in GitHub Desktop.
Save athoune/2c35c28a81b95c9ad55c to your computer and use it in GitHub Desktop.
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