zuul-jobs/roles/multi-node-hosts-file/tasks/main.yaml
David Moreau-Simard 974b5d7dac
Multi-node: Set up hosts file
This allows nodes in a multi-node job to resolve each other through
their inventory hostname.

Change-Id: I19cc7690d6fea99461bc67a46a09a8037f9c3292
2017-09-22 16:25:51 -04:00

18 lines
493 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']}) -%}
{% 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 }}"