Select Page

Based on: https://stackoverflow.com/questions/39819378/ansible-get-current-target-hosts-ip-address

- name: test playbook
  hosts: newinstance
  become: yes
  become_method: sudo
  gather_facts: yes

  tasks:
    - debug: msg="{{ansible_all_ipv4_addresses}}"
    - debug: msg="{{ansible_default_ipv4.address}}"

On GCE ansible_default_ipv4.address contains IP of GCE internal network.