- hosts: localhost
  connection: local
  gather_facts: no
  vars:
      he_fqdn: "{{ inventory_hostname }}"
      engine_vm_ipv4_def: defined
  tasks:
    - name: Get target engine VM IPv4 address
      shell: getent ahostsv4 {{ he_fqdn }} | cut -d' ' -f1 | uniq
      register: engine_vm_ipv4
      when: engine_vm_ipv4 is not defined
    - debug: msg={{ engine_vm_ipv4 }}
    - debug: msg={{ engine_vm_ipv4.stdout_lines[0] }}

    - name: Get target engine VM IPv4 address
      shell: getent ahostsv4 {{ he_fqdn }} | cut -d' ' -f1 | uniq
      register: engine_vm_ipv4_def
      when: engine_vm_ipv4_def is not defined
    - debug: msg={{ engine_vm_ipv4_def }}
    - debug: msg={{ engine_vm_ipv4_def.stdout_lines[0] }}

