---
  - name: Configure Hosts File
    lineinfile: >
      path=/etc/hosts
      regexp='.*{{ item }}$'
      line="{{ hostvars[item].ansible_default_ipv4.address }} {{item}}"
      state=present
    when: hostvars[item].ansible_default_ipv4.address is defined
    with_items: "{{ groups['nodes'] }}"
