Last active
August 29, 2015 13:57
-
-
Save zircote/9794700 to your computer and use it in GitHub Desktop.
ansible filters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# !/usr/bin/env python | |
""" | |
Example Usage: | |
--- | |
- debug: msg="{{ ansible_eth0.ipv4.address | ip2long }}" | |
""" | |
from socket import inet_aton | |
from struct import unpack | |
def ip2long(ip): | |
return unpack("!L", inet_aton(ip))[0] | |
class FilterModule(object): | |
def filters(self): | |
return {"ip2long": ip2long} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment