diff --git a/filter_plugin/ip_from_inventory.py b/filter_plugin/ip_from_inventory.py new file mode 100644 index 0000000..f19551a --- /dev/null +++ b/filter_plugin/ip_from_inventory.py @@ -0,0 +1,15 @@ +from ansible.hostvars import HostVars + +def ip_from_inventory(hostname): + """ + replace this ``{{ hostvars[hostname]['ansible_host'] }}`` + with something nicer such as `` {{ hostname | ip_from_inventory }}`` + """ + return HostVars[hostname]['ansible_host'] + +class FilterModule(object): + def filter(self): + return { + 'ip_from_inventory': ip_from_inventory, + } +