|
37 | 37 | ocp_workers: "{{ workers | json_query('resources[*].metadata.name') | sort }}" |
38 | 38 | num_workers: "{{ workers.resources | length }}" |
39 | 39 |
|
40 | | -- name: Discover IPv6 interfaces on first worker |
| 40 | +- name: Discover IPv6 interfaces on all workers via live state |
41 | 41 | ansible.builtin.shell: | |
42 | 42 | set -o pipefail && \ |
43 | | - oc adm node-logs {{ ocp_workers[0] }} | \ |
44 | | - grep '{{ item.cidr | regex_replace('::/64$', '') }}' | \ |
45 | | - grep dev | \ |
46 | | - sed 's/.*{{ item.cidr | regex_replace('::/64$', '') }}::.* dev \(\S\+\).*/\1/g' | \ |
47 | | - tail -1 |
| 43 | + timeout 120 oc debug node/{{ item.0 }} -- chroot /host \ |
| 44 | + ip -6 addr show scope global | \ |
| 45 | + grep -B1 '{{ item.1.cidr | regex_replace('::/64$', '') }}' | \ |
| 46 | + awk -F': ' '/^[0-9]/{print $2}' | head -1 |
48 | 47 | environment: |
49 | 48 | KUBECONFIG: "{{ kubeconfig }}" |
50 | | - loop: "{{ ipv6_secondary_networks.networks }}" |
51 | | - register: ipv6_interfaces_results |
| 49 | + with_nested: |
| 50 | + - "{{ ocp_workers }}" |
| 51 | + - "{{ ipv6_secondary_networks.networks }}" |
| 52 | + register: all_worker_interfaces |
52 | 53 | changed_when: false |
53 | 54 | retries: 10 |
54 | 55 | delay: 30 |
55 | | - until: ipv6_interfaces_results.stdout != "" |
| 56 | + until: all_worker_interfaces.stdout != "" |
56 | 57 |
|
57 | | -- name: Store IPv6 interface names |
| 58 | +- name: Validate consistent NIC naming across all workers |
| 59 | + ansible.builtin.assert: |
| 60 | + that: |
| 61 | + - per_network_interfaces | unique | length == 1 |
| 62 | + fail_msg: | |
| 63 | + NIC naming inconsistency for {{ item.net_name }}: {{ per_network_interfaces }} |
| 64 | + Workers have different interface names for the same IPv6 network. |
| 65 | + vars: |
| 66 | + per_network_interfaces: "{{ all_worker_interfaces.results | selectattr('item.1.net_name', 'equalto', item.net_name) | map(attribute='stdout') | list }}" |
| 67 | + loop: "{{ ipv6_secondary_networks.networks }}" |
| 68 | + |
| 69 | +- name: Store IPv6 interface names (validated consistent across workers) |
58 | 70 | ansible.builtin.set_fact: |
59 | | - ipv6_interfaces: "{{ ipv6_interfaces_results.results | map(attribute='stdout') | list }}" |
| 71 | + ipv6_interfaces: "{{ all_worker_interfaces.results | selectattr('item.0', 'equalto', ocp_workers[0]) | map(attribute='stdout') | list }}" |
60 | 72 |
|
61 | 73 | - name: Validate discovered IPv6 interfaces are not empty |
62 | 74 | ansible.builtin.assert: |
63 | 75 | that: |
64 | 76 | - ipv6_interfaces | length == ipv6_secondary_networks.networks | length |
65 | 77 | - ipv6_interfaces | select('equalto', '') | list | length == 0 |
66 | 78 | fail_msg: | |
67 | | - Failed to discover IPv6 interfaces on worker {{ ocp_workers[0] }}. |
| 79 | + Failed to discover IPv6 interfaces on workers. |
68 | 80 | Expected {{ ipv6_secondary_networks.networks | length }} interfaces, got: {{ ipv6_interfaces }} |
69 | 81 |
|
70 | 82 | - name: Display discovered IPv6 interfaces |
|
94 | 106 | KUBECONFIG: "{{ kubeconfig }}" |
95 | 107 | changed_when: true |
96 | 108 |
|
97 | | -- name: Verify NetworkAttachmentDefinition CRs exist |
| 109 | +- name: Verify NetworkAttachmentDefinition CR exists in {{ item }} |
98 | 110 | kubernetes.core.k8s_info: |
99 | 111 | kubeconfig: "{{ kubeconfig }}" |
100 | 112 | api_version: k8s.cni.cncf.io/v1 |
101 | 113 | kind: NetworkAttachmentDefinition |
| 114 | + namespace: "{{ item }}" |
102 | 115 | register: network_attachments |
103 | 116 | until: |
104 | 117 | - network_attachments is defined |
105 | 118 | - network_attachments is not failed |
106 | | - - network_attachments | json_query('resources[*].metadata.name') | list | sort == ipv6_secondary_networks.projects | sort |
| 119 | + - network_attachments.resources | length > 0 |
107 | 120 | retries: 10 |
108 | 121 | delay: 30 |
| 122 | + loop: "{{ ipv6_secondary_networks.projects }}" |
109 | 123 |
|
110 | 124 | - name: Template IPv6 test deployments |
111 | 125 | ansible.builtin.template: |
|
0 commit comments