test_omnia.yml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891
  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_CRM_US_AWXD_TC_006
  16. # Test case to validate whether the proper error message is displayed when slurm and kubernetes tags are skipped
  17. - name: OMNIA_CRM_US_AWXD_TC_006
  18. hosts: localhost
  19. connection: local
  20. vars_files:
  21. - ../roles/web_ui/vars/main.yml
  22. - ../roles/common/vars/main.yml
  23. - test_vars/test_omnia_vars.yml
  24. tasks:
  25. - name: Check input config file is encrypted
  26. command: cat {{ test_input_config_filename }}
  27. changed_when: false
  28. register: config_content
  29. tags: TC_006
  30. - name: Decrpyt input_config.yml
  31. command: ansible-vault decrypt {{ test_input_config_filename }} --vault-password-file {{ vault_filename }}
  32. changed_when: false
  33. when: "'$ANSIBLE_VAULT;' in config_content.stdout"
  34. tags: TC_006
  35. - name: Include variable file input_config.yml
  36. include_vars: "{{ test_input_config_filename }}"
  37. tags: TC_006
  38. - name: Creating inventory file with hosts associated to the groups
  39. copy:
  40. dest: "testinventory.yml"
  41. mode: '{{ file_permission }}'
  42. content: |
  43. ---
  44. manager:
  45. hosts:
  46. {{ host1 }}
  47. compute:
  48. hosts:
  49. {{ host2 }}
  50. tags: TC_006
  51. - name: Push the inventory to AWX
  52. shell: |
  53. set -o pipefail
  54. docker exec awx_task awx-manage inventory_import --inventory-name {{ omnia_inventory_name }} --source "{{ inventory_path }}/testinventory.yml"
  55. changed_when: false
  56. tags: TC_006
  57. - block:
  58. - name: Launch the job template
  59. command: >-
  60. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  61. job_templates launch "{{ omnia_template_name }}" --credentials "{{ credential_name }}" --skip_tags slurm,kubernetes --monitor -f human
  62. changed_when: false
  63. register: command_output
  64. rescue:
  65. - name: Validate error message
  66. assert:
  67. that: "'FAILED!' in command_output.stdout"
  68. success_msg: "{{ test_case_success_msg }}"
  69. fail_msg: "{{ test_case_failure_msg }}"
  70. tags: TC_006
  71. - name: Delete the hosts
  72. command: >-
  73. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  74. hosts delete {{ host1 }} --monitor -f human
  75. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  76. hosts delete {{ host2 }} --monitor -f human
  77. changed_when: false
  78. tags: TC_006
  79. - name: Delete the inventory file
  80. ignore_errors: yes
  81. file:
  82. state: absent
  83. path: testinventory.yml
  84. tags: TC_006
  85. - name: Create inventory file if it doesn't exist
  86. ignore_errors: yes
  87. file:
  88. path: "testinventory.yml"
  89. state: touch
  90. mode: '{{ file_permission }}'
  91. tags: TC_006
  92. # Testcase OMNIA_CRM_US_AWXD_TC_007
  93. # Test case to validate whether the skip tags validation is passed when slurm tag is given
  94. - name: OMNIA_CRM_US_AWXD_TC_007
  95. hosts: localhost
  96. connection: local
  97. vars_files:
  98. - ../roles/web_ui/vars/main.yml
  99. - ../roles/common/vars/main.yml
  100. - test_vars/test_omnia_vars.yml
  101. tasks:
  102. - name: Check input config file is encrypted
  103. command: cat {{ test_input_config_filename }}
  104. changed_when: false
  105. register: config_content
  106. tags: TC_007
  107. - name: Decrpyt input_config.yml
  108. command: ansible-vault decrypt {{ test_input_config_filename }} --vault-password-file {{ vault_filename }}
  109. changed_when: false
  110. when: "'$ANSIBLE_VAULT;' in config_content.stdout"
  111. tags: TC_007
  112. - name: Include variable file input_config.yml
  113. include_vars: "{{ test_input_config_filename }}"
  114. tags: TC_007
  115. - name: Creating inventory file with hosts associated to the groups
  116. copy:
  117. dest: "testinventory.yml"
  118. mode: '{{ file_permission }}'
  119. content: |
  120. ---
  121. manager:
  122. hosts:
  123. {{ host1 }}
  124. compute:
  125. hosts:
  126. {{ host2 }}
  127. tags: TC_007
  128. - name: Push the inventory to AWX
  129. shell: |
  130. set -o pipefail
  131. docker exec awx_task awx-manage inventory_import --inventory-name {{ omnia_inventory_name }} --source "{{ inventory_path }}/testinventory.yml"
  132. changed_when: false
  133. tags: TC_007
  134. - block:
  135. - name: Launch the job template
  136. command: >-
  137. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  138. job_templates launch "{{ omnia_template_name }}" --credentials "{{ credential_name }}" --skip_tags slurm --monitor -f human
  139. changed_when: false
  140. register: command_output
  141. - name: Validate success message
  142. assert:
  143. that: "'FAILED!' not in command_output.stdout"
  144. success_msg: "{{ test_case_success_msg }}"
  145. fail_msg: "{{ test_case_failure_msg }}"
  146. tags: TC_007
  147. - name: Delete the hosts
  148. command: >-
  149. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  150. hosts delete {{ host1 }} --monitor -f human
  151. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  152. hosts delete {{ host2 }} --monitor -f human
  153. changed_when: false
  154. tags: TC_007
  155. - name: Delete the inventory file
  156. ignore_errors: yes
  157. file:
  158. state: absent
  159. path: testinventory.yml
  160. tags: TC_007
  161. - name: Create inventory file if it doesn't exist
  162. ignore_errors: yes
  163. file:
  164. path: "testinventory.yml"
  165. state: touch
  166. mode: '{{ file_permission }}'
  167. tags: TC_007
  168. # Testcase OMNIA_CRM_US_AWXD_TC_008
  169. # Test case to validate whether the skip tags validation is passed when kubernetes tag is given
  170. - name: OMNIA_CRM_US_AWXD_TC_008
  171. hosts: localhost
  172. connection: local
  173. vars_files:
  174. - ../roles/web_ui/vars/main.yml
  175. - ../roles/common/vars/main.yml
  176. - test_vars/test_omnia_vars.yml
  177. tasks:
  178. - name: Check input config file is encrypted
  179. command: cat {{ test_input_config_filename }}
  180. changed_when: false
  181. register: config_content
  182. tags: TC_008
  183. - name: Decrpyt input_config.yml
  184. command: ansible-vault decrypt {{ test_input_config_filename }} --vault-password-file {{ vault_filename }}
  185. changed_when: false
  186. when: "'$ANSIBLE_VAULT;' in config_content.stdout"
  187. tags: TC_008
  188. - name: Include variable file input_config.yml
  189. include_vars: "{{ test_input_config_filename }}"
  190. tags: TC_008
  191. - name: Creating inventory file with hosts associated to the groups
  192. copy:
  193. dest: "testinventory.yml"
  194. mode: '{{ file_permission }}'
  195. content: |
  196. ---
  197. manager:
  198. hosts:
  199. {{ host1 }}
  200. compute:
  201. hosts:
  202. {{ host2 }}
  203. tags: TC_008
  204. - name: Push the inventory to AWX
  205. shell: |
  206. set -o pipefail
  207. docker exec awx_task awx-manage inventory_import --inventory-name {{ omnia_inventory_name }} --source "{{ inventory_path }}/testinventory.yml"
  208. changed_when: false
  209. tags: TC_008
  210. - block:
  211. - name: Launch the job template
  212. command: >-
  213. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  214. job_templates launch "{{ omnia_template_name }}" --credentials "{{ credential_name }}" --skip_tags kubernetes --monitor -f human
  215. changed_when: false
  216. register: command_output
  217. - name: Validate success message
  218. assert:
  219. that: "'FAILED!' not in command_output.stdout"
  220. success_msg: "{{ test_case_success_msg }}"
  221. fail_msg: "{{ test_case_failure_msg }}"
  222. tags: TC_008
  223. - name: Delete the hosts
  224. command: >-
  225. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  226. hosts delete {{ host1 }} --monitor -f human
  227. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  228. hosts delete {{ host2 }} --monitor -f human
  229. changed_when: false
  230. tags: TC_008
  231. - name: Delete the inventory file
  232. ignore_errors: yes
  233. file:
  234. state: absent
  235. path: testinventory.yml
  236. tags: TC_008
  237. - name: Create inventory file if it doesn't exist
  238. ignore_errors: yes
  239. file:
  240. path: "testinventory.yml"
  241. state: touch
  242. mode: '{{ file_permission }}'
  243. tags: TC_008
  244. # Testcase OMNIA_CRM_US_AWXD_TC_009
  245. # Test case to validate whether the proper error message is displayed when no host is added to manager group
  246. - name: OMNIA_CRM_US_AWXD_TC_009
  247. hosts: localhost
  248. connection: local
  249. vars_files:
  250. - ../roles/web_ui/vars/main.yml
  251. - ../roles/common/vars/main.yml
  252. - test_vars/test_omnia_vars.yml
  253. tasks:
  254. - name: Check input config file is encrypted
  255. command: cat {{ test_input_config_filename }}
  256. changed_when: false
  257. register: config_content
  258. tags: TC_009
  259. - name: Decrpyt input_config.yml
  260. command: ansible-vault decrypt {{ test_input_config_filename }} --vault-password-file {{ vault_filename }}
  261. changed_when: false
  262. when: "'$ANSIBLE_VAULT;' in config_content.stdout"
  263. tags: TC_009
  264. - name: Include variable file input_config.yml
  265. include_vars: "{{ test_input_config_filename }}"
  266. tags: TC_009
  267. - name: Creating inventory file with hosts associated to the groups
  268. copy:
  269. dest: "testinventory.yml"
  270. mode: '{{ file_permission }}'
  271. content: |
  272. ---
  273. manager:
  274. hosts:
  275. compute:
  276. hosts:
  277. {{ host2 }}
  278. tags: TC_009
  279. - name: Push the inventory to AWX
  280. shell: |
  281. set -o pipefail
  282. docker exec awx_task awx-manage inventory_import --inventory-name {{ omnia_inventory_name }} --source "{{ inventory_path }}/testinventory.yml"
  283. changed_when: false
  284. tags: TC_009
  285. - block:
  286. - name: Launch the job template
  287. command: >-
  288. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  289. job_templates launch "{{ omnia_template_name }}" --credentials "{{ credential_name }}" --monitor -f human
  290. changed_when: false
  291. register: command_output
  292. rescue:
  293. - name: Validate error message
  294. assert:
  295. that: "'FAILED!' in command_output.stdout"
  296. success_msg: "{{ test_case_success_msg }}"
  297. fail_msg: "{{ test_case_failure_msg }}"
  298. tags: TC_009
  299. - name: Delete the hosts
  300. command: >-
  301. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  302. hosts delete {{ host2 }} --monitor -f human
  303. changed_when: false
  304. tags: TC_009
  305. - name: Delete the inventory file
  306. ignore_errors: yes
  307. file:
  308. state: absent
  309. path: testinventory.yml
  310. tags: TC_009
  311. - name: Create inventory file if it doesn't exist
  312. ignore_errors: yes
  313. file:
  314. path: "testinventory.yml"
  315. state: touch
  316. mode: '{{ file_permission }}'
  317. tags: TC_009
  318. # Testcase OMNIA_CRM_US_AWXD_TC_010
  319. # Test case to verify whether the manger group validation is passed when single host is present
  320. - name: OMNIA_CRM_US_AWXD_TC_010
  321. hosts: localhost
  322. connection: local
  323. vars_files:
  324. - ../roles/web_ui/vars/main.yml
  325. - ../roles/common/vars/main.yml
  326. - test_vars/test_omnia_vars.yml
  327. tasks:
  328. - name: Check input config file is encrypted
  329. command: cat {{ test_input_config_filename }}
  330. changed_when: false
  331. register: config_content
  332. tags: TC_010
  333. - name: Decrpyt input_config.yml
  334. command: ansible-vault decrypt {{ test_input_config_filename }} --vault-password-file {{ vault_filename }}
  335. changed_when: false
  336. when: "'$ANSIBLE_VAULT;' in config_content.stdout"
  337. tags: TC_010
  338. - name: Include variable file input_config.yml
  339. include_vars: "{{ test_input_config_filename }}"
  340. tags: TC_010
  341. - name: Creating inventory file with hosts associated to the groups
  342. copy:
  343. dest: "testinventory.yml"
  344. mode: '{{ file_permission }}'
  345. content: |
  346. ---
  347. manager:
  348. hosts:
  349. {{ host1 }}
  350. compute:
  351. hosts:
  352. {{ host2 }}
  353. tags: TC_010
  354. - name: Push the inventory to AWX
  355. shell: |
  356. set -o pipefail
  357. docker exec awx_task awx-manage inventory_import --inventory-name {{ omnia_inventory_name }} --source "{{ inventory_path }}/testinventory.yml"
  358. changed_when: false
  359. tags: TC_010
  360. - block:
  361. - name: Launch the job template
  362. command: >-
  363. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  364. job_templates launch "{{ omnia_template_name }}" --credentials "{{ credential_name }}" --monitor -f human
  365. changed_when: false
  366. register: command_output
  367. tags: TC_010
  368. - name: Validate success message
  369. assert:
  370. that: "'FAILED!' not in command_output.stdout"
  371. success_msg: "{{ test_case_success_msg }}"
  372. fail_msg: "{{ test_case_failure_msg }}"
  373. tags: TC_010
  374. - name: Delete the hosts
  375. command: >-
  376. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  377. hosts delete {{ host1 }} --monitor -f human
  378. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  379. hosts delete {{ host2 }} --monitor -f human
  380. changed_when: false
  381. tags: TC_010
  382. - name: Delete the inventory file
  383. ignore_errors: yes
  384. file:
  385. state: absent
  386. path: testinventory.yml
  387. tags: TC_010
  388. - name: Create inventory file if it doesn't exist
  389. ignore_errors: yes
  390. file:
  391. path: "testinventory.yml"
  392. state: touch
  393. mode: '{{ file_permission }}'
  394. tags: TC_010
  395. # Testcase OMNIA_CRM_US_AWXD_TC_011
  396. # Test case to validate whether the proper error message is displayed when no host is added to compute group
  397. - name: OMNIA_CRM_US_AWXD_TC_011
  398. hosts: localhost
  399. connection: local
  400. vars_files:
  401. - ../roles/web_ui/vars/main.yml
  402. - ../roles/common/vars/main.yml
  403. - test_vars/test_omnia_vars.yml
  404. tasks:
  405. - name: Check input config file is encrypted
  406. command: cat {{ test_input_config_filename }}
  407. changed_when: false
  408. register: config_content
  409. tags: TC_011
  410. - name: Decrpyt input_config.yml
  411. command: ansible-vault decrypt {{ test_input_config_filename }} --vault-password-file {{ vault_filename }}
  412. changed_when: false
  413. when: "'$ANSIBLE_VAULT;' in config_content.stdout"
  414. tags: TC_011
  415. - name: Include variable file input_config.yml
  416. include_vars: "{{ test_input_config_filename }}"
  417. tags: TC_011
  418. - name: Creating inventory file with hosts associated to the groups
  419. copy:
  420. dest: "testinventory.yml"
  421. mode: '{{ file_permission }}'
  422. content: |
  423. ---
  424. manager:
  425. hosts:
  426. {{ host3 }}
  427. compute:
  428. hosts:
  429. tags: TC_011
  430. - name: Push the inventory to AWX
  431. shell: |
  432. set -o pipefail
  433. docker exec awx_task awx-manage inventory_import --inventory-name {{ omnia_inventory_name }} --source "{{ inventory_path }}/testinventory.yml"
  434. changed_when: false
  435. tags: TC_011
  436. - block:
  437. - name: Launch the job template
  438. command: >-
  439. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  440. job_templates launch "{{ omnia_template_name }}" --credentials "{{ credential_name }}" --monitor -f human
  441. changed_when: false
  442. register: command_output
  443. rescue:
  444. - name: Validate error message
  445. assert:
  446. that: "'FAILED!' in command_output.stdout"
  447. success_msg: "{{ test_case_success_msg }}"
  448. fail_msg: "{{ test_case_failure_msg }}"
  449. tags: TC_011
  450. - name: Delete the hosts
  451. command: >-
  452. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  453. hosts delete {{ host3 }} --monitor -f human
  454. changed_when: false
  455. tags: TC_011
  456. - name: Delete the inventory file
  457. file:
  458. state: absent
  459. path: testinventory.yml
  460. ignore_errors: yes
  461. tags: TC_011
  462. - name: Create inventory file if it doesn't exist
  463. file:
  464. path: "testinventory.yml"
  465. mode: '{{ file_permission }}'
  466. state: touch
  467. ignore_errors: yes
  468. tags: TC_011
  469. # Testcase OMNIA_CRM_US_AWXD_TC_012
  470. # Test case to verify whether the compute group validation is passed when more than 1 host is present
  471. - name: OMNIA_CRM_US_AWXD_TC_012
  472. hosts: localhost
  473. connection: local
  474. vars_files:
  475. - ../roles/web_ui/vars/main.yml
  476. - ../roles/common/vars/main.yml
  477. - test_vars/test_omnia_vars.yml
  478. tasks:
  479. - name: Check input config file is encrypted
  480. command: cat {{ test_input_config_filename }}
  481. changed_when: false
  482. register: config_content
  483. tags: TC_012
  484. - name: Decrpyt input_config.yml
  485. command: ansible-vault decrypt {{ test_input_config_filename }} --vault-password-file {{ vault_filename }}
  486. changed_when: false
  487. when: "'$ANSIBLE_VAULT;' in config_content.stdout"
  488. tags: TC_012
  489. - name: Include variable file input_config.yml
  490. include_vars: "{{ test_input_config_filename }}"
  491. tags: TC_012
  492. - name: Creating inventory file with hosts associated to the groups
  493. copy:
  494. dest: "testinventory.yml"
  495. mode: '{{ file_permission }}'
  496. content: |
  497. ---
  498. manager:
  499. hosts:
  500. {{ host1 }}
  501. compute:
  502. hosts:
  503. {{ host2 }}
  504. hosts:
  505. {{ host3 }}
  506. tags: TC_012
  507. - name: Push the inventory to AWX
  508. shell: |
  509. set -o pipefail
  510. docker exec awx_task awx-manage inventory_import --inventory-name {{ omnia_inventory_name }} --source "{{ inventory_path }}/testinventory.yml"
  511. changed_when: false
  512. tags: TC_012
  513. - block:
  514. - name: Launch the job template
  515. command: >-
  516. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  517. job_templates launch "{{ omnia_template_name }}" --credentials "{{ credential_name }}" --monitor -f human
  518. changed_when: false
  519. register: command_output
  520. - name: Validate success message
  521. assert:
  522. that: "'FAILED!' not in command_output.stdout"
  523. success_msg: "{{ test_case_success_msg }}"
  524. fail_msg: "{{ test_case_failure_msg }}"
  525. tags: TC_012
  526. - name: Delete the hosts
  527. command: >-
  528. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  529. hosts delete {{ host1 }} --monitor -f human
  530. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  531. hosts delete {{ host2 }} --monitor -f human
  532. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  533. hosts delete {{ host3 }} --monitor -f human
  534. changed_when: false
  535. tags: TC_012
  536. - name: Delete the inventory file
  537. ignore_errors: yes
  538. file:
  539. state: absent
  540. path: testinventory.yml
  541. tags: TC_012
  542. - name: Create inventory file if it doesn't exist
  543. ignore_errors: yes
  544. file:
  545. path: "testinventory.yml"
  546. state: touch
  547. mode: '{{ file_permission }}'
  548. tags: TC_012
  549. # Testcase OMNIA_CRM_US_AWXD_TC_013
  550. # Test case to validate the error meesage when a host is present in both manager and compute groups
  551. - name: OMNIA_CRM_US_AWXD_TC_013
  552. hosts: localhost
  553. connection: local
  554. vars_files:
  555. - ../roles/web_ui/vars/main.yml
  556. - ../roles/common/vars/main.yml
  557. - test_vars/test_omnia_vars.yml
  558. tasks:
  559. - name: Check input config file is encrypted
  560. command: cat {{ test_input_config_filename }}
  561. changed_when: false
  562. register: config_content
  563. tags: TC_013
  564. - name: Decrpyt input_config.yml
  565. command: ansible-vault decrypt {{ test_input_config_filename }} --vault-password-file {{ vault_filename }}
  566. changed_when: false
  567. when: "'$ANSIBLE_VAULT;' in config_content.stdout"
  568. tags: TC_013
  569. - name: Include variable file input_config.yml
  570. include_vars: "{{ test_input_config_filename }}"
  571. tags: TC_013
  572. - name: Creating inventory file with hosts associated to the groups
  573. copy:
  574. dest: "testinventory.yml"
  575. mode: '{{ file_permission }}'
  576. content: |
  577. ---
  578. manager:
  579. hosts:
  580. {{ host1 }}
  581. compute:
  582. hosts:
  583. {{ host1 }}
  584. tags: TC_013
  585. - name: Push the inventory to AWX
  586. shell: |
  587. set -o pipefail
  588. docker exec awx_task awx-manage inventory_import --inventory-name {{ omnia_inventory_name }} --source "{{ inventory_path }}/testinventory.yml"
  589. changed_when: false
  590. tags: TC_013
  591. - block:
  592. - name: Launch the job template
  593. command: >-
  594. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  595. job_templates launch "{{ omnia_template_name }}" --credentials "{{ credential_name }}" --monitor -f human
  596. changed_when: false
  597. register: command_output
  598. rescue:
  599. - name: Validate error message
  600. assert:
  601. that: "'FAILED!' in command_output.stdout"
  602. success_msg: "{{ test_case_success_msg }}"
  603. fail_msg: "{{ test_case_failure_msg }}"
  604. tags: TC_013
  605. - name: Delete the hosts
  606. command: >-
  607. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  608. hosts delete {{ host1 }} --monitor -f human
  609. changed_when: false
  610. tags: TC_013
  611. - name: Delete the inventory file
  612. ignore_errors: yes
  613. file:
  614. state: absent
  615. path: testinventory.yml
  616. tags: TC_013
  617. - name: Create inventory file if it doesn't exist
  618. ignore_errors: yes
  619. file:
  620. path: "testinventory.yml"
  621. state: touch
  622. mode: '{{ file_permission }}'
  623. tags: TC_013
  624. # Testcase OMNIA_CRM_US_AWXD_TC_014
  625. # Test case to verify the disjunction validation when the hosts are disjoint
  626. - name: OMNIA_CRM_US_AWXD_TC_014
  627. hosts: localhost
  628. connection: local
  629. vars_files:
  630. - ../roles/web_ui/vars/main.yml
  631. - ../roles/common/vars/main.yml
  632. - test_vars/test_omnia_vars.yml
  633. tasks:
  634. - name: Check input config file is encrypted
  635. command: cat {{ test_input_config_filename }}
  636. changed_when: false
  637. register: config_content
  638. tags: TC_014
  639. - name: Decrpyt input_config.yml
  640. command: ansible-vault decrypt {{ test_input_config_filename }} --vault-password-file {{ vault_filename }}
  641. changed_when: false
  642. when: "'$ANSIBLE_VAULT;' in config_content.stdout"
  643. tags: TC_014
  644. - name: Include variable file input_config.yml
  645. include_vars: "{{ test_input_config_filename }}"
  646. tags: TC_014
  647. - name: Creating inventory file with hosts associated to the groups
  648. copy:
  649. dest: "testinventory.yml"
  650. mode: '{{ file_permission }}'
  651. content: |
  652. ---
  653. manager:
  654. hosts:
  655. {{ host1 }}
  656. compute:
  657. hosts:
  658. {{ host2 }}
  659. tags: TC_014
  660. - name: Push the inventory to AWX
  661. shell: |
  662. set -o pipefail
  663. docker exec awx_task awx-manage inventory_import --inventory-name {{ omnia_inventory_name }} --source "{{ inventory_path }}/testinventory.yml"
  664. changed_when: false
  665. tags: TC_014
  666. - block:
  667. - name: Launch the job template
  668. command: >-
  669. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  670. job_templates launch "{{ omnia_template_name }}" --credentials "{{ credential_name }}" --monitor -f human
  671. changed_when: false
  672. register: command_output
  673. - name: Validate success message
  674. assert:
  675. that: "'FAILED!' not in command_output.stdout"
  676. success_msg: "{{ test_case_success_msg }}"
  677. fail_msg: "{{ test_case_failure_msg }}"
  678. tags: TC_014
  679. - name: Delete the hosts
  680. command: >-
  681. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  682. hosts delete {{ host1 }} --monitor -f human
  683. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  684. hosts delete {{ host2 }} --monitor -f human
  685. changed_when: false
  686. tags: TC_014
  687. - name: Delete the inventory file
  688. ignore_errors: yes
  689. file:
  690. state: absent
  691. path: testinventory.yml
  692. tags: TC_014
  693. - name: Create inventory file if it doesn't exist
  694. ignore_errors: yes
  695. file:
  696. path: "testinventory.yml"
  697. state: touch
  698. mode: '{{ file_permission }}'
  699. tags: TC_014
  700. # Testcase OMNIA_CRM_US_AWXD_TC_015
  701. # Test case to validate whether the proper error message is displayed when more than one host is added to manager group
  702. - name: OMNIA_CRM_US_AWXD_TC_015
  703. hosts: localhost
  704. connection: local
  705. vars_files:
  706. - ../roles/web_ui/vars/main.yml
  707. - ../roles/common/vars/main.yml
  708. - test_vars/test_omnia_vars.yml
  709. tasks:
  710. - name: Check input config file is encrypted
  711. command: cat {{ test_input_config_filename }}
  712. changed_when: false
  713. register: config_content
  714. tags: TC_015
  715. - name: Decrpyt input_config.yml
  716. command: ansible-vault decrypt {{ test_input_config_filename }} --vault-password-file {{ vault_filename }}
  717. changed_when: false
  718. when: "'$ANSIBLE_VAULT;' in config_content.stdout"
  719. tags: TC_015
  720. - name: Include variable file input_config.yml
  721. include_vars: "{{ test_input_config_filename }}"
  722. tags: TC_015
  723. - name: Creating inventory file with hosts associated to the groups
  724. copy:
  725. dest: "testinventory.yml"
  726. mode: '{{ file_permission }}'
  727. content: |
  728. ---
  729. compute:
  730. hosts:
  731. {{ host1 }}
  732. manager:
  733. hosts:
  734. {{ host2 }}
  735. hosts:
  736. {{ host3 }}
  737. tags: TC_015
  738. - name: Push the inventory to AWX
  739. shell: |
  740. set -o pipefail
  741. docker exec awx_task awx-manage inventory_import --inventory-name {{ omnia_inventory_name }} --source "{{ inventory_path }}/testinventory.yml"
  742. changed_when: false
  743. tags: TC_015
  744. - block:
  745. - name: Launch the job template
  746. command: >-
  747. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  748. job_templates launch "{{ omnia_template_name }}" --credentials "{{ credential_name }}" --monitor -f human
  749. changed_when: false
  750. register: command_output
  751. rescue:
  752. - name: Validate error message
  753. assert:
  754. that: "'FAILED!' in command_output.stdout"
  755. success_msg: "{{ test_case_success_msg }}"
  756. fail_msg: "{{ test_case_failure_msg }}"
  757. tags: TC_015
  758. - name: Delete the hosts
  759. command: >-
  760. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  761. hosts delete {{ host1 }} --monitor -f human
  762. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  763. hosts delete {{ host2 }} --monitor -f human
  764. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ awx_password }}" --conf.insecure
  765. hosts delete {{ host3 }} --monitor -f human
  766. changed_when: false
  767. tags: TC_015
  768. - name: Delete the inventory file
  769. ignore_errors: yes
  770. file:
  771. state: absent
  772. path: testinventory.yml
  773. tags: TC_015
  774. - name: Create inventory file if it doesn't exist
  775. ignore_errors: yes
  776. file:
  777. path: "testinventory.yml"
  778. state: touch
  779. mode: '{{ file_permission }}'
  780. tags: TC_015