tripleo-ansible/tripleo_ansible/roles/tripleo_hosts_entries/tasks/main.yml
Jose Luis Franco Arza 4578d6d61c Change Ansible group from overcloud to allovercloud.
[0] got merged to enable multistack working in the overcloud. This
patch modifies the overcloud group in the inventory and changes its
name into allovercloud. We need to adapt all the calls to the old
overcloud group to work with the new allovercloud instead.

[0] - Ife14dbe04dd11db44a944f98373f63e01dfbb8d8

Change-Id: I80a00b3d7d11921306f86efc8023aa89500d4f3e
2020-04-23 18:07:51 +02:00

69 lines
2.5 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
# 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: Remove old Heat hosts configuration (if present)
become: true
blockinfile:
state: absent
path: "{{ tripleo_hosts_entries_hosts_path }}"
block: ""
marker: "# {mark}"
marker_begin: "HEAT_HOSTS_START - Do not edit manually within this section!"
marker_end: "HEAT_HOSTS_END"
tags:
- tripleo_hosts_entries
- name: Render out the hosts entries
run_once: true
set_fact:
tripleo_hosts_entries_block: |
{% for host in groups['allovercloud'] -%}
{{ hostvars[host][hostvars[host]['hostname_resolve_network'] ~ '_ip'] ~ ' ' ~
host ~ '.' ~ cloud_domain ~ ' ' ~ host }}
{# ## NOTE(hjensas): The Undercloud Minion has no networks, need to check for that here. -#}
{% if hostvars[host]['role_networks'] is not none -%}
{% set _role_networks = hostvars[host]['role_networks'] | default ([]) -%}
{% set _networks = (enabled_networks | default([])) | intersect(_role_networks) -%}
{% for network in _networks -%}
{{ hostvars[host][networks[network]['name_lower'] ~ '_ip'] ~ ' ' ~
host ~ '.' ~ network.lower() ~ '.' ~ cloud_domain ~ ' ' ~
host ~ '.' ~ network.lower() }}
{% endfor -%}
{% endif -%}
{{ hostvars[host]['ctlplane_ip'] ~ ' ' ~
host ~ '.ctlplane' ~ '.' ~ cloud_domain ~ ' ' ~ host ~ '.ctlplane' }}
{% endfor %}
tags:
- tripleo_hosts_entries
- name: Update /etc/hosts
become: true
blockinfile:
create: true
path: "{{ tripleo_hosts_entries_hosts_path }}"
# BOF denotes the beginning of the file.
insertbefore: BOF
block: |
{{ tripleo_hosts_entries_block }}
{% for host in tripleo_hosts_entries_undercloud_hosts_entries | default([]) +
tripleo_hosts_entries_vip_hosts_entries | default([]) +
tripleo_hosts_entries_extra_hosts_entries | default([]) %}
{{ host }}
{% endfor %}
tags:
- tripleo_hosts_entries