community.general.ipify_facts – Retrieve the public IP of your internet gateway

Note

This plugin is part of the community.general collection (version 3.8.3).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.ipify_facts.

Synopsis

  • If behind NAT and need to know the public IP of your internet gateway.

Parameters

Parameter

Comments

api_url

string

URL of the ipify.org API service.

?format=json will be appended per default.

Default: “https://api.ipify.org/”

timeout

integer

HTTP connection timeout in seconds.

Default: 10

validate_certs

boolean

When set to NO, SSL certificates will not be validated.

Choices:

  • no

  • yes ← (default)

Notes

Note

Examples

# Gather IP facts from ipify.org
- name: Get my public IP
  community.general.ipify_facts:

# Gather IP facts from your own ipify service endpoint with a custom timeout
- name: Get my public IP
  community.general.ipify_facts:
    api_url: http://api.example.com/ipify
    timeout: 20

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

ipify_public_ip

string

Public IP of the internet gateway.

Returned: success

Sample: “1.2.3.4”

Authors

  • René Moser (@resmo)