community.general.ipbase_info 模块 – 使用 ipbase.com API 获取主机的 IP 地理位置和其他信息
注意
此模块是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。
要在 playbook 中使用它,请指定:community.general.ipbase_info
。
community.general 7.0.0 中的新增功能
概要
使用 ipbase.com API 获取主机的 IP 地理位置和其他信息
参数
参数 |
注释 |
---|---|
如果您需要更多请求,则为请求的 API 密钥。 |
|
您要获取信息的 IP。如果未指定,API 将自动检测 IP。 |
|
用于本地化 IP 数据的 ISO Alpha 2 语言代码 默认值: |
属性
属性 |
支持 |
描述 |
---|---|---|
支持:完整 此操作不会修改状态。 |
可以在 |
|
支持: 不适用 此操作不会修改状态。 |
在 diff 模式下,将返回有关已更改(或可能需要在 |
注释
注意
有关更多信息,请查看 https://ipbase.com/。
示例
- name: "Get IP geolocation information of the primary outgoing IP"
community.general.ipbase_info:
register: my_ip_info
- name: "Get IP geolocation information of a specific IP"
community.general.ipbase_info:
ip: "8.8.8.8"
register: my_ip_info
- name: "Get IP geolocation information of a specific IP with all other possible parameters"
community.general.ipbase_info:
ip: "8.8.8.8"
apikey: "xxxxxxxxxxxxxxxxxxxxxx"
hostname: true
language: "de"
register: my_ip_info
返回值
常用返回值已记录在此处 此处,以下是此模块特有的字段
键 |
描述 |
---|---|
来自 ipbase.com 的 JSON 解析响应。有关响应的详细结构,请参阅 https://ipbase.com/docs/info。 返回: 成功 示例: |