test_provision_ndod.yml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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_DIO_US_NDOD_TC_013
  16. # Execute provison role in management station and PXE boot one compute node
  17. - name: OMNIA_DIO_US_NDOD_TC_013
  18. hosts: localhost
  19. connection: local
  20. gather_subset:
  21. - 'min'
  22. vars_files:
  23. - test_vars/test_provision_vars.yml
  24. tasks:
  25. - name: Set ip address of the compute node
  26. set_fact:
  27. single_node_ip_address: "{{ groups[cobbler_groupname][0] }}"
  28. tags: TC_013
  29. - name: Delete inventory if exists
  30. file:
  31. path: inventory
  32. state: absent
  33. tags: TC_013
  34. - name: Create inventory file
  35. lineinfile:
  36. path: inventory
  37. line: "{{ single_node_ip_address }} ansible_user=root ansible_password={{ boundary_password }} ansible_ssh_common_args='-o StrictHostKeyChecking=no'"
  38. create: yes
  39. mode: '{{ file_permission }}'
  40. tags: TC_013
  41. - meta: refresh_inventory
  42. tags: TC_013
  43. - name: Validate authentication of username and password
  44. command: ansible {{ single_node_ip_address }} -m ping -i inventory
  45. register: validate_login
  46. changed_when: false
  47. ignore_errors: yes
  48. tags: TC_013
  49. - name: Validate the authentication output
  50. assert:
  51. that:
  52. - "'pong' in validate_login.stdout"
  53. - "'SUCCESS' in validate_login.stdout"
  54. - "'UNREACHABLE' not in validate_login.stdout"
  55. fail_msg: "{{ authentication_fail_msg }}"
  56. success_msg: "{{ authentication_success_msg }}"
  57. tags: TC_013
  58. - name: Check hostname
  59. command: ansible {{ single_node_ip_address }} -m shell -a hostname -i inventory
  60. register: validate_hostname
  61. changed_when: false
  62. ignore_errors: yes
  63. tags: TC_013
  64. - name: Validate the hostname
  65. assert:
  66. that: "'localhost' not in validate_hostname.stdout"
  67. fail_msg: "{{ hostname_fail_msg }}"
  68. success_msg: "{{ hostname_success_msg }}"
  69. tags: TC_013
  70. - name: Delete inventory if exists
  71. file:
  72. path: inventory
  73. state: absent
  74. tags: TC_013
  75. # OMNIA_DIO_US_NDOD_TC_014
  76. # Execute provison role in management station and PXE boot two compute node
  77. - name: OMNIA_DIO_US_NDOD_TC_014
  78. hosts: localhost
  79. connection: local
  80. gather_subset:
  81. - 'min'
  82. vars_files:
  83. - test_vars/test_provision_vars.yml
  84. - ../roles/provision/vars/main.yml
  85. tasks:
  86. - name: Delete inventory if exists
  87. file:
  88. path: inventory
  89. state: absent
  90. tags: TC_014
  91. - name: Create inventory file
  92. lineinfile:
  93. path: inventory
  94. line: "[nodes]"
  95. create: yes
  96. mode: '{{ file_permission }}'
  97. tags: TC_014
  98. - name: Edit inventory file
  99. lineinfile:
  100. path: inventory
  101. line: "{{ item }} ansible_user=root ansible_password={{ boundary_password }} ansible_ssh_common_args='-o StrictHostKeyChecking=no'"
  102. with_items:
  103. - "{{ groups[cobbler_groupname] }}"
  104. tags: TC_014
  105. - meta: refresh_inventory
  106. tags: TC_014
  107. - name: Validate ip address is different for both servers
  108. assert:
  109. that: groups[cobbler_groupname][0] != groups[cobbler_groupname][1]
  110. fail_msg: "{{ ip_address_fail_msg }}"
  111. success_msg: "{{ ip_address_success_msg }}"
  112. delegate_to: localhost
  113. run_once: yes
  114. tags: TC_014
  115. - name: Check hostname of both servers
  116. command: ansible nodes -m shell -a hostname -i inventory
  117. register: node_hostname
  118. changed_when: false
  119. ignore_errors: yes
  120. tags: TC_014
  121. - name: Validate hostname is different for both servers
  122. assert:
  123. that:
  124. - node_hostname.stdout_lines[1] != node_hostname.stdout_lines[3]
  125. - "'localhost' not in node_hostname.stdout_lines[1]"
  126. - "'localhost' not in node_hostname.stdout_lines[3]"
  127. fail_msg: "{{ hostname_fail_msg }}"
  128. success_msg: "{{ hostname_success_msg }}"
  129. delegate_to: localhost
  130. run_once: yes
  131. tags: TC_014
  132. - name: Delete inventory if exists
  133. file:
  134. path: inventory
  135. state: absent
  136. delegate_to: localhost
  137. run_once: yes
  138. tags: TC_014
  139. # OMNIA_DIO_US_NDOD_TC_015
  140. # Validate passwordless ssh connection established or not with compute nodes
  141. - name: OMNIA_DIO_US_NDOD_TC_015
  142. hosts: localhost
  143. gather_subset:
  144. - 'min'
  145. vars_files:
  146. - test_vars/test_provision_vars.yml
  147. - ../roles/provision/vars/main.yml
  148. tasks:
  149. - name: Validate authentication of username and password
  150. command: "ansible {{ cobbler_groupname }} -m ping -i cobbler_inventory"
  151. register: validate_login
  152. changed_when: false
  153. ignore_errors: yes
  154. tags: TC_015
  155. - name: Validate the passwordless SSH connection
  156. assert:
  157. that:
  158. - "'pong' in validate_login.stdout"
  159. - "'SUCCESS' in validate_login.stdout"
  160. - "'UNREACHABLE' not in validate_login.stdout"
  161. success_msg: "{{ authentication_success_msg }}"
  162. fail_msg: "{{ authentication_fail_msg }}"
  163. tags: TC_015
  164. # OMNIA_DIO_US_NDOD_TC_016
  165. # Execute provison role in management station and reboot compute node after os provision again
  166. - name: OMNIA_DIO_US_NDOD_TC_016
  167. hosts: localhost
  168. connection: local
  169. gather_subset:
  170. - 'min'
  171. vars_files:
  172. - test_vars/test_provision_vars.yml
  173. tasks:
  174. - name: Set ip address of the compute node
  175. set_fact:
  176. single_node_ip_address: "{{ groups[cobbler_groupname][0] }}"
  177. tags: TC_016
  178. - name: Delete inventory if exists
  179. file:
  180. path: inventory
  181. state: absent
  182. tags: TC_016
  183. - name: Create inventory file
  184. lineinfile:
  185. path: inventory
  186. line: "[nodes]"
  187. create: yes
  188. mode: '{{ file_permission }}'
  189. tags: TC_016
  190. - name: Edit inventory file
  191. lineinfile:
  192. path: inventory
  193. line: "{{ single_node_ip_address }} ansible_user=root ansible_password={{ boundary_password }} ansible_ssh_common_args='-o StrictHostKeyChecking=no'"
  194. tags: TC_016
  195. - meta: refresh_inventory
  196. tags: TC_016
  197. - name: Reboot servers
  198. command: ansible nodes -m command -a reboot -i inventory
  199. ignore_errors: yes
  200. changed_when: true
  201. tags: TC_016
  202. - name: Wait for 10 minutes
  203. pause:
  204. minutes: 10
  205. tags: TC_016
  206. - name: Check ip address of servers
  207. command: ansible nodes -m command -a 'ip a' -i inventory
  208. ignore_errors: yes
  209. changed_when: false
  210. register: ip_address_after_reboot
  211. tags: TC_016
  212. - name: Validate ip address is same after reboot
  213. assert:
  214. that: "'{{ single_node_ip_address }}' in ip_address_after_reboot.stdout"
  215. fail_msg: "{{ ip_address_fail_msg }}"
  216. success_msg: "{{ ip_address_success_msg }}"
  217. tags: TC_016