Skip to content

Instantly share code, notes, and snippets.

@lanky
Last active September 1, 2016 15:55
Show Gist options
  • Save lanky/e9ff4ba2aa185b25b4d3f4907b8e28c1 to your computer and use it in GitHub Desktop.
Save lanky/e9ff4ba2aa185b25b4d3f4907b8e28c1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from ansible import errors
import types
def split(input, sep=' ', maxsplit=0):
if not isinstance(input, types.StringTypes) or not isinstance(sep, types.StringTypes):
raise errors.AnsibleFilterError('split only operates on strings')
if maxsplit > 0:
return input.split(sep, maxsplit)
return input.split(sep)
class FilterModule(object):
def filters(self):
return {
'split' : split,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment