test_ib_mtu.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. - name: Get MTU of mgmt5
  16. hosts: infiniband
  17. gather_facts: no
  18. connection: local
  19. vars_files:
  20. - test_vars/test_infiniband_vars.yml
  21. tasks:
  22. - name: Set credentials and variables
  23. set_fact:
  24. username: "{{ username }}"
  25. password: "{{ password }}"
  26. filtered_dict: {}
  27. no_log: true
  28. tags: reboot,mtu
  29. - name: Authenticate
  30. block:
  31. - name: Authenticate to switch- "{{ inventory_hostname }}"
  32. uri:
  33. url: http://{{ inventory_hostname }}/admin/launch?script=rh&template=login&action=login
  34. method: POST
  35. body_format: form-urlencoded
  36. body:
  37. f_user_id: "{{ username }}"
  38. f_password: "{{ password }}"
  39. enter: Sign in
  40. status_code: 302
  41. register: login
  42. no_log: true
  43. - name: Verify authentication status
  44. fail:
  45. msg: "Authentication failed"
  46. when: login.set_cookie is undefined
  47. rescue:
  48. - name: Filtered response creation
  49. set_fact:
  50. filtered_dict: "{{filtered_dict |combine({item.key: item.value})}}"
  51. when: item.key not in 'invocation'
  52. with_dict: "{{ login }}"
  53. no_log: true
  54. - name: Authentication failure response
  55. fail:
  56. msg: "{{ filtered_dict }}"
  57. tags: reboot,mtu
  58. - name: get MTU from ib {{ validation_port }}
  59. uri:
  60. url: http://{{ inventory_hostname }}/admin/launch?script=json
  61. method: POST
  62. body_format: json
  63. headers:
  64. Cookie: "{{ login.set_cookie.split(';')[0] }}"
  65. body:
  66. {
  67. "commands":
  68. [
  69. "show interfaces ib {{ validation_port }}"
  70. ]
  71. }
  72. return_content: yes
  73. register: value
  74. tags: mtu
  75. - name: print reistered o/p
  76. debug:
  77. msg: "{{ value }}"
  78. tags: mtu
  79. - name: reboot IB switch
  80. uri:
  81. url: http://{{ inventory_hostname }}/admin/launch?script=json
  82. method: POST
  83. body_format: json
  84. headers:
  85. Cookie: "{{ login.set_cookie.split(';')[0] }}"
  86. body:
  87. {
  88. "commands":
  89. [
  90. "reload"
  91. ]
  92. }
  93. return_content: yes
  94. tags: reboot