map_volume.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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: Include powervault_me4_vars.yml
  16. include_vars: "{{ playbook_dir }}/control_plane/input_params/powervault_me4_vars.yml"
  17. - name: Include powervault_me4 role variables
  18. include_vars: "{{ playbook_dir }}/control_plane/roles/powervault_me4/vars/main.yml"
  19. - name: Check if login_vars.yml file is encrypted
  20. command: cat {{ login_pv_file }}
  21. changed_when: false
  22. no_log: true
  23. register: config_content
  24. delegate_to: localhost
  25. run_once: true
  26. - name: Decrpyt login_vars.yml
  27. command: >-
  28. ansible-vault decrypt {{ login_pv_file }}
  29. --vault-password-file {{ login_pv_vault_file }}
  30. changed_when: false
  31. run_once: true
  32. delegate_to: localhost
  33. when: "'$ANSIBLE_VAULT;' in config_content.stdout"
  34. - name: Include variable file login_vars.yml
  35. include_vars: "{{ login_pv_file }}"
  36. no_log: true
  37. - name: Get auth string
  38. shell: echo -n {{ powervault_me4_username }}_{{ powervault_me4_password }} | sha256sum
  39. register: map_auth_string
  40. changed_when: false
  41. ignore_errors: yes
  42. delegate_to: localhost
  43. tags: install
  44. - name: Get session key
  45. uri:
  46. url: https://{{ groups['powervault_me4'][0] }}/api/login/{{ map_auth_string.stdout | replace(" -", "") }}
  47. method: GET
  48. headers:
  49. {'datatype': 'json'}
  50. validate_certs: no
  51. register: map_session_key
  52. delegate_to: localhost
  53. tags: install
  54. - name: Get map port
  55. set_fact:
  56. map_port: "{{ item.0 }}"
  57. when: hostvars['pv']['map_ip'] == item.1
  58. with_together:
  59. - "{{ up_port }}"
  60. - "{{ set_port_ip }}"
  61. register: output
  62. - name: Map volume
  63. uri:
  64. url: https://{{ groups['powervault_me4'][0] }}/api/map/volume/{{ powervault_me4_k8s_volume_name }}/access/{{ access }}/ports/{{ map_port }}/lun/{{ lun1 }}/initiator/{{ hostvars['server_iqdn_id']['server_iqdn'] }}
  65. method: GET
  66. body_format: json
  67. validate_certs: no
  68. use_proxy: no
  69. headers:
  70. {'sessionKey': "{{ map_session_key.json.status[0].response }}", 'datatype':'json'}
  71. register: map_vol1
  72. delegate_to: localhost
  73. tags: install
  74. - name: Map volume
  75. uri:
  76. url: https://{{ groups['powervault_me4'][0] }}/api/map/volume/{{ powervault_me4_slurm_volume_name }}/access/{{ access }}/ports/{{ map_port }}/lun/{{ lun2 }}/initiator/{{ hostvars['server_iqdn_id']['server_iqdn'] }}
  77. method: GET
  78. body_format: json
  79. validate_certs: no
  80. use_proxy: no
  81. headers:
  82. {'sessionKey': "{{ map_session_key.json.status[0].response }}", 'datatype':'json'}
  83. register: map_vol2
  84. delegate_to: localhost
  85. tags: install
  86. - name: Encypt login_vars.yml
  87. command: >-
  88. ansible-vault encrypt {{ login_pv_file }}
  89. --vault-password-file {{ login_pv_vault_file }}
  90. changed_when: false
  91. run_once: true
  92. delegate_to: localhost
  93. when: "'$ANSIBLE_VAULT;' in config_content.stdout"