�
�Udac @` s� d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d
Z d d l
m Z d d l m
Z
d
Z d e f d � � YZ d � Z e d k r� e � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust communityt supported_bys%
---
module: ipinfoio_facts
short_description: "Retrieve IP geolocation facts of a host's IP address"
description:
- "Gather IP geolocation facts of a host's IP address using ipinfo.io API"
version_added: "2.3"
author: "Aleksei Kostiuk (@akostyuk)"
options:
timeout:
description:
- HTTP connection timeout in seconds
required: false
default: 10
http_agent:
description:
- Set http user agent
required: false
default: "ansible-ipinfoio-module/0.0.1"
notes:
- "Check http://ipinfo.io/ for more information"
sf
# Retrieve geolocation data of a host's IP address
- name: get IP geolocation data
ipinfoio_facts:
s�
ansible_facts:
description: "Dictionary of ip geolocation facts for a host's IP address"
returned: changed
type: complex
contains:
ip:
description: "Public IP address of a host"
type: str
sample: "8.8.8.8"
hostname:
description: Domain name
type: str
sample: "google-public-dns-a.google.com"
country:
description: ISO 3166-1 alpha-2 country code
type: str
sample: "US"
region:
description: State or province name
type: str
sample: "California"
city:
description: City name
type: str
sample: "Mountain View"
loc:
description: Latitude and Longitude of the location
type: str
sample: "37.3860,-122.0838"
org:
description: "organization's name"
type: str
sample: "AS3356 Level 3 Communications, Inc."
postal:
description: Postal code
type: str
sample: "94035"
( t
AnsibleModule( t fetch_urls ansible-ipinfoio-module/0.0.1t
IpinfoioFactsc B` s e Z d � Z d � Z RS( c C` s+ d | _ | j j d � | _ | | _ d S( Ns https://ipinfo.io/jsont timeout( t urlt paramst getR t module( t selfR ( ( sL /usr/lib/python2.7/site-packages/ansible/modules/net_tools/ipinfoio_facts.pyt __init__^ s c C` s� t | j | j d t d | j �\ } } y | d d k Wn0 t k
rn | j j d d j | j � � nf Xy+ | j � } | j j | j
d � � } Wn3 t k
r� | j j d d j | j | � � n X| Sd S( Nt forceR R i� t msgs/ Could not get {0} page, check for connectivity!t utf8s/ Failed to parse the ipinfo.io response: {0} {1}( R R R t TrueR t AssertionErrort fail_jsont formatt readt from_jsont decodet
ValueError( R t responset infot contentt result( ( sL /usr/lib/python2.7/site-packages/ansible/modules/net_tools/ipinfoio_facts.pyt get_geo_datac s
( t __name__t
__module__R R! ( ( ( sL /usr/lib/python2.7/site-packages/ansible/modules/net_tools/ipinfoio_facts.pyR
\ s c C` st t d t d t d t � d t d d d d � � d t � } t | � } t d t d
| j � � } | j | � d S( Nt
argument_spect
http_agentt defaultR t typet inti
t supports_check_modet changedt
ansible_facts( R t dictt
USER_AGENTR R
t FalseR! t exit_json( R t ipinfoiot ipinfoio_result( ( sL /usr/lib/python2.7/site-packages/ansible/modules/net_tools/ipinfoio_facts.pyt mainw s t __main__N( t
__future__R R R R'