Filter template

Filter template #

This filter template can be used as the starting point for writing your own filters. As you can see, there’s not much to it. After all, a filter must simply take input and return output.

"""A template for an Ansible filter plugin"""


def some_filter(input):
    """Filter some text and return some other text"""

    # Calculate the result from the input here
    result = "..."

    return result


# Your Python module must export a class called 'FilterModule'
# with a 'filters()' function that returns a dict of filters.
class FilterModule(object):
    def filters(self):
        return {
            # The return value must be a dict of name:filter key:value pairs.
            "some_filter": some_filter,
        }