ports.yml 3.0 KB

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