tripleo-ansible/tripleo_ansible/roles/tripleo_cellv2/tasks/add_internalapi_hosts_entri...

58 lines
1.8 KiB
YAML

---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Add CellController internalapi to control plan controller
become: true
lineinfile:
dest: "/etc/hosts"
regexp: ".*{{ hostvars[item]['internal_api_hostname'] }}.*$"
line: >-
{{ hostvars[item]['internal_api_ip'] }}
{{ hostvars[item]['internal_api_hostname'] }}
{{ hostvars[item]['internal_api_hostname'].split('.')[:2] | join('.') }}
insertafter: "# HEAT_HOSTS_END"
state: present
when:
- hostvars[item]['internal_api_ip'] is defined
- hostvars[item]['internal_api_hostname'] is defined
with_items: "{{ tripleo_cellv2_cellcontroller_group }}"
register: hosts_result
tags:
- hosts
- create
- name: Restart nova services
become: true
block:
- name: nova restart podman
systemd:
name: "{{ item }}"
state: restarted
with_items:
- tripleo_nova_api
- tripleo_nova_conductor
- tripleo_nova_scheduler
when: tripleo_cellv2_containercli == "podman"
- name: nova restart docker
command: docker restart nova_api nova_scheduler nova_conductor
when: tripleo_cellv2_containercli == "docker"
when:
- hosts_result.changed
tags:
- hosts
- create