test_provision_cc.yml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  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. # Testcase OMNIA_DIO_US_CC_TC_004
  16. # Execute provision role in management station and verify cobbler configuration
  17. - name: OMNIA_DIO_US_CC_TC_004
  18. hosts: localhost
  19. connection: local
  20. vars_files:
  21. - test_vars/test_provision_vars.yml
  22. - ../roles/provision/vars/main.yml
  23. - "{{ test_input_config_filename }}"
  24. tasks:
  25. - name: Check the iso file is present
  26. stat:
  27. path: "{{ iso_file_path }}"
  28. register: iso_status
  29. tags: TC_004
  30. - name: Fail if iso file is missing
  31. fail:
  32. msg: "{{ iso_fail }}"
  33. when: iso_status.stat.exists == false
  34. tags: TC_004
  35. - name: Delete the cobbler container if exits
  36. docker_container:
  37. name: "{{ docker_container_name }}"
  38. state: absent
  39. tags: TC_004
  40. - name: Delete docker image if exists
  41. docker_image:
  42. name: "{{ docker_image_name }}"
  43. tag: "{{ docker_image_tag }}"
  44. state: absent
  45. tags: TC_004
  46. - block:
  47. - name: Call common role
  48. include_role:
  49. name: ../roles/common
  50. vars:
  51. input_config_filename: "{{ test_input_config_filename }}"
  52. - name: Call provision role
  53. include_role:
  54. name: ../roles/provision
  55. tags: TC_004
  56. - name: Check the connection to cobbler UI and it returns a status 200
  57. uri:
  58. url: https://localhost/cobbler_web
  59. status_code: 200
  60. return_content: yes
  61. validate_certs: no
  62. tags: TC_004,VERIFY_004
  63. - name: Fetch cobbler version in cobbler container
  64. command: docker exec {{ docker_container_name }} cobbler version
  65. changed_when: false
  66. register: cobbler_version
  67. tags: TC_004,VERIFY_004
  68. - name: Verify cobbler version
  69. assert:
  70. that:
  71. - "'Cobbler' in cobbler_version.stdout"
  72. - "'Error' not in cobbler_version.stdout"
  73. fail_msg: "{{ cobbler_version_fail_msg }}"
  74. success_msg: "{{ cobbler_version_success_msg }}"
  75. tags: TC_004,VERIFY_004
  76. - name: Run cobbler check command in cobbler container
  77. command: docker exec {{ docker_container_name }} cobbler check
  78. changed_when: false
  79. register: cobbler_check
  80. tags: TC_004,VERIFY_004
  81. - name: Verify cobbler check command output
  82. assert:
  83. that:
  84. - "'The following are potential configuration items that you may want to fix' not in cobbler_check.stdout"
  85. - "'Error' not in cobbler_check.stdout"
  86. fail_msg: "{{ cobbler_check_fail_msg }}"
  87. success_msg: "{{ cobbler_check_success_msg }}"
  88. ignore_errors: yes
  89. tags: TC_004,VERIFY_004
  90. - name: Run cobbler sync command in cobbler container
  91. command: docker exec {{ docker_container_name }} cobbler sync
  92. changed_when: false
  93. register: cobbler_sync
  94. tags: TC_004,VERIFY_004
  95. - name: Verify cobbler sync command output
  96. assert:
  97. that:
  98. - "'TASK COMPLETE' in cobbler_sync.stdout"
  99. - "'Fail' not in cobbler_sync.stdout"
  100. - "'Error' not in cobbler_sync.stdout"
  101. fail_msg: "{{ cobbler_sync_fail_msg }}"
  102. success_msg: "{{ cobbler_sync_success_msg }}"
  103. tags: TC_004,VERIFY_004
  104. - name: Fetch cobbler distro list
  105. command: docker exec {{ docker_container_name }} cobbler distro list
  106. changed_when: false
  107. register: cobbler_distro_list
  108. tags: TC_004,VERIFY_004
  109. - name: Verify cobbler distro list
  110. assert:
  111. that:
  112. - "'CentOS' in cobbler_distro_list.stdout"
  113. fail_msg: "{{ cobbler_distro_list_fail_msg }}"
  114. success_msg: "{{ cobbler_distro_list_success_msg }}"
  115. tags: TC_004,VERIFY_004
  116. - name: Fetch cobbler profile list
  117. command: docker exec cobbler cobbler profile list
  118. changed_when: false
  119. register: cobbler_profile_list
  120. tags: TC_004,VERIFY_004
  121. - name: Verify cobbler profile list
  122. assert:
  123. that:
  124. - "'CentOS' in cobbler_profile_list.stdout"
  125. fail_msg: "{{ cobbler_profile_list_fail_msg }}"
  126. success_msg: "{{ cobbler_profile_list_success_msg }}"
  127. tags: TC_004,VERIFY_004
  128. - name: Check kickstart file
  129. shell: |
  130. docker exec {{ docker_container_name }} [ -f /var/lib/cobbler/kickstarts/{{ kickstart_filename }} ] && echo "File exist" || echo "File does not exist"
  131. changed_when: false
  132. register: kickstart_file_status
  133. tags: TC_004,VERIFY_004
  134. - name: Verify kickstart file present
  135. assert:
  136. that:
  137. - "'File exist' in kickstart_file_status.stdout"
  138. fail_msg: "{{ kickstart_file_fail_msg }}"
  139. success_msg: "{{ kickstart_file_success_msg }}"
  140. tags: TC_004,VERIFY_004
  141. - name: Check crontab list
  142. command: docker exec cobbler crontab -l
  143. changed_when: false
  144. register: crontab_list
  145. tags: TC_004,VERIFY_004
  146. - name: Verify crontab list
  147. assert:
  148. that:
  149. - "'* * * * * ansible-playbook /root/tftp.yml' in crontab_list.stdout"
  150. - "'5 * * * * ansible-playbook /root/inventory_creation.yml' in crontab_list.stdout"
  151. fail_msg: "{{ crontab_list_fail_msg }}"
  152. success_msg: "{{ crontab_list_success_msg }}"
  153. tags: TC_004,VERIFY_004
  154. - name: Check tftp,dhcpd,xinetd,cobblerd service is running
  155. command: docker exec cobbler systemctl is-active {{ item }}
  156. changed_when: false
  157. ignore_errors: yes
  158. register: cobbler_service_check
  159. with_items: "{{ cobbler_services }}"
  160. tags: TC_004,VERIFY_004
  161. - name: Verify tftp,dhcpd,xinetd,cobblerd service is running
  162. assert:
  163. that:
  164. - "'active' in cobbler_service_check.results[{{ item }}].stdout"
  165. - "'inactive' not in cobbler_service_check.results[{{ item }}].stdout"
  166. - "'unknown' not in cobbler_service_check.results[{{ item }}].stdout"
  167. fail_msg: "{{ cobbler_service_check_fail_msg }}"
  168. success_msg: "{{ cobbler_service_check_success_msg }}"
  169. with_sequence: start=0 end=3
  170. tags: TC_004,VERIFY_004
  171. # Testcase OMNIA_DIO_US_CDIP_TC_005
  172. # Execute provison role in management station where cobbler container is configured
  173. - name: OMNIA_DIO_US_CDIP_TC_005
  174. hosts: localhost
  175. connection: local
  176. vars_files:
  177. - test_vars/test_provision_vars.yml
  178. - ../roles/provision/vars/main.yml
  179. tasks:
  180. - block:
  181. - name: Call common role
  182. include_role:
  183. name: ../roles/common
  184. vars:
  185. input_config_filename: "{{ test_input_config_filename }}"
  186. - name: Call provision role
  187. include_role:
  188. name: ../roles/provision
  189. tags: TC_005
  190. - name: Check the connection to cobbler UI and it returns a status 200
  191. uri:
  192. url: https://localhost/cobbler_web
  193. status_code: 200
  194. return_content: yes
  195. validate_certs: no
  196. tags: TC_005,VERIFY_005
  197. - name: Fetch cobbler version in cobbler container
  198. command: docker exec {{ docker_container_name }} cobbler version
  199. changed_when: false
  200. register: cobbler_version
  201. tags: TC_005,VERIFY_005
  202. - name: Verify cobbler version
  203. assert:
  204. that:
  205. - "'Cobbler' in cobbler_version.stdout"
  206. - "'Error' not in cobbler_version.stdout"
  207. fail_msg: "{{ cobbler_version_fail_msg }}"
  208. success_msg: "{{ cobbler_version_success_msg }}"
  209. tags: TC_005,VERIFY_005
  210. - name: Run cobbler check command in cobbler container
  211. command: docker exec {{ docker_container_name }} cobbler check
  212. changed_when: false
  213. register: cobbler_check
  214. tags: TC_005,VERIFY_005
  215. - name: Verify cobbler check command output
  216. assert:
  217. that:
  218. - "'The following are potential configuration items that you may want to fix' not in cobbler_check.stdout"
  219. - "'Error' not in cobbler_check.stdout"
  220. fail_msg: "{{ cobbler_check_fail_msg }}"
  221. success_msg: "{{ cobbler_check_success_msg }}"
  222. ignore_errors: yes
  223. tags: TC_005,VERIFY_005
  224. - name: Run cobbler sync command in cobbler container
  225. command: docker exec {{ docker_container_name }} cobbler sync
  226. changed_when: false
  227. register: cobbler_sync
  228. tags: TC_005,VERIFY_005
  229. - name: Verify cobbler sync command output
  230. assert:
  231. that:
  232. - "'TASK COMPLETE' in cobbler_sync.stdout"
  233. - "'Fail' not in cobbler_sync.stdout"
  234. - "'Error' not in cobbler_sync.stdout"
  235. fail_msg: "{{ cobbler_sync_fail_msg }}"
  236. success_msg: "{{ cobbler_sync_success_msg }}"
  237. tags: TC_005,VERIFY_005
  238. - name: Fetch cobbler distro list
  239. command: docker exec {{ docker_container_name }} cobbler distro list
  240. changed_when: false
  241. register: cobbler_distro_list
  242. tags: TC_005,VERIFY_005
  243. - name: Verify cobbler distro list
  244. assert:
  245. that:
  246. - "'CentOS' in cobbler_distro_list.stdout"
  247. fail_msg: "{{ cobbler_distro_list_fail_msg }}"
  248. success_msg: "{{ cobbler_distro_list_success_msg }}"
  249. tags: TC_005,VERIFY_005
  250. - name: Fetch cobbler profile list
  251. command: docker exec cobbler cobbler profile list
  252. changed_when: false
  253. register: cobbler_profile_list
  254. tags: TC_005,VERIFY_005
  255. - name: Verify cobbler profile list
  256. assert:
  257. that:
  258. - "'CentOS' in cobbler_profile_list.stdout"
  259. fail_msg: "{{ cobbler_profile_list_fail_msg }}"
  260. success_msg: "{{ cobbler_profile_list_success_msg }}"
  261. tags: TC_005,VERIFY_005
  262. - name: Check kickstart file
  263. shell: |
  264. docker exec {{ docker_container_name }} [ -f /var/lib/cobbler/kickstarts/{{ kickstart_filename }} ] && echo "File exist" || echo "File does not exist"
  265. changed_when: false
  266. register: kickstart_file_status
  267. tags: TC_005,VERIFY_005
  268. - name: Verify kickstart file present
  269. assert:
  270. that:
  271. - "'File exist' in kickstart_file_status.stdout"
  272. fail_msg: "{{ kickstart_file_fail_msg }}"
  273. success_msg: "{{ kickstart_file_success_msg }}"
  274. tags: TC_005,VERIFY_005
  275. - name: Check crontab list
  276. command: docker exec cobbler crontab -l
  277. changed_when: false
  278. register: crontab_list
  279. tags: TC_005,VERIFY_005
  280. - name: Verify crontab list
  281. assert:
  282. that:
  283. - "'* * * * * ansible-playbook /root/tftp.yml' in crontab_list.stdout"
  284. - "'5 * * * * ansible-playbook /root/inventory_creation.yml' in crontab_list.stdout"
  285. fail_msg: "{{ crontab_list_fail_msg }}"
  286. success_msg: "{{ crontab_list_success_msg }}"
  287. tags: TC_005,VERIFY_005
  288. - name: Check tftp,dhcpd,xinetd,cobblerd service is running
  289. command: docker exec cobbler systemctl is-active {{ item }}
  290. changed_when: false
  291. ignore_errors: yes
  292. register: cobbler_service_check
  293. with_items: "{{ cobbler_services }}"
  294. tags: TC_005,VERIFY_005
  295. - name: Verify tftp,dhcpd,xinetd,cobblerd service is running
  296. assert:
  297. that:
  298. - "'active' in cobbler_service_check.results[{{ item }}].stdout"
  299. - "'inactive' not in cobbler_service_check.results[{{ item }}].stdout"
  300. - "'unknown' not in cobbler_service_check.results[{{ item }}].stdout"
  301. fail_msg: "{{ cobbler_service_check_fail_msg }}"
  302. success_msg: "{{ cobbler_service_check_success_msg }}"
  303. with_sequence: start=0 end=3
  304. tags: TC_005,VERIFY_005
  305. # Testcase OMNIA_DIO_US_CC_TC_006
  306. # Execute provision role in management station where already one container present
  307. - name: OMNIA_DIO_US_CC_TC_006
  308. hosts: localhost
  309. connection: local
  310. vars_files:
  311. - test_vars/test_provision_vars.yml
  312. - ../roles/provision/vars/main.yml
  313. tasks:
  314. - name: Delete the cobbler container if exits
  315. docker_container:
  316. name: "{{ docker_container_name }}"
  317. state: absent
  318. tags: TC_006
  319. - name: Delete docker image if exists
  320. docker_image:
  321. name: "{{ docker_image_name }}"
  322. tag: "{{ docker_image_tag }}"
  323. state: absent
  324. tags: TC_006
  325. - name: Create docker image
  326. docker_image:
  327. name: ubuntu
  328. tag: latest
  329. source: pull
  330. tags: TC_006
  331. - name: Create docker container
  332. command: docker run -dit ubuntu
  333. register: create_docker_container
  334. changed_when: true
  335. args:
  336. warn: false
  337. tags: TC_006
  338. - block:
  339. - name: Call common role
  340. include_role:
  341. name: ../roles/common
  342. vars:
  343. input_config_filename: "{{ test_input_config_filename }}"
  344. - name: Call provision role
  345. include_role:
  346. name: ../roles/provision
  347. tags: TC_006
  348. - name: Check the connection to cobbler UI and it returns a status 200
  349. uri:
  350. url: https://localhost/cobbler_web
  351. status_code: 200
  352. return_content: yes
  353. validate_certs: no
  354. tags: TC_006,VERIFY_006
  355. - name: Fetch cobbler version in cobbler container
  356. command: docker exec {{ docker_container_name }} cobbler version
  357. changed_when: false
  358. register: cobbler_version
  359. tags: TC_006,VERIFY_006
  360. - name: Verify cobbler version
  361. assert:
  362. that:
  363. - "'Cobbler' in cobbler_version.stdout"
  364. - "'Error' not in cobbler_version.stdout"
  365. fail_msg: "{{ cobbler_version_fail_msg }}"
  366. success_msg: "{{ cobbler_version_success_msg }}"
  367. tags: TC_006,VERIFY_006
  368. - name: Run cobbler check command in cobbler container
  369. command: docker exec {{ docker_container_name }} cobbler check
  370. changed_when: false
  371. register: cobbler_check
  372. tags: TC_006,VERIFY_006
  373. - name: Verify cobbler check command output
  374. assert:
  375. that:
  376. - "'The following are potential configuration items that you may want to fix' not in cobbler_check.stdout"
  377. - "'Error' not in cobbler_check.stdout"
  378. fail_msg: "{{ cobbler_check_fail_msg }}"
  379. success_msg: "{{ cobbler_check_success_msg }}"
  380. ignore_errors: yes
  381. tags: TC_006,VERIFY_006
  382. - name: Run cobbler sync command in cobbler container
  383. command: docker exec {{ docker_container_name }} cobbler sync
  384. changed_when: false
  385. register: cobbler_sync
  386. tags: TC_006,VERIFY_006
  387. - name: Verify cobbler sync command output
  388. assert:
  389. that:
  390. - "'TASK COMPLETE' in cobbler_sync.stdout"
  391. - "'Fail' not in cobbler_sync.stdout"
  392. - "'Error' not in cobbler_sync.stdout"
  393. fail_msg: "{{ cobbler_sync_fail_msg }}"
  394. success_msg: "{{ cobbler_sync_success_msg }}"
  395. tags: TC_006,VERIFY_006
  396. - name: Fetch cobbler distro list
  397. command: docker exec {{ docker_container_name }} cobbler distro list
  398. changed_when: false
  399. register: cobbler_distro_list
  400. tags: TC_006,VERIFY_006
  401. - name: Verify cobbler distro list
  402. assert:
  403. that:
  404. - "'CentOS' in cobbler_distro_list.stdout"
  405. fail_msg: "{{ cobbler_distro_list_fail_msg }}"
  406. success_msg: "{{ cobbler_distro_list_success_msg }}"
  407. tags: TC_006,VERIFY_006
  408. - name: Fetch cobbler profile list
  409. command: docker exec cobbler cobbler profile list
  410. changed_when: false
  411. register: cobbler_profile_list
  412. tags: TC_006,VERIFY_006
  413. - name: Verify cobbler profile list
  414. assert:
  415. that:
  416. - "'CentOS' in cobbler_profile_list.stdout"
  417. fail_msg: "{{ cobbler_profile_list_fail_msg }}"
  418. success_msg: "{{ cobbler_profile_list_success_msg }}"
  419. tags: TC_006,VERIFY_006
  420. - name: Check kickstart file
  421. shell: |
  422. docker exec {{ docker_container_name }} [ -f /var/lib/cobbler/kickstarts/{{ kickstart_filename }} ] && echo "File exist" || echo "File does not exist"
  423. changed_when: false
  424. register: kickstart_file_status
  425. tags: TC_006,VERIFY_006
  426. - name: Verify kickstart file present
  427. assert:
  428. that:
  429. - "'File exist' in kickstart_file_status.stdout"
  430. fail_msg: "{{ kickstart_file_fail_msg }}"
  431. success_msg: "{{ kickstart_file_success_msg }}"
  432. tags: TC_006,VERIFY_006
  433. - name: Check crontab list
  434. command: docker exec cobbler crontab -l
  435. changed_when: false
  436. register: crontab_list
  437. tags: TC_006,VERIFY_006
  438. - name: Verify crontab list
  439. assert:
  440. that:
  441. - "'* * * * * ansible-playbook /root/tftp.yml' in crontab_list.stdout"
  442. - "'5 * * * * ansible-playbook /root/inventory_creation.yml' in crontab_list.stdout"
  443. fail_msg: "{{ crontab_list_fail_msg }}"
  444. success_msg: "{{ crontab_list_success_msg }}"
  445. tags: TC_006,VERIFY_006
  446. - name: Check tftp,dhcpd,xinetd,cobblerd service is running
  447. command: docker exec cobbler systemctl is-active {{ item }}
  448. changed_when: false
  449. ignore_errors: yes
  450. register: cobbler_service_check
  451. with_items: "{{ cobbler_services }}"
  452. tags: TC_006,VERIFY_006
  453. - name: Verify tftp,dhcpd,xinetd,cobblerd service is running
  454. assert:
  455. that:
  456. - "'active' in cobbler_service_check.results[{{ item }}].stdout"
  457. - "'inactive' not in cobbler_service_check.results[{{ item }}].stdout"
  458. - "'unknown' not in cobbler_service_check.results[{{ item }}].stdout"
  459. fail_msg: "{{ cobbler_service_check_fail_msg }}"
  460. success_msg: "{{ cobbler_service_check_success_msg }}"
  461. with_sequence: start=0 end=3
  462. tags: TC_006,VERIFY_006
  463. - name: Delete the ubuntu container
  464. docker_container:
  465. name: "{{ create_docker_container.stdout }}"
  466. state: absent
  467. tags: TC_006
  468. - name: Delete the ubuntu umage
  469. docker_image:
  470. name: ubuntu
  471. state: absent
  472. tags: TC_006
  473. # Testcase OMNIA_DIO_US_CC_TC_007
  474. # Execute provision role in management station and reboot management station
  475. - name: OMNIA_DIO_US_CC_TC_007
  476. hosts: localhost
  477. connection: local
  478. vars_files:
  479. - test_vars/test_provision_vars.yml
  480. - ../roles/provision/vars/main.yml
  481. tasks:
  482. - name: Check last uptime of the server
  483. command: uptime -s
  484. register: uptime_status
  485. changed_when: false
  486. ignore_errors: yes
  487. tags: TC_007
  488. - name: Check current date
  489. command: date +"%Y-%m-%d %H"
  490. register: current_time
  491. changed_when: false
  492. ignore_errors: yes
  493. tags: TC_007
  494. - name: Delete the cobbler container if exits
  495. docker_container:
  496. name: "{{ docker_container_name }}"
  497. state: absent
  498. when: current_time.stdout not in uptime_status.stdout
  499. tags: TC_007
  500. - name: Delete docker image if exists
  501. docker_image:
  502. name: "{{ docker_image_name }}"
  503. tag: "{{ docker_image_tag }}"
  504. state: absent
  505. when: current_time.stdout not in uptime_status.stdout
  506. tags: TC_007
  507. - block:
  508. - name: Call common role
  509. include_role:
  510. name: ../roles/common
  511. vars:
  512. input_config_filename: "{{ test_input_config_filename }}"
  513. - name: Call provision role
  514. include_role:
  515. name: ../roles/provision
  516. when: current_time.stdout not in uptime_status.stdout
  517. tags: TC_007
  518. - name: Reboot localhost
  519. command: reboot
  520. when: current_time.stdout not in uptime_status.stdout
  521. tags: TC_007
  522. - name: Inspect cobbler container
  523. docker_container_info:
  524. name: "{{ docker_container_name }}"
  525. register: cobbler_cnt_status
  526. tags: TC_007,VERIFY_007
  527. - name: Verify cobbler container is running after reboot
  528. assert:
  529. that: "'running' in cobbler_cnt_status.container.State.Status"
  530. fail_msg: "{{ cobbler_reboot_fail_msg }}"
  531. success_msg: "{{ cobbler_reboot_success_msg }}"
  532. tags: TC_007,VERIFY_007