zuul-jobs/roles/multi-node-hosts-file/tasks/main.yaml
Andrea Frittoli 13b96b4bc6 Include hostnames in /etc/hosts
Include the resolution of the hostname to the private IPv4 for all
hosts in multinode setups.
Currently we only setup the inventory name, which is not enough
since qemu relies on the hostname for live migration.

Change-Id: I717f5f8b5b803abe874bea498fd07f5508cc7214
2018-06-05 11:13:03 +01:00

19 lines
589 B
YAML

- name: Set up the list of hosts and addresses
set_fact:
host_addresses: >
{% set hosts = {} -%}
{% for host, vars in hostvars.items() -%}
{% set _ = hosts.update({host: vars['nodepool']['private_ipv4']}) -%}
{% set _ = hosts.update({vars['ansible_hostname']: vars['nodepool']['private_ipv4']}) -%}
{% endfor -%}
{{- hosts -}}
- name: Add inventory hostnames to the hosts file
become: yes
lineinfile:
dest: /etc/hosts
state: present
insertafter: EOF
line: "{{ item.value }} {{ item.key }}"
with_dict: "{{ host_addresses }}"