Fix prechecks for interfaces with dashes

Closes-Bug: #2070051

Depends-On: https://review.opendev.org/c/openstack/ansible-collection-kolla/+/923544

Change-Id: I221eb136e77c61aef39e8646b48b927352d1419d
This commit is contained in:
Michal Nasiadka 2024-06-21 16:39:09 +02:00
parent 09067aa0cd
commit a535e65a85
6 changed files with 6 additions and 12 deletions

View File

@ -107,7 +107,7 @@
- name: Checking the kolla_external_vip_interface is active
assert:
that: hostvars[inventory_hostname].ansible_facts[kolla_external_vip_interface]['active']
that: hostvars[inventory_hostname].ansible_facts[kolla_external_vip_interface | replace('-', '_')]['active']
fail_msg: "Please check the kolla_external_vip_interface settings - interface {{ kolla_external_vip_interface }} is not active"
when:
- haproxy_enable_external_vip | bool

View File

@ -5,7 +5,7 @@
- name: Checking the api_interface is active
fail: "msg='Please check the api_interface settings - interface {{ api_interface }} is not active'"
when: not hostvars[inventory_hostname].ansible_facts[api_interface]['active']
when: not hostvars[inventory_hostname].ansible_facts[api_interface | replace('-', '_')]['active']
# kolla_address handles relevant address check
- name: Checking the api_interface ip address configuration

View File

@ -78,12 +78,6 @@ In Kolla operators should configure following network interfaces:
with the bare metal cloud hosts in order to provide DHCP leases with
PXE boot options. Defaults to ``network_interface``.
.. warning::
Ansible facts does not recognize interface names containing dashes,
in example ``br-ex`` or ``bond-0`` cannot be used because ansible will read
them as ``br_ex`` and ``bond_0`` respectively.
.. _address-family-configuration:
Address family configuration (IPv4/IPv6)

View File

@ -106,7 +106,7 @@ following:
static_configs:
- targets:
{% for host in groups['prometheus'] %}
- '{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ 3456 }}'
- '{{ hostvars[host][('ansible_' + hostvars[host]['api_interface'] | replace('-','_'))]['ipv4']['address'] }}:{{ 3456 }}'
{% endfor %}
The jobs, ``custom``, and ``custom_template`` would be appended to the default

View File

@ -33,7 +33,7 @@
- name: Bootstrap cephadm
vars:
mon_ip: "{{ hostvars[inventory_hostname]['ansible_' + api_interface_name].ipv4.address }}"
mon_ip: "{{ hostvars[inventory_hostname]['ansible_' + api_interface_name | replace('-','_')].ipv4.address }}"
command:
cmd: >
cephadm
@ -80,7 +80,7 @@
ceph_conf_fixed: |
[global]
fsid = {{ ceph_fsid }}
mon_host = {% for host in groups['all'] %} {{ hostvars[host]['ansible_' + api_interface_name].ipv4.address }} {% if not loop.last %},{% endif %} {% endfor %}
mon_host = {% for host in groups['all'] %} {{ hostvars[host]['ansible_' + api_interface_name | replace('-','_')].ipv4.address }} {% if not loop.last %},{% endif %} {% endfor %}
copy:
content: "{{ ceph_conf_fixed }}"
dest: "/etc/ceph/ceph.conf.fixed"

View File

@ -349,7 +349,7 @@
KOLLA_SWIFT_BASE_IMAGE: "{{ docker_image_prefix }}swift-base:{{ docker_image_tag }}"
# NOTE(yoctozepto): no IPv6 for now
STORAGE_NODES: "{{ groups['all'] | map('extract', hostvars,
['ansible_'+api_interface_name, 'ipv4', 'address'])
['ansible_'+api_interface_name | replace('-','_') , 'ipv4', 'address'])
| join(' ') }}"
CONTAINER_ENGINE: "{{ container_engine }}"
when: scenario == 'swift'