dashes in interface names not handled properly

Bug #1927357 reported by Erik Panter
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
kolla-ansible
Fix Released
Medium
Unassigned

Bug Description

**Environment**:
* OS (e.g. from /etc/os-release): Ubuntu 18.04.5 LTS
* Kolla-Ansible version: stable/ussuri (55ffe1f8f)
* Ansible version: 2.9.21

**Bug Report**
What happened:

We encountered this error during a Train -> Ussuri upgrade:

```
TASK [haproxy : Stopping all slave keepalived containers] ***************************************************************************************************
fatal: [os-ctrl-0]: FAILED! => {"msg": "The conditional check 'kolla_internal_vip_address not in addresses' failed. The error was: error while evaluating conditional (kolla_internal_vip_address not in addresses): {{ hostvars[inventory_hostname]['ansible_' + api_interface].get(key, []) | map(attribute='address') | list }}: 'ansible.vars.hostvars.HostVarsVars object' has no attribute 'ansible_os-api-internal'\n\nThe error appears to be in '/usr/local/share/kolla-ansible/ansible/roles/haproxy/tasks/upgrade.yml': line 6, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Stopping all slave keepalived containers\n ^ here\n"}
```

Our api_interface name here is "os-api-internal" which resulted in the variable name "ansible_os-api-internal"

This paragraph in the Ansible 3 documentation states that dashes need to be replaced by underscores when accessing these variables, and it seems to work the same way in 2.9:
https://docs.ansible.com/ansible/3/reference_appendices/faq.html#how-do-i-access-a-variable-name-programmatically

(note that the `replace` parameters seem to be interchanged in the doc)

Based on a quick search this should also affect prechecks and ovs deployment.

Erik Panter (epanter)
description: updated
Mark Goddard (mgoddard)
summary: - dashes in interface names not handeled properly
+ dashes in interface names not handled properly
Changed in kolla-ansible:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to kolla-ansible (master)

Related fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/kolla-ansible/+/794545

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Related fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/kolla-ansible/+/794857

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to kolla-ansible (master)

Reviewed: https://review.opendev.org/c/openstack/kolla-ansible/+/794857
Committed: https://opendev.org/openstack/kolla-ansible/commit/46bd05250d5c6497da35d8a490336a433915358e
Submitter: "Zuul (22348)"
Branch: master

commit 46bd05250d5c6497da35d8a490336a433915358e
Author: Mark Goddard <email address hidden>
Date: Fri Jun 4 17:05:24 2021 +0100

    baremetal: fix /etc/hosts generation when api_interface has dashes

    Interface names with dashes can cause problems in Ansible since dashes
    are replaced with underscores when referencing facts. In the baremetal
    role we reference the fact for api_interface without replacing dashes
    with underscores. This may result in host entries being omitted from
    /etc/hosts.

    This change fixes the issue.

    Change-Id: I667adc7d8a7dbd20dbfa293f389e02355f8275bb
    Related-Bug: #1927357

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to kolla-ansible (stable/wallaby)

Related fix proposed to branch: stable/wallaby
Review: https://review.opendev.org/c/openstack/kolla-ansible/+/797257

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to kolla-ansible (stable/victoria)

Related fix proposed to branch: stable/victoria
Review: https://review.opendev.org/c/openstack/kolla-ansible/+/797258

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to kolla-ansible (stable/ussuri)

Related fix proposed to branch: stable/ussuri
Review: https://review.opendev.org/c/openstack/kolla-ansible/+/797259

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to kolla-ansible (stable/wallaby)

Reviewed: https://review.opendev.org/c/openstack/kolla-ansible/+/797257
Committed: https://opendev.org/openstack/kolla-ansible/commit/315d8eec29b387bbc269eb4a13a3d979985bd845
Submitter: "Zuul (22348)"
Branch: stable/wallaby

commit 315d8eec29b387bbc269eb4a13a3d979985bd845
Author: Mark Goddard <email address hidden>
Date: Fri Jun 4 17:05:24 2021 +0100

    baremetal: fix /etc/hosts generation when api_interface has dashes

    Interface names with dashes can cause problems in Ansible since dashes
    are replaced with underscores when referencing facts. In the baremetal
    role we reference the fact for api_interface without replacing dashes
    with underscores. This may result in host entries being omitted from
    /etc/hosts.

    This change fixes the issue.

    Change-Id: I667adc7d8a7dbd20dbfa293f389e02355f8275bb
    Related-Bug: #1927357
    (cherry picked from commit 46bd05250d5c6497da35d8a490336a433915358e)

tags: added: in-stable-wallaby
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to kolla-ansible (stable/victoria)

Reviewed: https://review.opendev.org/c/openstack/kolla-ansible/+/797258
Committed: https://opendev.org/openstack/kolla-ansible/commit/5bc072141a8645414e62d2d468ebb8ed649c92bb
Submitter: "Zuul (22348)"
Branch: stable/victoria

commit 5bc072141a8645414e62d2d468ebb8ed649c92bb
Author: Mark Goddard <email address hidden>
Date: Fri Jun 4 17:05:24 2021 +0100

    baremetal: fix /etc/hosts generation when api_interface has dashes

    Interface names with dashes can cause problems in Ansible since dashes
    are replaced with underscores when referencing facts. In the baremetal
    role we reference the fact for api_interface without replacing dashes
    with underscores. This may result in host entries being omitted from
    /etc/hosts.

    This change fixes the issue.

    Change-Id: I667adc7d8a7dbd20dbfa293f389e02355f8275bb
    Related-Bug: #1927357
    (cherry picked from commit 46bd05250d5c6497da35d8a490336a433915358e)

tags: added: in-stable-victoria
tags: added: in-stable-ussuri
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to kolla-ansible (stable/ussuri)

Reviewed: https://review.opendev.org/c/openstack/kolla-ansible/+/797259
Committed: https://opendev.org/openstack/kolla-ansible/commit/c6aa022a4a047c0d266dd2ab303b5ec30f0a7ffe
Submitter: "Zuul (22348)"
Branch: stable/ussuri

commit c6aa022a4a047c0d266dd2ab303b5ec30f0a7ffe
Author: Mark Goddard <email address hidden>
Date: Fri Jun 4 17:05:24 2021 +0100

    baremetal: fix /etc/hosts generation when api_interface has dashes

    Interface names with dashes can cause problems in Ansible since dashes
    are replaced with underscores when referencing facts. In the baremetal
    role we reference the fact for api_interface without replacing dashes
    with underscores. This may result in host entries being omitted from
    /etc/hosts.

    This change fixes the issue.

    Change-Id: I667adc7d8a7dbd20dbfa293f389e02355f8275bb
    Related-Bug: #1927357
    (cherry picked from commit 46bd05250d5c6497da35d8a490336a433915358e)

Changed in kolla-ansible:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.