community.general.ipify_facts (8.5.0) — module

Retrieve the public IP of your internet gateway

Authors: René Moser (@resmo)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

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

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Gather IP facts from ipify.org
- name: Get my public IP
  community.general.ipify_facts:
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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

Inputs

    
api_url:
    default: https://api.ipify.org/
    description:
    - URL of the ipify.org API service.
    - C(?format=json) will be appended per default.
    type: str

timeout:
    default: 10
    description:
    - HTTP connection timeout in seconds.
    type: int

validate_certs:
    default: true
    description:
    - When set to V(false), SSL certificates will not be validated.
    type: bool

Outputs

ipify_public_ip:
  description: Public IP of the internet gateway.
  returned: success
  sample: 1.2.3.4
  type: str