diff --git a/ansible/roles/baremetal/tasks/pre-install.yml b/ansible/roles/baremetal/tasks/pre-install.yml index f67300ed67..d24f1e01a4 100644 --- a/ansible/roles/baremetal/tasks/pre-install.yml +++ b/ansible/roles/baremetal/tasks/pre-install.yml @@ -24,7 +24,8 @@ {% for host in groups['baremetal'] %} {% set api_interface = hostvars[host]['api_interface'] %} {% if host not in groups['bifrost'] or 'ansible_' + api_interface in hostvars[host] %} - {{ hostvars[host]['ansible_' + api_interface]['ipv4']['address'] }} {{ hostvars[host]['ansible_hostname'] }} + {% set hostnames = [hostvars[host]['ansible_nodename'], hostvars[host]['ansible_hostname']] %} + {{ hostvars[host]['ansible_' + api_interface]['ipv4']['address'] }} {{ hostnames | unique | join(' ') }} {% endif %} {% endfor %} become: True diff --git a/releasenotes/notes/add-nodename-to-etc-hosts-6360acc642ee3d49.yaml b/releasenotes/notes/add-nodename-to-etc-hosts-6360acc642ee3d49.yaml new file mode 100644 index 0000000000..84998c1c8b --- /dev/null +++ b/releasenotes/notes/add-nodename-to-etc-hosts-6360acc642ee3d49.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Adds system hostnames to ``/etc/hosts``, if different from short hostnames. + This can fix live migration of Nova instances in some contexts. See `bug + 1830023 `__ for + details.