---
# Gather IP facts from ipify.org
- name: get my public IP
  ipify_facts:
  retries: 3

- name: set internal IP
  set_fact:
    host_internal_ip: "{{ ansible_default_ipv4.address }}"

# TODO: enable this for future GCE support in the playbooks
# - name: set public IP
#   set_fact:
#     host_public_ip: "{{ ipify_public_ip }}"
#   when: GCE

- name: set public IP
  set_fact:
    host_public_ip: "{{ host_internal_ip }}"
  # when: not GCE

- name: set interface name
  set_fact:
    interface_name: "{{ ansible_default_ipv4.alias }}"

- name: set interface gateway
  set_fact:
    interface_gateway: "{{ ansible_default_ipv4.gateway }}"

- name: set gateway next hop
  set_fact:
    gateway_next_hop: "{{ ansible_default_ipv4.gateway }}"

- debug: var=ansible_all_ipv4_addresses
- debug: var=host_internal_ip
- debug: var=host_public_ip
- debug: var=gateway_next_hop
