Skip to content

Commit b5916f2

Browse files
rebtooropenshift-merge-bot[bot]
authored andcommitted
[multiple] Fix host filtering and MAC address handling
Two issues in the `deploy_bmh` role: **1. Host filter misses numbered suffixes** The host filter used exact string matching (`in` test) to exclude infrastructure hosts. This missed hosts like `controller-0`, causing BMH CRs to be created for the Ansible controller VM. Switch to regex prefix matching (`match`) so `controller-0`, `crc-0`, `ocp-worker-0`, etc. are all properly excluded. Apply the same fix in `cleanup_openstack` for consistency. **2. MAC addresses corrupted by `jinja2_native`** MAC addresses containing only decimal digits (e.g. `52:54:05:00:32:17`) are silently converted to integers by Ansible's `jinja2_native` mode (YAML 1.1 sexagesimal parsing). When `cifmw_baremetal_hosts` is set via extra vars (`-e @reproducer-variables.yml`), the MAC string passes through Jinja2 native evaluation and becomes an integer (`41136121937`). Load `baremetal-info.yml` into a namespaced variable via `include_vars` (which uses `yaml.safe_load` and preserves string types) and prefer it as the data source. Also quote `bootMACAddress` in the BMH template for defensive output. Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Roberto Alfieri <ralfieri@redhat.com>
1 parent 4e1b598 commit b5916f2

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

roles/cleanup_openstack/tasks/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
_cifmw_deploy_bmh_bm_hosts: >-
2929
{{
3030
cifmw_baremetal_hosts | default({}) | dict2items |
31-
rejectattr('key', 'in', ['crc', 'controller', 'ocp']) |
31+
rejectattr('key', 'match', '^(crc|controller|ocp)') |
3232
items2dict
3333
}}
3434
ansible.builtin.set_fact:

roles/deploy_bmh/tasks/main.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,27 @@
1414
# License for the specific language governing permissions and limitations
1515
# under the License.
1616

17-
- name: Load baremetal hosts information from file
17+
- name: Load baremetal hosts from file for type-safe MAC handling
1818
when:
1919
- cifmw_deploy_bmh_parameters_file is file
2020
- cifmw_baremetal_hosts is not defined
2121
ansible.builtin.include_vars:
2222
file: "{{ cifmw_deploy_bmh_parameters_file }}"
23+
name: _deploy_bmh_file_data
2324

2425
- name: Set baremetal hosts facts
26+
vars:
27+
_bmh_source: >-
28+
{{
29+
(_deploy_bmh_file_data | default({})).cifmw_baremetal_hosts |
30+
default(cifmw_baremetal_hosts) |
31+
default({})
32+
}}
2533
ansible.builtin.set_fact:
2634
cifmw_deploy_bmh_bm_hosts: >-
2735
{{
28-
cifmw_baremetal_hosts | default({}) | dict2items |
29-
rejectattr('key', 'in', ['crc', 'controller', 'ocp']) |
36+
_bmh_source | dict2items |
37+
rejectattr('key', 'match', '^(crc|controller|ocp)') |
3038
items2dict
3139
}}
3240

roles/deploy_bmh/template/bmh.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ spec:
2222
credentialsName: {{ node_name }}-bmc-secret
2323
disableCertificateVerification: {{ cifmw_deploy_bmh_disable_certificate_validation }}
2424
{% for nic in (node_data['nics'] | default([])) if nic['network'] == cifmw_deploy_bmh_boot_interface %}
25-
bootMACAddress: {{ nic.mac }}
25+
bootMACAddress: "{{ nic.mac }}"
2626
{% endfor %}
2727
bootMode: {{ node_data['boot_mode'] }}
2828
online: {{ 'true' if node_data['status'] | default("") == "running" else 'false' }}

0 commit comments

Comments
 (0)