github.com/jlmeeker/kismatic@v1.10.1-0.20180612190640-57f9005a1f1a/ansible/roles/hosts/tasks/main.yaml (about)

     1  - name: remove this hostname from hosts file
     2    lineinfile: dest=/etc/hosts regexp='.*{{ inventory_hostname }}$' state=absent
     3  
     4  - name: add nodes to hosts file
     5    blockinfile:
     6      dest: /etc/hosts
     7      state: present
     8      marker: "# Kismatic hosts {mark}"
     9      backup: yes
    10      block: |-
    11        {% for item in groups['all'] %}
    12        {% if hostvars[item].internal_ipv4 is defined %}
    13        {{ hostvars[item].internal_ipv4 }} {{ item }}
    14        {% endif %}
    15        {% endfor %}