ports.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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: port_auth_string
  40. changed_when: false
  41. ignore_errors: yes
  42. tags: install
  43. - name: Get session key
  44. uri:
  45. url: https://{{ groups['powervault_me4'][0] }}/api/login/{{ port_auth_string.stdout | replace(" -", "") }}
  46. method: GET
  47. headers:
  48. {'datatype': 'json'}
  49. validate_certs: no
  50. register: port_session_key
  51. delegate_to: localhost
  52. tags: install
  53. - name: Show ports
  54. uri:
  55. url: https://{{ groups['powervault_me4'][0] }}/api/show/ports
  56. method: GET
  57. body_format: json
  58. validate_certs: no
  59. use_proxy: no
  60. headers:
  61. {'sessionKey': "{{ port_session_key.json.status[0].response }}", 'datatype':'json'}
  62. register: show_ports
  63. delegate_to: localhost
  64. tags: install
  65. - name: Up ports
  66. set_fact:
  67. up_port: "{{ up_port + [item.port] }}"
  68. target_id: "{{ item.get('target-id') }}"
  69. when: item.status == "Up"
  70. loop: "{{ show_ports.json.port }}"
  71. loop_control:
  72. label: "{{ item.port }}"
  73. - name: Set ip
  74. set_fact:
  75. set_port_ip: "{{ set_port_ip+['{{ port_ip }}{{ temp|int }}'] }}"
  76. temp: "{{ temp|int+t|int }}"
  77. loop: "{{ up_port }}"
  78. - name: Assign ip to ports
  79. uri:
  80. url: https://{{ groups['powervault_me4'][0] }}/api/set/host-parameters/gateway/{{ port_gateway }}/ip/{{ item.0 }}/netmask/{{ port_netmask }}/ports/{{ item.1 }}/prompt/yes/noprompt
  81. method: GET
  82. body_format: json
  83. validate_certs: no
  84. use_proxy: no
  85. headers:
  86. {'sessionKey': "{{ port_session_key.json.status[0].response }}", 'datatype':'json'}
  87. register: set_ports
  88. with_together:
  89. - "{{ set_port_ip }}"
  90. - "{{ up_port }}"
  91. delegate_to: localhost
  92. tags: install