Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Roles][BugFix] Add fix for mdm cluster connect #55

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions roles/powerflex_config/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
delegate_to: "{{ powerflex_config_mdm_primary_hostname }}"
when: powerflex_config_array_version == '4'

- name: Add certificate file for PowerFlex version 4.x
ansible.builtin.command: scli --add_certificate --certificate_file /opt/emc/scaleio/mdm/cfg/mgmt_ca.pem
run_once: true
register: powerflex_config_add_certificate
changed_when: powerflex_config_add_certificate.rc == 0
delegate_to: "{{ powerflex_config_mdm_primary_hostname }}"
when: powerflex_config_array_version == '4'

- name: Login to MDM for PowerFlex version 4.x
ansible.builtin.command: scli --login --p12_path /opt/emc/scaleio/mdm/cfg/cli_certificate.p12 --p12_password {{ password }}
run_once: true
Expand Down
2 changes: 1 addition & 1 deletion roles/powerflex_gateway/tasks/install_keepalived.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
mode: '0600'
owner: root
group: root
notify: restart keepalived
notify: Restart keepalived
24 changes: 24 additions & 0 deletions roles/powerflex_lia/tasks/install_lia.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,27 @@

- name: Include install_powerflex.yml
ansible.builtin.include_tasks: ../../powerflex_common/tasks/install_powerflex.yml

- name: Check if /opt/emc/scaleio/lia/cfg/conf.txt exists
ansible.builtin.stat:
path: /opt/emc/scaleio/lia/cfg/conf.txt
register: powerflex_lia_conf_file_stat

- name: Update lia_mtls_only
ansible.builtin.lineinfile:
path: /opt/emc/scaleio/lia/cfg/conf.txt
regexp: '^lia_mtls_only=1$'
state: absent
when: powerflex_lia_conf_file_stat.stat.exists

- name: Replace lia_token value
ansible.builtin.replace:
path: /opt/emc/scaleio/lia/cfg/conf.txt
regexp: '^lia_token=.*$'
replace: 'lia_token={{ powerflex_lia_token }}'
when: powerflex_lia_conf_file_stat.stat.exists

- name: PKill LIA for config changes effect
ansible.builtin.command: pkill lia
register: powerflex_lia_pkill_ouput
changed_when: powerflex_lia_pkill_ouput.rc == 0
7 changes: 7 additions & 0 deletions roles/powerflex_mdm/tasks/install_powerflex4x_mdm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
run_once: true
delegate_to: "{{ powerflex_mdm_primary_hostname }}"

- name: Add certificate file for PowerFlex version 4.x
ansible.builtin.command: scli --add_certificate --certificate_file /opt/emc/scaleio/mdm/cfg/mgmt_ca.pem
run_once: true
register: powerflex_mdm_add_certificate
changed_when: powerflex_mdm_add_certificate.rc == 0
delegate_to: "{{ powerflex_mdm_primary_hostname }}"

- name: Login to primary MDM node
register: powerflex_mdm_secondary_login
ansible.builtin.command: >
Expand Down
2 changes: 1 addition & 1 deletion roles/powerflex_sdc/tasks/install_sdc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@
mode: "0600"
owner: "root"
group: "root"
notify: restart scini
notify: Restart scini
when:
- ansible_distribution not in ['WindowsOS', 'SLES', 'VMkernel']
10 changes: 9 additions & 1 deletion roles/powerflex_sdr/tasks/add_sdr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,22 @@
rescue:
- name: Generate login certificate using primary_mdm_ip
ansible.builtin.command: >
scli --generate_login_certificate --management_system_ip {{ powerflex_sdr_primary_mdm_ip }} --username {{ username }}
scli --generate_login_certificate --management_system_ip {{ powerflex_sdr_mdm_primary_ip }} --username {{ username }}
--password {{ password }} --p12_path /opt/emc/scaleio/mdm/cfg/cli_certificate.p12 --p12_password {{ password }} --insecure
run_once: true
register: powerflex_sdr_generate_login_certificate_mdm_ip
changed_when: powerflex_sdr_generate_login_certificate_mdm_ip.rc == 0
delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}"
when: powerflex_sdr_array_version != "3"

