map_volume.yml 3.1 KB

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