Add cell internalapi VIP in controllers /etc/hosts

When adding a cell into a tls-everywhere environment, also the
cellcontroller(s) internal api vip(s) is/are required to be added to
the central overcloud controllers, because when using a tls-everywhere
environment nova uses the cell controller internal api hostname instead
of the vip to connect to the cell DB.

When user executes the create-nova-cell-v2 playbook, as documented in
[0], add such extra entry/entries into the central controllers
/etc/hosts. Only do that if internal_api_vip and internal_api_hostname
are defined in the cell controller(s)' group hostvars (that would match
both non/TLS-E cases automagically).

[0] https://docs.openstack.org/project-deploy-guide/tripleo-docs/latest/features/deploy_cellv2_basic.html#cell-create-cell

Related: rhbz#1926716

Change-Id: Ib23d06ea702545a0c2f4f47da63ce588957488fe
Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
(cherry picked from commit c52f115d51)
This commit is contained in:
Bogdan Dobrelya 2022-04-22 12:15:34 +02:00
parent bc52446cd1
commit 4b5e8023d4
1 changed files with 23 additions and 1 deletions

View File

@ -34,6 +34,28 @@
- hosts
- create
- name: Add Cell internalapi VIP to control plan controller
become: true
vars:
cell_domain_name: >-
{{ hostvars[item]['internal_api_hostname'] | regex_replace(item ~ '\.?', '') }}
lineinfile:
dest: "/etc/hosts"
regexp: "\\s*{{ tripleo_cellv2_cell_name }}\\.?{{ cell_domain_name }}.*$"
line: >-
{{ hostvars[item]['internal_api_vip'] }}
{{ cell_domain_name | ternary(tripleo_cellv2_cell_name ~ '.' ~ cell_domain_name, tripleo_cellv2_cell_name) }}
insertafter: "# HEAT_HOSTS_END"
state: present
when:
- hostvars[item]['internal_api_vip'] is defined
- hostvars[item]['internal_api_hostname'] is defined
with_items: "{{ tripleo_cellv2_cellcontroller_group }}"
register: hosts_result2
tags:
- hosts
- create
- name: Restart nova services
become: true
block:
@ -51,7 +73,7 @@
command: docker restart nova_api nova_scheduler nova_conductor
when: tripleo_cellv2_containercli == "docker"
when:
- hosts_result.changed
- hosts_result.changed or hosts_result2.changed
tags:
- hosts
- create