Passing filters(functions) to custom ansible filter plugin

Viewed 157

I'd like to pass functions(such as contains, defined, etc) to my ansible-filter plugin. In a same manner that is passed to map() for example.

e.g:

# playbook

    - debug: 
        msg: "{{ my_dict | my_filter('contains', 'somevalue') }}"

# plugin    

class FilterModule(object):
    def filters(self):
      return {'my_filter': self.my_filter}

    def my_filter(data, function):
      something = function(data)
      return something

However, In official documentation and across the internet I only found examples of how to pass data but not callables.

0 Answers
Related