|
14 | 14 | # License for the specific language governing permissions and limitations |
15 | 15 | # under the License. |
16 | 16 |
|
17 | | - |
18 | 17 | - name: Converge |
19 | 18 | hosts: all |
20 | 19 | gather_facts: true |
21 | | - vars: |
22 | | - cifmw_path: "{{ ansible_user_dir }}/.crc/bin:{{ ansible_user_dir }}/.crc/bin/oc:{{ ansible_user_dir }}/bin:{{ ansible_env.PATH }}" |
23 | | - cifmw_openshift_kubeconfig: "{{ ansible_user_dir }}/.crc/machines/crc/kubeconfig" |
24 | | - testpod_name: "pod-testnad" |
25 | 20 | tasks: |
26 | 21 | - name: Add crc hostname with it's IP to /etc/hosts |
27 | 22 | become: true |
|
41 | 36 | delegate_to: crc |
42 | 37 | delegate_facts: true |
43 | 38 |
|
44 | | - - name: Prepare the network var for the role |
| 39 | + - name: Load shared variables |
| 40 | + ansible.builtin.include_vars: |
| 41 | + file: ../resources/vars/shared_vars.yml |
| 42 | + |
| 43 | + - name: Override interface name in cifmw_networking_env_definition |
| 44 | + vars: |
| 45 | + _cifmw_networking_env_definition_patch: |
| 46 | + instances: |
| 47 | + crc: |
| 48 | + networks: |
| 49 | + default: |
| 50 | + interface_name: "{{ hostvars.crc.ansible_default_ipv4.interface }}" |
45 | 51 | ansible.builtin.set_fact: |
46 | | - crc_ci_bootstrap_networks_out: |
47 | | - networks: |
48 | | - default: |
49 | | - iface: "{{ hostvars.crc.ansible_default_ipv4.interface }}" |
50 | | - mtu: 1500 |
51 | | - range: 192.168.122.0/24 |
52 | | - multus: |
53 | | - range: 192.168.122.30-192.168.122.70 |
54 | | - cifmw_ci_multus_nad_extra_list: |
55 | | - - name: bgpnet1 |
56 | | - iface: bgpnet1_iface |
57 | | - type: interface |
58 | | - ipam: |
59 | | - type: whereabouts |
60 | | - range: 100.65.4.0/30 |
61 | | - range_start: 100.65.4.1 |
62 | | - range_end: 100.65.4.2 |
| 52 | + cifmw_networking_env_definition: "{{ cifmw_networking_env_definition | combine(_cifmw_networking_env_definition_patch, recursive=True) }}" |
63 | 53 |
|
64 | 54 | - name: Call ci_multus role |
65 | 55 | ansible.builtin.include_role: |
66 | 56 | name: "ci_multus" |
67 | | - |
68 | | - # Verify the run |
69 | | - - name: Fetch files stat results |
70 | | - ansible.builtin.stat: |
71 | | - path: >- |
72 | | - {{ |
73 | | - [ |
74 | | - ansible_user_dir, |
75 | | - 'ci-framework-data', |
76 | | - 'artifacts', |
77 | | - item |
78 | | - ] | ansible.builtin.path_join |
79 | | - }} |
80 | | - register: _ci_multus_molecule_stat_out |
81 | | - loop: |
82 | | - - manifests/ci_multus/ci_multus_nads.yml |
83 | | - |
84 | | - - name: Assert that all expected files exist |
85 | | - ansible.builtin.assert: |
86 | | - that: >- |
87 | | - _ci_multus_molecule_stat_out.results | |
88 | | - map(attribute="stat.exists") | |
89 | | - select("equalto", true) | |
90 | | - length == (_ci_multus_molecule_stat_out.results | length) |
91 | | -
|
92 | | - - name: Fetch all files content |
93 | | - ansible.builtin.slurp: |
94 | | - path: "{{ item }}" |
95 | | - register: _ci_multus_molecule_slurp_out |
96 | | - loop: >- |
97 | | - {{ |
98 | | - _ci_multus_molecule_stat_out.results | |
99 | | - map(attribute="stat.path") |
100 | | - }} |
101 | | -
|
102 | | - - name: Assert that all files contains proper YAML data |
103 | | - ansible.builtin.assert: |
104 | | - that: "item.content | b64decode | from_yaml_all | length > 0" |
105 | | - loop: "{{ _ci_multus_molecule_slurp_out.results }}" |
106 | | - loop_control: |
107 | | - label: "{{ item.source }}" |
108 | | - |
109 | | - - name: Check if NADs were created |
110 | | - kubernetes.core.k8s_info: |
111 | | - kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
112 | | - namespace: "{{ cifmw_ci_multus_namespace }}" |
113 | | - api_version: k8s.cni.cncf.io/v1 |
114 | | - kind: NetworkAttachmentDefinition |
115 | | - register: _ci_multus_molecule_nads_out |
116 | | - failed_when: >- |
117 | | - (_ci_multus_molecule_nads_out is not defined) or |
118 | | - (_ci_multus_molecule_nads_out is failed) or |
119 | | - (_ci_multus_molecule_nads_out.resources | length == 0) |
120 | | -
|
121 | | - - name: Create a test pod to attach a network |
122 | | - kubernetes.core.k8s: |
123 | | - kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
124 | | - namespace: "{{ cifmw_ci_multus_namespace }}" |
125 | | - state: present |
126 | | - definition: |
127 | | - api_version: v1 |
128 | | - kind: Pod |
129 | | - metadata: |
130 | | - name: "{{ testpod_name }}" |
131 | | - annotations: |
132 | | - k8s.v1.cni.cncf.io/networks: default |
133 | | - spec: |
134 | | - containers: |
135 | | - - name: testnad |
136 | | - image: quay.rdoproject.org/openstack-k8s-operators/alpine:latest |
137 | | - imagePullPolicy: Always |
138 | | - command: |
139 | | - - "/bin/ash" |
140 | | - - "-c" |
141 | | - - "trap : TERM INT; sleep infinity & wait" |
142 | | - wait: true |
143 | | - wait_sleep: 10 |
144 | | - wait_timeout: 300 |
145 | | - wait_condition: |
146 | | - type: Ready |
147 | | - status: "True" |
148 | | - register: _ci_multus_molecule_test_pod_out |
149 | | - |
150 | | - - name: Assert that test pod has the additional network |
151 | | - ansible.builtin.assert: |
152 | | - that: |
153 | | - - _ci_multus_molecule_test_pod_out.result.metadata.annotations[ |
154 | | - 'k8s.v1.cni.cncf.io/networks'] == "default" |
155 | | - |
156 | | - - name: Delete test pod |
157 | | - kubernetes.core.k8s: |
158 | | - kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
159 | | - api_key: "{{ cifmw_openshift_token | default(omit)}}" |
160 | | - context: "{{ cifmw_openshift_context | default(omit)}}" |
161 | | - namespace: "{{ cifmw_ci_multus_namespace }}" |
162 | | - state: absent |
163 | | - api_version: v1 |
164 | | - kind: Pod |
165 | | - name: "{{ testpod_name }}" |
166 | | - |
167 | | - - name: Call cleanup |
168 | | - ansible.builtin.import_role: |
169 | | - name: ci_multus |
170 | | - tasks_from: cleanup.yml |
171 | | - |
172 | | - - name: Check if NADs were deleted |
173 | | - kubernetes.core.k8s_info: |
174 | | - kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
175 | | - namespace: "{{ cifmw_ci_multus_namespace }}" |
176 | | - api_version: k8s.cni.cncf.io/v1 |
177 | | - kind: NetworkAttachmentDefinition |
178 | | - register: _ci_multus_molecule_nads_cleanup_out |
179 | | - failed_when: >- |
180 | | - (_ci_multus_molecule_nads_cleanup_out is not defined) or |
181 | | - (_ci_multus_molecule_nads_cleanup_out is failed) or |
182 | | - (_ci_multus_molecule_nads_cleanup_out.resources | length > 0) |
183 | | -
|
184 | | - - name: Get all namespaces |
185 | | - kubernetes.core.k8s_info: |
186 | | - kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
187 | | - api_key: "{{ cifmw_openshift_token | default(omit)}}" |
188 | | - context: "{{ cifmw_openshift_context | default(omit)}}" |
189 | | - kind: Namespace |
190 | | - register: _ci_multus_molecule_ns_out |
191 | | - |
192 | | - - name: Assert that multus namespace is absent |
193 | | - vars: |
194 | | - ns_names: >- |
195 | | - {{ |
196 | | - _ci_multus_molecule_ns_out.resources | |
197 | | - default([]) | |
198 | | - map(attribute='metadata.name') |
199 | | - }} |
200 | | - ansible.builtin.assert: |
201 | | - that: "cifmw_ci_multus_namespace not in ns_names" |
0 commit comments