Add ansible_nodename (system hostname) to /etc/hosts
Kolla-Ansible populates /etc/hosts with overcloud hosts using their API
interface IP address. When configured correctly, this allows Nova to use
the API interface for live migration of instances between compute hosts.
The hostname used is from the `ansible_hostname` variable, which is a
short hostname generated by Ansible using the first dot as a delimiter.
However, Nova defaults to use the result of socket.gethostname() to
register nova-compute services.
In deployments where hostnames are set to FQDNs, for example when using
FreeIPA, nova-compute would try to reach the other compute node using
its FQDN (as registered in the Nova database), which was absent from
/etc/hosts. This can result in failures to live migrate instances if
DNS entries don't match.
This commit populates /etc/hosts with `ansible_nodename` (hostname as
reported by the system) in addition to `ansible_hostname`, if they are
different.
Change-Id: Id058aa1db8d60c979680e6a41f7f3e1c39f98235
Closes-Bug: #1830023
(cherry picked from commit 37899026bf
)
This commit is contained in:
parent
6ecab061f9
commit
8d260e0e3f
@ -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
|
||||
|
@ -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 <https://bugs.launchpad.net/kolla-ansible/+bug/1830023>`__ for
|
||||
details.
|
Loading…
Reference in New Issue
Block a user