Browse Source

draft for filter to get ip from hostname

python3
Edoardo Putti 8 years ago
parent
commit
23b9a38909
1 changed files with 15 additions and 0 deletions
  1. +15
    -0
      filter_plugin/ip_from_inventory.py

+ 15
- 0
filter_plugin/ip_from_inventory.py View File

@ -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,
}

Loading…
Cancel
Save