I am developing a custom Ansible action plugin. From in there I would like to calculate the gateway and subnet mask from an CIDR. This is already possible with the ipaddr filter. Instead of replicating the code, is there a way to call the ipaddr filter from inside an action plugin?
I know you can call a module from an action plugin like so:
self._execute_module(...)
Is anything like this available for filters?
I looked into the source of Ansible and found the filter_loader
class but have not figured out how to use it.
from ansible.errors import AnsibleError, AnsibleFilterError
from ansible.plugins import filter_loader
...
ipaddr = filter_loader.get('ipaddr')
This results into an error, I think I can not avoid without modifications on the ipaddr filter itself, which of course is no option.
Traceback (most recent call last):
File "/usr/lib64/python2.7/multiprocessing/queues.py", line 266, in _feed
send(obj)
PicklingError: Can't pickle <class '/usr/lib/python2.7/site-packages/ansible/plugins/filter/ipaddr.FilterModule'>: import of module /usr/lib/python2.7/site-packages/ansible/plugins/filter/ipaddr failed