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

Note

This module is part of the community.general collection (version 9.5.1).

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 false, SSL certificates will not be validated.

Choices:

  • false

  • true ← (default)

Attributes

Attribute

Support

Description

check_mode

Support: full

This action does not modify state.

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: N/A

This action does not modify state.

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

facts

Support: full

Action returns an ansible_facts dictionary that will update existing host facts.

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)