- name: Add certificate file for PowerFlex version 4.x
ansible.builtin.command: scli --add_certificate --certificate_file /opt/emc/scaleio/mdm/cfg/mgmt_ca.pem
run_once: true
register: powerflex_sdr_add_certificate
changed_when: powerflex_sdr_add_certificate.rc == 0
delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}"
when: powerflex_sdr_array_version != '3'

- name: Login to MDM for PowerFlex version 4.x
ansible.builtin.command: scli --login --p12_path /opt/emc/scaleio/mdm/cfg/cli_certificate.p12 --p12_password {{ password }}
run_once: true
Expand Down
43 changes: 34 additions & 9 deletions roles/powerflex_sdr/tasks/remove_sdr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,42 @@
no_log: true
when: powerflex_sdr_array_version == "3"

- name: Login to mdm for PowerFlex version 4.x
ansible.builtin.command: >
scli --login --management_system_ip {{ hostname }}
--username admin
--password "{{ password }}"
--approve_certificate
- name: Generate login certificate for PowerFlex version 4.x
block:
- name: Generate login certificate using management_system_ip
ansible.builtin.command: >
scli --generate_login_certificate --management_system_ip {{ hostname }} --username {{ username }} --password {{ password }}
--p12_path /opt/emc/scaleio/mdm/cfg/cli_certificate.p12 --p12_password {{ password }} --insecure
run_once: true
register: powerflex_sdr_generate_login_certificate
changed_when: powerflex_sdr_generate_login_certificate.rc == 0
delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}"
when: powerflex_sdr_array_version != "3"
rescue:
- name: Generate login certificate using primary_mdm_ip
ansible.builtin.command: >
scli --generate_login_certificate --management_system_ip {{ powerflex_sdr_mdm_primary_ip }} --username {{ username }}
--password {{ password }} --p12_path /opt/emc/scaleio/mdm/cfg/cli_certificate.p12 --p12_password {{ password }} --insecure
run_once: true
register: powerflex_sdr_generate_login_certificate_mdm_ip
changed_when: powerflex_sdr_generate_login_certificate_mdm_ip.rc == 0
delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}"
when: powerflex_sdr_array_version != "3"

- name: Add certificate file for PowerFlex version 4.x
ansible.builtin.command: scli --add_certificate --certificate_file /opt/emc/scaleio/mdm/cfg/mgmt_ca.pem
run_once: true
register: powerflex_initial_login
register: powerflex_sdr_add_certificate
changed_when: powerflex_sdr_add_certificate.rc == 0
delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}"
when: powerflex_sdr_array_version != '3'

- name: Login to MDM for PowerFlex version 4.x
ansible.builtin.command: scli --login --p12_path /opt/emc/scaleio/mdm/cfg/cli_certificate.p12 --p12_password {{ password }}
run_once: true
register: powerflex_sdr_login_output
changed_when: powerflex_sdr_login_output.rc == 0
delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}"
changed_when: powerflex_initial_login.rc == 0
no_log: true
when: powerflex_sdr_array_version != "3"

- name: Output msg of previous task login to mdm
Expand Down
8 changes: 8 additions & 0 deletions roles/powerflex_sds/tasks/install_sds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@
delegate_to: "{{ powerflex_sds_primary_mdm_hostname }}"
when: powerflex_sds_array_version != "3"

- name: Add certificate file for PowerFlex version 4.x
ansible.builtin.command: scli --add_certificate --certificate_file /opt/emc/scaleio/mdm/cfg/mgmt_ca.pem
run_once: true
register: powerflex_sds_add_certificate
changed_when: powerflex_sds_add_certificate.rc == 0
delegate_to: "{{ powerflex_sds_primary_mdm_hostname }}"
when: powerflex_sds_array_version != '3'

- name: Login to MDM for PowerFlex version 4.x
ansible.builtin.command: scli --login --p12_path /opt/emc/scaleio/mdm/cfg/cli_certificate.p12 --p12_password {{ password }}
run_once: true
Expand Down
131 changes: 131 additions & 0 deletions roles/powerflex_tb/tasks/connect_mdm_cluster.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions roles/powerflex_tb/tasks/install_tb4x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
18 changes: 12 additions & 6 deletions roles/powerflex_tb/tasks/set_tb_ips.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading