test_provision_ndod.yml 9.3 KB

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