watcher/roles/add-hostnames-to-hosts/tasks/main.yaml
Alexander Chadin 6bb0432ee7 ZuulV3 jobs
This patch set removes legacy-* jobs and migrates
tempest functional job to ZuulV3 syntax.

Change-Id: I87771737cc713eae20b4d6aaaefefc5e40875666
Implements: blueprint migrate-to-zuulv3
2018-03-23 20:40:23 +00:00

16 lines
523 B
YAML

- name: Set up the list of hostnames and addresses
set_fact:
hostname_addresses: >
{% set hosts = {} -%}
{% for host, vars in hostvars.items() -%}
{% 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: "{{ hostname_addresses }}"