test_inventory_validation.yml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. # Copyright 2021 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. - block:
  16. - name: Get iDRAC IP details
  17. dellemc.openmanage.idrac_system_info:
  18. idrac_ip: "{{ item | trim }}"
  19. idrac_user: "{{ idrac_username }}"
  20. idrac_password: "{{ idrac_password }}"
  21. register: idrac_ip
  22. run_once: true
  23. ignore_errors: yes
  24. tags: "TC_004"
  25. - name: Validate iDRAC IP
  26. assert:
  27. that:
  28. - idrac_ip.system_info.iDRACNIC[0].ProductInfo == idrac_search_key
  29. fail_msg: "{{ item | trim }} {{ idrac_fail_msg }}"
  30. success_msg: "{{ item | trim }} {{ idrac_success_msg }}"
  31. tags: "TC_004"
  32. - name: Authenticate infiniband Switch
  33. uri:
  34. url: http://{{ item | trim }}/admin/launch?script=rh&template=login&action=login
  35. method: POST
  36. body_format: form-urlencoded
  37. body:
  38. f_user_id: "{{ ib_username }}"
  39. f_password: "{{ ib_password }}"
  40. enter: Sign in
  41. status_code: "{{ infiniband_status_code }}"
  42. register: login
  43. ignore_errors: yes
  44. run_once: true
  45. tags: "TC_005"
  46. - name: Assert infiniband switch
  47. uri:
  48. url: http://{{ item | trim }}/admin/launch?script=json
  49. method: POST
  50. body_format: json
  51. headers:
  52. Cookie: "{{ login.set_cookie.split(';')[0] }}"
  53. body:
  54. {
  55. "commands":
  56. [
  57. "show version"
  58. ]
  59. }
  60. register: infinibandswitch_info
  61. when: login.failed == false or 'set_cookie' not in login
  62. ignore_errors: yes
  63. run_once: true
  64. tags: "TC_005"
  65. - name: Validate infiniband IP
  66. assert:
  67. that:
  68. - infinibandswitch_info.json.data['Product name'] == infiniband_search_key
  69. fail_msg: "{{ infiniband_fail_msg }}"
  70. success_msg: "{{ infiniband_success_msg }}"
  71. ignore_errors: yes
  72. tags: "TC_005"
  73. - name: Get ethernet IP details
  74. dellos10_command:
  75. provider:
  76. host: "{{ item | trim }}"
  77. username: "{{ ethernet_switch_username }}"
  78. password: "{{ ethernet_switch_password }}"
  79. commands: ['show version']
  80. register: ethernet_info
  81. ignore_errors: yes
  82. run_once: true
  83. when: ethernet_switch_support
  84. tags: "TC_006"
  85. - name: Validate ethernet IP
  86. assert:
  87. that:
  88. - ethernet_info.stdout | regex_search(ethernet_search_key)
  89. fail_msg: " {{ item | trim }} {{ ethernet_fail_msg }}"
  90. success_msg: "{{ item | trim }} {{ ethernet_success_msg }}"
  91. tags: "TC_006"
  92. - name: Get auth string for powervault
  93. shell: echo -n {{ powervault_me4_username }}_{{powervault_me4_password}} | sha256sum
  94. changed_when: false
  95. when: powervault_support
  96. register: auth_string
  97. ignore_errors: yes
  98. run_once: true
  99. tags: "TC_007"
  100. - name: Get session key for powervault
  101. uri:
  102. url: https://{{ item | trim }}/api/login/{{ auth_string.stdout | replace(" -", "") }}
  103. method: GET
  104. headers:
  105. {'datatype': 'json'}
  106. validate_certs: no
  107. when: powervault_support
  108. register: session_key
  109. ignore_errors: yes
  110. run_once: true
  111. tags: "TC_007"
  112. - name: Assert me4_powervault
  113. uri:
  114. url: https://{{ item | trim }}/api/show/system
  115. method: GET
  116. body_format: json
  117. validate_certs: no
  118. use_proxy: no
  119. headers:
  120. {'sessionKey': "{{ session_key.json.status[0].response }}", 'datatype':'json'}
  121. register: system_info
  122. ignore_errors: yes
  123. run_once: true
  124. tags: "TC_007"
  125. - name: Validate me4_powervault IP
  126. assert:
  127. that:
  128. - "'{{ me4_powervault_search_key }}' in system_info.json.system[0]['scsi-product-id']"
  129. fail_msg: "{{ item | trim }} {{ powervault_fail_msg }}"
  130. success_msg: "{{ item | trim }} {{ powervault_success_msg }}"
  131. ignore_errors: yes
  132. tags: "TC_007"
  133. rescue:
  134. - debug:
  135. msg: "{{ failed_msg }}"