From 117ffded176d85fb882e2a10fecd3710d56a4975 Mon Sep 17 00:00:00 2001 From: Timothy Stewart Date: Mon, 3 Aug 2026 11:03:45 -0500 Subject: [PATCH] test(molecule): assert nodes register a non-loopback InternalIP - Add a flannel-scenario verify assertion that every node reports an InternalIP derived from its configured flannel_iface - Guards against k3s binding to 127.0.0.1 instead of the cluster interface - Complements the pre-commit default-interface test with an end-to-end check --- .../tasks/test/verify-components.yml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/molecule/resources/verify_from_outside/tasks/test/verify-components.yml b/molecule/resources/verify_from_outside/tasks/test/verify-components.yml index a72285f..d6eb36f 100644 --- a/molecule/resources/verify_from_outside/tasks/test/verify-components.yml +++ b/molecule/resources/verify_from_outside/tasks/test/verify-components.yml @@ -38,6 +38,30 @@ loop_control: label: "{{ item.metadata.name }} ready" + - name: Assert every node registered a node IP from its interface + # Each k3s node is launched with --node-ip derived from flannel_iface. + # Confirm every node carries a real InternalIP (not a loopback), which + # proves k3s bound to the cluster interface rather than defaulting to 127.0.0.1. + ansible.builtin.assert: + that: >- + (node_internal_ips | length) >= 1 and + (node_internal_ips | reject('eq', '127.0.0.1') | list | length) == node_internal_ips | length + success_msg: "{{ item.metadata.name }} is bound to {{ node_internal_ips | join(', ') }}" + fail_msg: >- + {{ item.metadata.name }} has no non-loopback InternalIP + (got: {{ node_internal_ips | join(', ') }}) + vars: + node_internal_ips: >- + {{ + (item.status.addresses | default([])) + | selectattr('type', 'equalto', 'InternalIP') + | map(attribute='address') + | list + }} + loop: "{{ verify_nodes.resources }}" + loop_control: + label: "{{ item.metadata.name }} InternalIP" + - name: Get any Calico namespaces with Flannel enabled kubernetes.core.k8s_info: kind: Namespace