test_k8s_firewalld.yml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. # Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. # OMNIA_UKP_US_VFKP_TC_007
  16. # Execute k8s_firewalld role in manager and compute nodes with os installed centos 7.9
  17. - name: OMNIA_UKP_US_VFKP_TC_007
  18. hosts: manager, compute
  19. gather_facts: false
  20. vars_files:
  21. - test_vars/test_k8s_firewalld_vars.yml
  22. - ../roles/k8s_firewalld/vars/main.yml
  23. tasks:
  24. - block:
  25. - name: Call k8s_firewalld role
  26. include_role:
  27. name: ../roles/k8s_firewalld
  28. tags: TC_007
  29. - name: Start and enable firewalld
  30. service:
  31. name: firewalld
  32. state: started
  33. enabled: yes
  34. tags: TC_007, VERIFY_007
  35. - name: Checking firewalld open ports on manager node
  36. command: firewall-cmd --list-ports
  37. register: manager_firewalld_ports
  38. when: "'manager' in group_names"
  39. tags: TC_007, VERIFY_007
  40. - name: Checking firewalld open ports on compute node
  41. command: firewall-cmd --list-ports
  42. register: compute_firewalld_ports
  43. when: "'compute' in group_names"
  44. tags: TC_007, VERIFY_007
  45. - name: Validating K8s port on manager node
  46. assert:
  47. that:
  48. - "'6443' in manager_firewalld_ports.stdout"
  49. - "'2379-2380' in manager_firewalld_ports.stdout"
  50. - "'10250' in manager_firewalld_ports.stdout"
  51. - "'10251' in manager_firewalld_ports.stdout"
  52. - "'10252' in manager_firewalld_ports.stdout"
  53. fail_msg: "{{ manager_k8s_ports_status_fail_msg }}"
  54. success_msg: "{{ manager_k8s_ports_status_success_msg }}"
  55. when: "'manager' in group_names"
  56. tags: TC_007, VERIFY_007
  57. - name: Validating K8s port on compute node
  58. assert:
  59. that:
  60. - "'10250' in compute_firewalld_ports.stdout"
  61. - "'30000-32767' in compute_firewalld_ports.stdout"
  62. fail_msg: "{{ compute_k8s_ports_status_fail_msg }}"
  63. success_msg: "{{ compute_k8s_ports_status_success_msg }}"
  64. when: "'compute' in group_names"
  65. tags: TC_007, VERIFY_007
  66. - name: Validating Calico udp/tcp ports on manager nodes
  67. assert:
  68. that:
  69. - "'4789' in manager_firewalld_ports.stdout"
  70. - "'5473' in manager_firewalld_ports.stdout"
  71. - "'179' in manager_firewalld_ports.stdout"
  72. fail_msg: "{{ calico_ports_manager_fail_msg }}"
  73. success_msg: "{{ calico_ports_manager_success_msg }}"
  74. when: "k8s_cni == 'calico' and 'manager' in group_names"
  75. tags: TC_007, VERIFY_007
  76. - name: Validating Calico udp/tcp ports on compute nodes
  77. assert:
  78. that:
  79. - "'4789' in compute_firewalld_ports.stdout"
  80. - "'5473' in compute_firewalld_ports.stdout"
  81. - "'179' in compute_firewalld_ports.stdout"
  82. fail_msg: "{{ calico_ports_compute_fail_msg }}"
  83. success_msg: "{{ calico_ports_compute_success_msg }}"
  84. when: "k8s_cni == 'calico' and 'compute' in group_names"
  85. tags: TC_007, VERIFY_007
  86. - name: Validating Flannel ports on manager nodes
  87. assert:
  88. that:
  89. - "'8285' in manager_firewalld_ports.stdout"
  90. - "'8472' in manager_firewalld_ports.stdout"
  91. fail_msg: "{{ flannel_ports_manager_fail_msg }}"
  92. success_msg: "{{ flannel_ports_manager_success_msg }}"
  93. when: "k8s_cni == 'flannel' and 'manager' in group_names"
  94. tags: TC_007, VERIFY_007
  95. - name: Validating Flannel ports on compute nodes
  96. assert:
  97. that:
  98. - "'8285' in compute_firewalld_ports.stdout"
  99. - "'8472' in compute_firewalld_ports.stdout"
  100. fail_msg: "{{ flannel_ports_compute_fail_msg }}"
  101. success_msg: "{{ flannel_ports_compute_success_msg }}"
  102. when: "k8s_cni == 'flannel' and 'compute' in group_names"
  103. tags: TC_007, VERIFY_007
  104. - name: Stop and disable firewalld
  105. service:
  106. name: firewalld
  107. state: stopped
  108. enabled: no
  109. tags: TC_007, VERIFY_007
  110. # OMNIA_UKP_US_VFKP_TC_008
  111. # Execute k8s_firewalld role in manager and compute nodes with K8s ports already opened
  112. - name: OMNIA_UKP_US_VFKP_TC_008
  113. hosts: manager, compute
  114. gather_facts: false
  115. vars_files:
  116. - test_vars/test_k8s_firewalld_vars.yml
  117. - ../roles/k8s_firewalld/vars/main.yml
  118. tasks:
  119. - block:
  120. - name: Call k8s_firewalld role
  121. include_role:
  122. name: ../roles/k8s_firewalld
  123. tags: TC_008
  124. - name: Start and enable firewalld
  125. service:
  126. name: firewalld
  127. state: started
  128. enabled: yes
  129. tags: TC_008, VERIFY_008
  130. - name: Checking firewalld open ports on manager node
  131. command: firewall-cmd --list-ports
  132. register: manager_firewalld_ports
  133. when: "'manager' in group_names"
  134. tags: TC_008, VERIFY_008
  135. - name: Checking firewalld open ports on compute node
  136. command: firewall-cmd --list-ports
  137. register: compute_firewalld_ports
  138. when: "'compute' in group_names"
  139. tags: TC_008, VERIFY_008
  140. - name: Validating K8s port on manager node
  141. assert:
  142. that:
  143. - "'6443' in manager_firewalld_ports.stdout"
  144. - "'2379-2380' in manager_firewalld_ports.stdout"
  145. - "'10250' in manager_firewalld_ports.stdout"
  146. - "'10251' in manager_firewalld_ports.stdout"
  147. - "'10252' in manager_firewalld_ports.stdout"
  148. fail_msg: "{{ manager_k8s_ports_status_fail_msg }}"
  149. success_msg: "{{ manager_k8s_ports_status_success_msg }}"
  150. when: "'manager' in group_names"
  151. tags: TC_008, VERIFY_008
  152. - name: Validating K8s port on compute node
  153. assert:
  154. that:
  155. - "'10250' in compute_firewalld_ports.stdout"
  156. - "'30000-32767' in compute_firewalld_ports.stdout"
  157. fail_msg: "{{ compute_k8s_ports_status_fail_msg }}"
  158. success_msg: "{{ compute_k8s_ports_status_success_msg }}"
  159. when: "'compute' in group_names"
  160. tags: TC_008, VERIFY_008
  161. - name: Validating Calico udp/tcp ports on manager nodes
  162. assert:
  163. that:
  164. - "'4789' in manager_firewalld_ports.stdout"
  165. - "'5473' in manager_firewalld_ports.stdout"
  166. - "'179' in manager_firewalld_ports.stdout"
  167. fail_msg: "{{ calico_ports_manager_fail_msg }}"
  168. success_msg: "{{ calico_ports_manager_success_msg }}"
  169. when: "k8s_cni == 'calico' and 'manager' in group_names"
  170. tags: TC_008, VERIFY_008
  171. - name: Validating Calico udp/tcp ports on compute nodes
  172. assert:
  173. that:
  174. - "'4789' in compute_firewalld_ports.stdout"
  175. - "'5473' in compute_firewalld_ports.stdout"
  176. - "'179' in compute_firewalld_ports.stdout"
  177. fail_msg: "{{ calico_ports_compute_fail_msg }}"
  178. success_msg: "{{ calico_ports_compute_success_msg }}"
  179. when: "k8s_cni == 'calico' and 'compute' in group_names"
  180. tags: TC_008, VERIFY_008
  181. - name: Validating Flannel ports on manager nodes
  182. assert:
  183. that:
  184. - "'8285' in manager_firewalld_ports.stdout"
  185. - "'8472' in manager_firewalld_ports.stdout"
  186. fail_msg: "{{ flannel_ports_manager_fail_msg }}"
  187. success_msg: "{{ flannel_ports_manager_success_msg }}"
  188. when: "k8s_cni == 'flannel' and 'manager' in group_names"
  189. tags: TC_008, VERIFY_008
  190. - name: Validating Flannel ports on compute nodes
  191. assert:
  192. that:
  193. - "'8285' in compute_firewalld_ports.stdout"
  194. - "'8472' in compute_firewalld_ports.stdout"
  195. fail_msg: "{{ flannel_ports_compute_fail_msg }}"
  196. success_msg: "{{ flannel_ports_compute_success_msg }}"
  197. when: "k8s_cni == 'flannel' and 'compute' in group_names"
  198. tags: TC_008, VERIFY_008
  199. - name: Stop and disable firewalld
  200. service:
  201. name: firewalld
  202. state: stopped
  203. enabled: no
  204. tags: TC_008, VERIFY_008