
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
113 lines
3.3 KiB
YAML
113 lines
3.3 KiB
YAML
---
|
|
# NOTE: raw install is required to support cloud images which do not have python installed
|
|
- name: "Install python2 and python-simplejson"
|
|
become: True
|
|
raw: "yum install -y python python-simplejson || (apt-get update && apt-get install -y python2.7 python-simplejson)"
|
|
|
|
- name: Gather facts
|
|
setup:
|
|
|
|
- name: Ensure localhost in /etc/hosts
|
|
lineinfile:
|
|
dest: /etc/hosts
|
|
regexp: "^127.0.0.1.*"
|
|
line: "127.0.0.1 localhost"
|
|
state: present
|
|
become: True
|
|
when: customize_etc_hosts | bool
|
|
|
|
- name: Generate /etc/hosts for all of the nodes
|
|
blockinfile:
|
|
dest: /etc/hosts
|
|
marker: "# {mark} ANSIBLE GENERATED HOSTS"
|
|
block: |
|
|
{% 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] %}
|
|
{% set hostnames = [hostvars[host]['ansible_nodename'], hostvars[host]['ansible_hostname']] %}
|
|
{{ hostvars[host]['ansible_' + api_interface]['ipv4']['address'] }} {{ hostnames | unique | join(' ') }}
|
|
{% endif %}
|
|
{% endfor %}
|
|
become: True
|
|
when:
|
|
- customize_etc_hosts | bool
|
|
# Skip hosts in the bifrost group that do not have a valid api_interface.
|
|
- inventory_hostname not in groups['bifrost'] or
|
|
'ansible_' + hostvars[inventory_hostname]['api_interface'] in hostvars[inventory_hostname]
|
|
|
|
- name: Ensure sudo group is present
|
|
group:
|
|
name: sudo
|
|
state: present
|
|
become: True
|
|
|
|
- name: Ensure kolla group is present
|
|
group:
|
|
name: "{{ kolla_group }}"
|
|
state: present
|
|
become: True
|
|
when: create_kolla_user | bool
|
|
|
|
- block:
|
|
- block:
|
|
- name: Install apt packages
|
|
apt:
|
|
update_cache: yes
|
|
become: True
|
|
|
|
- name: Install ca certs
|
|
package:
|
|
name: "{{ item }}"
|
|
state: latest
|
|
become: True
|
|
with_items:
|
|
- ca-certificates
|
|
- apt-transport-https
|
|
|
|
- name: Ensure apt sources list directory exists
|
|
file:
|
|
path: /etc/apt/sources.list.d
|
|
state: directory
|
|
recurse: yes
|
|
become: True
|
|
|
|
- name: Install docker apt gpg key
|
|
apt_key:
|
|
url: "{{ docker_apt_url }}/{{ docker_apt_key_file }}"
|
|
id: "{{ docker_apt_key_id }}"
|
|
state: present
|
|
become: True
|
|
|
|
- name: Enable docker apt repository
|
|
apt_repository:
|
|
repo: "{{ docker_apt_repo }}"
|
|
filename: docker
|
|
become: True
|
|
when: ansible_os_family == 'Debian'
|
|
|
|
- block:
|
|
- name: Ensure yum repos directory exists
|
|
file:
|
|
path: /etc/yum.repos.d/
|
|
state: directory
|
|
recurse: yes
|
|
become: True
|
|
|
|
- name: Enable docker yum repository
|
|
yum_repository:
|
|
name: docker
|
|
description: Docker main Repository
|
|
baseurl: "{{ docker_yum_baseurl }}"
|
|
gpgcheck: "{{ docker_yum_gpgcheck | bool }}"
|
|
gpgkey: "{{ docker_yum_gpgkey }}"
|
|
become: True
|
|
|
|
- name: Install docker rpm gpg key
|
|
rpm_key:
|
|
state: present
|
|
key: "{{ docker_yum_url }}/gpg"
|
|
become: True
|
|
when: docker_yum_gpgcheck | bool
|
|
when: ansible_os_family == 'RedHat'
|
|
when: enable_docker_repo | bool
|