--- - name: "Get ip of {{ host }}" ansible.builtin.shell: | getent ahosts {{ host }} | cut -d' ' -f1 | sort -u register: _host_ip changed_when: false - name: "Get ip of {{ microshift_host }}" ansible.builtin.shell: | getent ahosts {{ microshift_host }} | cut -d' ' -f1 | sort -u register: _microshift_ip changed_when: false - name: "Ensure /etc/hosts contains {{ host }}" ansible.builtin.lineinfile: path: /etc/hosts line: "{{ _microshift_ip.stdout }} {{ host }}" when: _host_ip.stdout == "" become: true