community.general.ipinfoio_facts 模块 – 获取主机IP地址的地理位置信息

注意

此模块是 community.general 集合 (版本 10.1.0) 的一部分。

如果您使用的是 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用: ansible-galaxy collection install community.general

要在playbook中使用它,请指定: community.general.ipinfoio_facts

概要

  • 使用ipinfo.io API收集主机IP地址的地理位置信息

参数

参数

注释

http_agent

字符串

设置http用户代理

默认值: "ansible-ipinfoio-module/0.0.1"

timeout

整数

HTTP连接超时时间(秒)

默认值: 10

属性

属性

支持

描述

check_mode

支持:完全支持

此操作不会修改状态。

可以在 check_mode 下运行,并在不修改目标的情况下返回更改状态预测。

diff_mode

支持: N/A

此操作不会修改状态。

在差异模式下,将返回有关已更改内容(或可能需要在 check_mode 中更改的内容)的详细信息。

facts

支持:完全支持

操作返回一个 ansible_facts 字典,该字典将更新现有的主机facts。

备注

注意

示例

# Retrieve geolocation data of a host's IP address
- name: Get IP geolocation data
  community.general.ipinfoio_facts:

返回的facts

此模块返回的facts添加到/更新 hostvars 主机facts中,并且可以像任何其他主机fact一样按名称引用。它们不需要注册即可使用。

描述

city

字符串

城市名称

返回:成功

示例: "Mountain View"

country

字符串

ISO 3166-1 alpha-2国家代码

返回:成功

示例: "US"

hostname

字符串

域名

返回:成功

示例: "google-public-dns-a.google.com"

ip

字符串

主机的公共IP地址

返回:成功

示例: "8.8.8.8"

loc

字符串

位置的经纬度

返回:成功

示例: "37.3860,-122.0838"

org

字符串

组织名称

返回:成功

示例: "AS3356 Level 3 Communications, Inc."

postal

字符串

邮政编码

返回:成功

示例: "94035"

region

字符串

州或省份名称

返回:成功

示例: "California"

作者

  • Aleksei Kostiuk (@akostyuk)