diff --git a/ansible/roles/baremetal/tasks/pre-install.yml b/ansible/roles/baremetal/tasks/pre-install.yml index 4dc3142d3e..6c4d9bfecc 100644 --- a/ansible/roles/baremetal/tasks/pre-install.yml +++ b/ansible/roles/baremetal/tasks/pre-install.yml @@ -28,7 +28,7 @@ marker: "# {mark} ANSIBLE GENERATED HOSTS" block: | {% for host in groups['baremetal'] %} - {% set api_interface = hostvars[host]['api_interface'] %} + {% set api_interface = hostvars[host]['api_interface'] | replace('-', '_') %} {% if host not in groups['bifrost'] or 'ansible_' + api_interface in hostvars[host] %} {% set hostnames = [hostvars[host]['ansible_nodename'], hostvars[host]['ansible_hostname']] %} {{ 'api' | kolla_address(host) }} {{ hostnames | unique | join(' ') }} @@ -39,7 +39,7 @@ - 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] + 'ansible_' + hostvars[inventory_hostname]['api_interface'] | replace('-', '_') in hostvars[inventory_hostname] # NOTE(osmanlicilegi): The distribution might come with cloud-init installed, and manage_etc_hosts # configuration enabled. If so, it will override the file /etc/hosts from cloud-init templates at diff --git a/releasenotes/notes/etc-hosts-dashes-37d0dc07c8fc881f.yaml b/releasenotes/notes/etc-hosts-dashes-37d0dc07c8fc881f.yaml new file mode 100644 index 0000000000..da5dbc9260 --- /dev/null +++ b/releasenotes/notes/etc-hosts-dashes-37d0dc07c8fc881f.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixes an issue when generating ``/etc/hosts`` during ``kolla-ansible + bootstrap-servers`` when one or more hosts has an ``api_interface`` with + dashes (``-``) in its name. `LP#1927357 + `__