pv_me4_prereq.yml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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: Ping the powervault device to validate connectivity
  16. command: ping -c1 {{ inventory_hostname }}
  17. register: validate_login
  18. changed_when: false
  19. ignore_errors: yes
  20. tags: install
  21. - name: Get auth string
  22. shell: echo -n {{ powervault_me4_username }}_{{ powervault_me4_password }} | sha256sum
  23. register: auth_string
  24. changed_when: false
  25. ignore_errors: yes
  26. tags: install
  27. - name: Get session key
  28. uri:
  29. url: https://{{ inventory_hostname }}/api/login/{{ auth_string.stdout | replace(" -", "") }}
  30. method: GET
  31. headers:
  32. {'datatype': 'json'}
  33. validate_certs: no
  34. register: session_key
  35. tags: install
  36. - name: Set powervault ip
  37. add_host:
  38. name: "pv_ip"
  39. powervault_ip: "{{ inventory_hostname }}"
  40. tags: install
  41. - name: Execute show system command
  42. uri:
  43. url: https://{{ inventory_hostname }}/api/show/system
  44. method: GET
  45. body_format: json
  46. validate_certs: no
  47. use_proxy: no
  48. headers:
  49. {'sessionKey': "{{ session_key.json.status[0].response }}", 'datatype':'json'}
  50. register: system_info
  51. tags: install
  52. - name: Get the product id
  53. set_fact:
  54. pv_id: "{{ system_info.json.system[0]['product-id'] }}"
  55. - name: Verify the product id and model no. of device
  56. fail:
  57. msg: "{{ fail_pv_support }}"
  58. when:
  59. - scsi_product_id not in system_info.json.system[0]['scsi-product-id']
  60. - pv_id != "ME4084" or pv_id != "ME4024" or pv_id != "ME4012"
  61. - name: Set system name
  62. uri:
  63. url: https://{{ inventory_hostname }}/api/set/system/name/{{ powervault_me4_system_name }}
  64. method: GET
  65. body_format: json
  66. validate_certs: no
  67. use_proxy: no
  68. headers:
  69. {'sessionKey': "{{ session_key.json.status[0].response }}", 'datatype':'json'}
  70. register: system_name
  71. when: powervault_me4_system_name
  72. tags: install