summaryrefslogtreecommitdiffstats
path: root/ansible_collections/dellemc/powerflex/roles/powerflex_tb
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/dellemc/powerflex/roles/powerflex_tb')
-rw-r--r--ansible_collections/dellemc/powerflex/roles/powerflex_tb/tasks/connect_mdm_cluster.yml131
-rw-r--r--ansible_collections/dellemc/powerflex/roles/powerflex_tb/tasks/install_tb4x.yml7
-rw-r--r--ansible_collections/dellemc/powerflex/roles/powerflex_tb/tasks/set_tb_ips.yml18
3 files changed, 150 insertions, 6 deletions
diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_tb/tasks/connect_mdm_cluster.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_tb/tasks/connect_mdm_cluster.yml
new file mode 100644
index 000000000..e166a9316
--- /dev/null
+++ b/ansible_collections/dellemc/powerflex/roles/powerflex_tb/tasks/connect_mdm_cluster.yml
@@ -0,0 +1,131 @@
+---
+- name: Get login token
+ ansible.builtin.uri:
+ url: "https://{{ hostname }}:{{ port }}/api/gatewayLogin"
+ validate_certs: "{{ validate_certs }}"
+ user: "{{ username }}"
+ password: "{{ password }}"
+ method: GET
+ force_basic_auth: true
+ delegate_to: "{{ lookup('ansible.builtin.env', 'RUNON', default='localhost') }}"
+ run_once: true
+ no_log: true
+ register: powerflex_tb_login_token_response
+
+- name: Get LIA credentials
+ ansible.builtin.uri:
+ url: "https://{{ hostname }}:{{ port }}/api/V1/Credential?filter=eq,label,DELL_POWERFLEX_LIA"
+ method: GET
+ validate_certs: "{{ validate_certs }}"
+ headers:
+ Authorization: "Bearer {{ powerflex_tb_login_token_response.json }}"
+ delegate_to: "{{ lookup('ansible.builtin.env', 'RUNON', default='localhost') }}"
+ run_once: true
+ register: powerflex_tb_lia_credentials
+
+- name: Set credential ID
+ ansible.builtin.set_fact:
+ powerflex_tb_lia_credential_id: "{{ powerflex_tb_lia_credentials.json.credentialList[0].credential.id }}"
+ when: powerflex_tb_lia_credentials is defined and powerflex_tb_lia_credentials.json.credentialList | length > 0
+
+- name: Create LIA credentials if not exists
+ when: powerflex_tb_lia_credentials.json.credentialList | length == 0
+ block:
+ - name: Create LIA credentials payload
+ ansible.builtin.set_fact:
+ powerflex_tb_lia_credential:
+ credential:
+ type: "ManagementSystemCredential"
+ label: "DELL_POWERFLEX_LIA"
+ password: "{{ powerflex_lia_token }}"
+ liaPassword: "{{ powerflex_lia_token }}"
+
+ - name: Create LIA credentials
+ ansible.builtin.uri:
+ url: "https://{{ hostname }}:{{ port }}/api/V1/Credential"
+ validate_certs: "{{ validate_certs }}"
+ method: POST
+ headers:
+ Authorization: "Bearer {{ powerflex_tb_login_token_response.json }}"
+ Content-Type: "application/json"
+ body: "{{ powerflex_tb_lia_credential | to_json }}"
+ register: powerflex_tb_lia_create_credentials
+ delegate_to: "{{ lookup('ansible.builtin.env', 'RUNON', default='localhost') }}"
+ run_once: true
+ changed_when: powerflex_tb_lia_create_credentials.status == 200
+
+ - name: Set credential ID
+ ansible.builtin.set_fact:
+ powerflex_tb_lia_credential_id: "{{ powerflex_tb_lia_create_credentials.json.credential.id }}"
+ when: powerflex_tb_lia_create_credentials is defined
+
+- name: Set discovery request payload
+ ansible.builtin.set_fact:
+ discovery_request_payload:
+ discoveryRequestList:
+ DiscoverIPRangeDeviceRequest:
+ - deviceManagementSystemCredRef: "{{ powerflex_tb_lia_credential_id }}"
+ deviceManagementSystemIPAddress: "{{ powerflex_tb_device_management_system_ip_address }}"
+ deviceManagementSystemId: "{{ powerflex_tb_system_id }}"
+ deviceType: "powerflex_management_system"
+ hostName: "block-legacy-gateway"
+ unmanaged: false
+ reserved: false
+ serverPoolId: ""
+ autoConfigureAlerts: true
+ snmpConfigure: true
+ when: powerflex_tb_lia_credentials is defined
+
+- name: Create connect mdm cluster payload
+ ansible.builtin.uri:
+ url: "https://{{ hostname }}:{{ port }}/api/V1/DiscoveryRequest"
+ validate_certs: "{{ validate_certs }}"
+ method: POST
+ headers:
+ Authorization: "Bearer {{ powerflex_tb_login_token_response.json }}"
+ Content-Type: "application/json"
+ body: "{{ discovery_request_payload | to_json }}"
+ status_code: 202
+ when: powerflex_tb_lia_credentials is defined
+ delegate_to: "{{ lookup('ansible.builtin.env', 'RUNON', default='localhost') }}"
+ run_once: true
+ register: powerflex_tb_connect_mdm_cluster_output
+ changed_when: powerflex_tb_connect_mdm_cluster_output.status == 202
+
+- name: Extract Job ID from connect mdm cluster output
+ ansible.builtin.set_fact:
+ powerflex_tb_connect_mdm_cluster_job_id: "{{ powerflex_tb_connect_mdm_cluster_output.link | regex_search('Job-[a-zA-Z0-9-]+') }}"
+ when: powerflex_tb_connect_mdm_cluster_output is defined
+
+- name: Track job
+ register: powerflex_tb_connect_mdm_cluster_job_status
+ ansible.builtin.uri:
+ url: "https://{{ hostname }}:{{ port }}/API/V1/JobHistory/{{ powerflex_tb_connect_mdm_cluster_job_id }}/status"
+ validate_certs: "{{ validate_certs }}"
+ method: GET
+ headers:
+ Authorization: "Bearer {{ powerflex_tb_login_token_response.json }}"
+ status_code: 200
+ run_once: true
+ retries: 5
+ delay: 10
+ delegate_to: "{{ lookup('ansible.builtin.env', 'RUNON', default='localhost') }}"
+ when: powerflex_tb_connect_mdm_cluster_job_id is defined
+ until: powerflex_tb_connect_mdm_cluster_job_status.json != "IN_PROGRESS"
+ failed_when: powerflex_tb_connect_mdm_cluster_job_status.json == "FAILED"
+ changed_when: powerflex_tb_connect_mdm_cluster_job_status.json == "SUCCEESSFUL"
+
+- name: Wait for API login call to be successful
+ register: powerflex_tb_api_login
+ ansible.builtin.uri:
+ url: "https://{{ hostname }}:{{ port }}/api/login"
+ user: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: "{{ validate_certs }}"
+ method: GET
+ delegate_to: "{{ lookup('ansible.builtin.env', 'RUNON', default='localhost') }}"
+ run_once: true
+ ignore_errors: true
+ retries: 5
+ delay: 10
+ until: powerflex_tb_api_login.status == 200
diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_tb/tasks/install_tb4x.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_tb/tasks/install_tb4x.yml
index d34857ba4..9ae3bc1c1 100644
--- a/ansible_collections/dellemc/powerflex/roles/powerflex_tb/tasks/install_tb4x.yml
+++ b/ansible_collections/dellemc/powerflex/roles/powerflex_tb/tasks/install_tb4x.yml
@@ -20,6 +20,10 @@
changed_when: powerflex_tb_login_output.rc == 0
delegate_to: "{{ powerflex_tb_mdm_primary_hostname }}"
+- name: Extract System ID
+ ansible.builtin.set_fact:
+ powerflex_tb_system_id: "{{ powerflex_tb_login_output.stdout | regex_search('System ID is (\\w+)', '\\1') | first }}"
+
- name: Add primary TB
ansible.builtin.command: >
scli --add_standby_mdm
@@ -67,3 +71,6 @@
changed_when: powerflex_tb_cluster_to_five_output.rc == 0
delegate_to: "{{ powerflex_tb_mdm_primary_hostname }}"
when: powerflex_tb_mdm_cluster_mode[0] != "5_node" and powerflex_tb_cluster_mode == "FiveNodes"
+
+- name: Connect MDM cluster
+ ansible.builtin.include_tasks: connect_mdm_cluster.yml
diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_tb/tasks/set_tb_ips.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_tb/tasks/set_tb_ips.yml
index 34c0144d5..f2c534f77 100644
--- a/ansible_collections/dellemc/powerflex/roles/powerflex_tb/tasks/set_tb_ips.yml
+++ b/ansible_collections/dellemc/powerflex/roles/powerflex_tb/tasks/set_tb_ips.yml
@@ -11,19 +11,25 @@
powerflex_tb_mdm_secondary_ip: "{{ hostvars[groups['mdm'][1]]['ansible_host'] }}"
powerflex_tb_mdm_secondary_hostname: "{{ hostvars[groups['mdm'][1]]['inventory_hostname'] }}"
-- name: Set fact - powerflex_tb_mdm_tertiary_ip
- ansible.builtin.set_fact:
- powerflex_tb_mdm_tertiary_ip: "{{ hostvars[groups['tb'][2]]['ansible_host'] }}"
- powerflex_tb_mdm_tertiary_hostname: "{{ hostvars[groups['tb'][2]]['inventory_hostname'] }}"
- when: "powerflex_tb_mdm_count | int > 2"
-
- name: Set fact - powerflex_tb_primary
ansible.builtin.set_fact:
powerflex_tb_primary_ip: "{{ hostvars[groups['tb'][0]]['ansible_host'] }}"
powerflex_tb_primary_hostname: "{{ hostvars[groups['tb'][0]]['inventory_hostname'] }}"
+- name: Set fact - powerflex_tb_device_management_system_ip_address
+ ansible.builtin.set_fact:
+ powerflex_tb_device_management_system_ip_address: "{{ powerflex_tb_mdm_primary_ip }}, {{ powerflex_tb_mdm_secondary_ip }}, {{ powerflex_tb_primary_ip }}"
+
- name: Set fact - powerflex_tb_primary
ansible.builtin.set_fact:
powerflex_tb_secondary_ip: "{{ hostvars[groups['tb'][1]]['ansible_host'] }}"
powerflex_tb_secondary_hostname: "{{ hostvars[groups['tb'][1]]['inventory_hostname'] }}"
+ powerflex_tb_device_management_system_ip_address: "{{ powerflex_tb_device_management_system_ip_address }}, {{ powerflex_tb_secondary_ip }}"
when: "powerflex_tb_count | int > 1"
+
+- name: Set fact - powerflex_tb_mdm_tertiary_ip
+ ansible.builtin.set_fact:
+ powerflex_tb_mdm_tertiary_ip: "{{ hostvars[groups['tb'][2]]['ansible_host'] }}"
+ powerflex_tb_mdm_tertiary_hostname: "{{ hostvars[groups['tb'][2]]['inventory_hostname'] }}"
+ powerflex_tb_device_management_system_ip_address: "{{ powerflex_tb_device_management_system_ip_address }}, {{ powerflex_tb_mdm_tertiary_ip }}"
+ when: "powerflex_tb_mdm_count | int > 2"