diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-18 05:52:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-18 05:52:22 +0000 |
commit | 38b7c80217c4e72b1d8988eb1e60bb6e77334114 (patch) | |
tree | 356e9fd3762877d07cde52d21e77070aeff7e789 /ansible_collections/dellemc/powerflex/roles/powerflex_sdr | |
parent | Adding upstream version 7.7.0+dfsg. (diff) | |
download | ansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.tar.xz ansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.zip |
Adding upstream version 9.4.0+dfsg.upstream/9.4.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/dellemc/powerflex/roles/powerflex_sdr')
18 files changed, 651 insertions, 0 deletions
diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/README.md b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/README.md new file mode 100644 index 000000000..e83491329 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/README.md @@ -0,0 +1,145 @@ +# powerflex_sdr + +Role to manage installation and uninstallation PowerFlex SDR. + +## Table of contents + +* [Requirements](#requirements) +* [Ansible collections](#ansible-collections) +* [Role Variables](#role-variables) +* [Examples](#examples) +* [Usage instructions](#usage-instructions) +* [Author Information](#author-information) + +## Requirements + +``` +ansible +python +``` + +## Ansible collections + +Collections required to use the role. + +``` +dellemc.powerflex +``` + +## Role Variables + +<table> +<thead> + <tr> + <th>Name</th> + <th>Required</th> + <th>Description</th> + <th>Choices</th> + <th>Type</th> + <th>Default Value</th> + </tr> +</thead> +<tbody> + <tr> + <td>powerflex_common_file_install_location</td> + <td>false</td> + <td>Location of required, compatible installation software package based on the operating system of the node. + <br>The files can be downloaded from the Dell Product support page for PowerFlex software.</td> + <td></td> + <td>path</td> + <td>/var/tmp</td> + </tr> + <tr> + <td>powerflex_protection_domain_name</td> + <td>false</td> + <td>The name of the protection domain to which the SDR will be added.</td> + <td></td> + <td>str</td> + <td></td> + </tr> + <tr> + <td>powerflex_storage_pool_name</td> + <td>false</td> + <td>The name of the storage pool to which the device will be added.</td> + <td></td> + <td>str</td> + <td></td> + </tr> + <tr> + <td>powerflex_sdr_repl_journal_capacity_max_ratio</td> + <td>false</td> + <td>Maximum capacity percentage to be allocated for journal capacity. Range is 0 to 100.</td> + <td></td> + <td>int</td> + <td>10</td> + </tr> + <tr> + <td>powerflex_mdm_password</td> + <td>true</td> + <td>Password for primary MDM node.</td> + <td></td> + <td>str</td> + <td></td> + </tr> +<tr> + <td>powerflex_sdr_state</td> + <td>false</td> + <td>State of the SDR.</td> + <td>present, absent</td> + <td>str</td> + <td>present</td> + </tr> +</tbody> +</table> + +## Examples +---- +``` + - name: Install powerflex SDR + ansible.builtin.include_role: + name: powerflex_sdr + vars: + powerflex_protection_domain_name: domain1 + powerflex_storage_pool_name: pool1 + powerflex_sdr_repl_journal_capacity_max_ratio: 10 + powerflex_sdr_state: present + powerflex_mdm_password: Password111 + + - name: Uninstall powerflex SDR + ansible.builtin.include_role: + name: powerflex_sdr + vars: + powerflex_mdm_password: Password111 + powerflex_sdr_state: absent + +``` + +## Usage instructions +---- +### To install all dependency packages, including SDR, on node: +- PowerFlex 3.6: + ``` + ansible-playbook -i inventory site.yml + ``` +- PowerFlex 4.5: + ``` + ansible-playbook -i inventory site_powerflex45.yml + ``` + +### To uninstall SDR: +- PowerFlex 3.6: + ``` + ansible-playbook -i inventory uninstall_powerflex.yml + ``` +- PowerFlex 4.5: + ``` + ansible-playbook -i inventory uninstall_powerflex45.yml + ``` + +Sample playbooks and inventory can be found in the playbooks directory. + +## Author Information +------------------ + +Dell Technologies <br> +Abhishek Sinha (ansible.team@Dell.com) 2023
\ No newline at end of file diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/defaults/main.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/defaults/main.yml new file mode 100644 index 000000000..efae8a870 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/defaults/main.yml @@ -0,0 +1,9 @@ +--- +# defaults file for powerflex_sdr +file_glob_name: sdr +file_gpg_name: RPM-GPG-KEY-ScaleIO +powerflex_common_file_install_location: "/var/tmp" +powerflex_sdr_repl_journal_capacity_max_ratio: 10 +powerflex_role_environment: + MDM_IP: "{{ powerflex_sdr_mdm_primary_ip }}" +powerflex_sdr_state: present diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/meta/argument_specs.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/meta/argument_specs.yml new file mode 100644 index 000000000..b730ebed4 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/meta/argument_specs.yml @@ -0,0 +1,34 @@ +--- +argument_specs: + main: + short_description: Role to manage installation and uninstallation Powerflex SDR + description: + - Role to manage installation and uninstallation Powerflex SDR. + options: + powerflex_common_file_install_location: + description: + - Location of installation and rpm gpg files to be installed. + - The required, compatible installation software package based on the operating system of the node. + - The files can be downloaded from the Dell Product support page for PowerFlex software. + type: path + default: /var/tmp + powerflex_sdr_state: + description: + - Specifies the state of SDR. + type: str + choices: ['absent', 'present'] + default: present + powerflex_protection_domain_name: + description: The name of the protection domain to which the SDR will be added. + type: str + powerflex_storage_pool_name: + description: The name of the storage pool to which the device will be added. + type: str + powerflex_sdr_repl_journal_capacity_max_ratio: + description: Maximum capacity percentage to be allocated for journal capacity. + type: int + default: 10 + powerflex_mdm_password: + required: true + type: str + description: Password for the Powerflex MDM. diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/meta/main.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/meta/main.yml new file mode 100644 index 000000000..e0280962c --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/meta/main.yml @@ -0,0 +1,21 @@ +--- +galaxy_info: + role_name: powerflex_sdr + namespace: dellemc + author: Abhishek Sinha + description: The role to manage installation and uninstallation PowerFlex SDR. + company: Dell Technologies + license: GPL-3.0-only + min_ansible_version: "2.14.0" + platforms: + - name: EL + versions: + - "9" + - "8" + - name: Ubuntu + versions: + - jammy + - name: SLES + versions: + - "15SP3" + - "15SP4" diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_installation/converge.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_installation/converge.yml new file mode 100644 index 000000000..3e4bb51fa --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_installation/converge.yml @@ -0,0 +1,30 @@ +--- +- name: Molecule Test for installation of SDR + hosts: sdr + vars_files: + - ../../../../playbooks/roles/vars_files/connection.yml + + tasks: + - name: Install and configure Powerflex SDR + ansible.builtin.import_role: + name: powerflex_sdr + vars: + powerflex_sdr_state: present + + - name: Verifying install package in check mode + ansible.builtin.assert: + that: + - powerflex_common_install_package_output.msg == "Check mode: No changes made" + when: ansible_check_mode + + - name: Verifying installation package in normal mode + ansible.builtin.assert: + that: + - " 'Installed' in powerflex_common_install_package_output.results[0]" + when: not ansible_check_mode and powerflex_common_install_package_output.changed + + - name: Verifying installation package in Idempotency mode + ansible.builtin.assert: + that: + - "'Nothing to do' in powerflex_common_install_package_output.msg" + when: not ansible_check_mode and not powerflex_common_install_package_output.changed diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_installation/molecule.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_installation/molecule.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_installation/molecule.yml @@ -0,0 +1 @@ +--- diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_installation_invalid_path_rpm/converge.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_installation_invalid_path_rpm/converge.yml new file mode 100644 index 000000000..bc5b5d3d5 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_installation_invalid_path_rpm/converge.yml @@ -0,0 +1,34 @@ +--- +- name: Molecule Test for installation of SDR with invalid rpm path, rpm file + hosts: sdr + vars_files: + - ../../../../playbooks/roles/vars_files/connection.yml + + tasks: + - name: Install and configure powerflex SDR with no rpm + ansible.builtin.import_role: + name: powerflex_sdr + vars: + powerflex_common_file_install_location: "/opt/empty" + powerflex_sdr_state: present + register: powerflex_sdr_no_rpm_result + ignore_errors: true + + - name: Verifying failure of install package with respect to no rpm file in normal mode + ansible.builtin.assert: + that: + - powerflex_common_package_file.files | length | int == 0 + + - name: Install and configure powerflex SDR with wrong file path + ansible.builtin.import_role: + name: powerflex_sdr + vars: + powerflex_common_file_install_location: "/opt/aaab" + powerflex_sdr_state: present + ignore_errors: true + register: powerflex_sdr_wrong_path_result + + - name: Verifying failure of install package with wrong file path + ansible.builtin.assert: + that: + - powerflex_common_package_file.files | length == 0 diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_installation_invalid_path_rpm/molecule.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_installation_invalid_path_rpm/molecule.yml new file mode 100644 index 000000000..93cad84c9 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_installation_invalid_path_rpm/molecule.yml @@ -0,0 +1,4 @@ +--- +scenario: + test_sequence: + - converge diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_installation_invalid_pd/converge.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_installation_invalid_pd/converge.yml new file mode 100644 index 000000000..17a448963 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_installation_invalid_pd/converge.yml @@ -0,0 +1,20 @@ +--- +- name: Molecule Test for installation of SDR + hosts: sdr + vars_files: + - ../../../../playbooks/roles/vars_files/connection.yml + + tasks: + - name: Install and configure powerflex SDR without protection domain + vars: + error_msg: "Please provide powerflex_protection_domain_name and powerflex_storage_pool_name in parameter for installing SDR." + block: + - name: Powerflex SDR + ansible.builtin.import_role: + name: dellemc.powerflex.powerflex_sdr + vars: + powerflex_sdr_state: present + rescue: + - name: Verifying failure of install package without protection domain + ansible.builtin.assert: + that: ansible_failed_result.ansible_facts.powerflex_add_sdr_output.msg == error_msg diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_installation_invalid_pd/molecule.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_installation_invalid_pd/molecule.yml new file mode 100644 index 000000000..93cad84c9 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_installation_invalid_pd/molecule.yml @@ -0,0 +1,4 @@ +--- +scenario: + test_sequence: + - converge diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_uninstallation/converge.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_uninstallation/converge.yml new file mode 100644 index 000000000..cc28cae33 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_uninstallation/converge.yml @@ -0,0 +1,66 @@ +--- +- name: SDR uninstallation + hosts: sdr + vars_files: + - ../../../../playbooks/roles/vars_files/connection.yml + + tasks: + - name: Uninstall powerflex SDR + register: powerflex_sdr_uninstall_outputs + ansible.builtin.import_role: + name: powerflex_sdr + vars: + powerflex_sdr_state: absent + + - name: Verifying uninstall package in converge + ansible.builtin.assert: + that: + - " 'Removed:' in powerflex_sdr_uninstall_output.results[0].results[0]" + when: + - not ansible_check_mode + - powerflex_sdr_uninstall_output.changed + - ansible_distribution in ("RedHat", "CentOS", "SLES") + + - name: Verifying uninstall package in check mode + ansible.builtin.assert: + that: + - powerflex_sdr_uninstall_output.msg == "Check mode: No changes made" + - powerflex_sdr_uninstall_output.changed + - ansible_distribution in ("RedHat", "CentOS", "SLES") + when: ansible_check_mode + + - name: Verifying remove the sdr in normal mode + ansible.builtin.assert: + that: + - powerflex_remove_sdr_output.sdr_details is None + when: + - not ansible_check_mode + - powerflex_remove_sdr_output.changed + - ansible_distribution == "Ubuntu" + + - name: Verifying uninstall package in Idempotency + ansible.builtin.assert: + that: + - powerflex_sdr_uninstall_output.results[0].msg == 'Nothing to do' + - ansible_distribution in ("RedHat", "CentOS", "SLES") + when: + - not ansible_check_mode + - not powerflex_sdr_uninstall_output.changed + - ansible_distribution in ("RedHat", "CentOS", "SLES") + + - name: Verifying remove the sdr in check mode + ansible.builtin.assert: + that: + - powerflex_remove_sdr_output.msg == "Check mode: No changes made" + - powerflex_remove_sdr_output.changed + - ansible_distribution == "Ubuntu" + when: ansible_check_mode + + - name: Verifying remove the sdr in Idempotency + ansible.builtin.assert: + that: + - powerflex_remove_sdr_output.sdr_details is None + when: + - not ansible_check_mode + - not powerflex_remove_sdr_output.changed + - ansible_distribution == "Ubuntu" diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_uninstallation/molecule.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_uninstallation/molecule.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/sdr_uninstallation/molecule.yml @@ -0,0 +1 @@ +--- diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/var_values.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/var_values.yml new file mode 100644 index 000000000..87df25556 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/molecule/var_values.yml @@ -0,0 +1,3 @@ +--- +powerflex_protection_domain_name: domain1 +powerflex_storage_pool_name: pool1 diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/tasks/add_sdr.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/tasks/add_sdr.yml new file mode 100644 index 000000000..1af345276 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/tasks/add_sdr.yml @@ -0,0 +1,142 @@ +--- +- name: Get configured MDM IP addresses + dellemc.powerflex.mdm_cluster: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" + validate_certs: "{{ validate_certs }}" + state: "present" + register: powerflex_sdr_mdm_ip_result + delegate_to: "{{ lookup('ansible.builtin.env', 'RUNON', default='localhost') }}" + +- name: Set fact - PowerFlex version + ansible.builtin.set_fact: + powerflex_sdr_array_version: "{{ powerflex_sdr_mdm_ip_result.mdm_cluster_details.master.versionInfo[1] }}" + +- name: Checking powerflex_protection_domain_name and powerflex_storage_pool_name is provided + ansible.builtin.set_fact: + powerflex_add_sdr_output: + msg: Please provide powerflex_protection_domain_name and powerflex_storage_pool_name in parameter for installing SDR. + failed_when: + - powerflex_protection_domain_name is undefined or powerflex_storage_pool_name is undefined + +- name: Include the sdr_set_facts.yml + ansible.builtin.include_tasks: sdr_set_facts.yml + +- name: Include install_powerflex.yml + ansible.builtin.include_tasks: ../../powerflex_common/tasks/install_powerflex.yml + +- name: Login to mdm for PowerFlex version below 4.x + ansible.builtin.command: > + scli --login --mdm_ip {{ powerflex_sdr_mdm_primary_ip }} + --username admin + --password "{{ powerflex_mdm_password }}" + --approve_certificate + run_once: true + register: powerflex_initial_login + delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}" + changed_when: powerflex_initial_login.rc == 0 + 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 + run_once: true + register: powerflex_initial_login + 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 + ansible.builtin.debug: + var: powerflex_initial_login.stdout + +- name: Set replication capacity + ansible.builtin.command: > + scli --set_replication_journal_capacity + --protection_domain_name {{ powerflex_protection_domain_name }} + --storage_pool_name {{ powerflex_storage_pool_name }} + --replication_journal_capacity_max_ratio {{ powerflex_sdr_repl_journal_capacity_max_ratio }} + run_once: true + register: powerflex_set_replication_capacity + delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}" + changed_when: powerflex_set_replication_capacity.rc == 0 + +- name: Wait for replication capacity to be created + ansible.builtin.pause: + seconds: 60 + run_once: true + delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}" + +- name: Get replication capacity + ansible.builtin.command: > + scli --query_all_replication_journal_capacity + --protection_domain_name {{ powerflex_protection_domain_name }} + run_once: true + delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}" + register: powerflex_get_replication_capacity + changed_when: powerflex_get_replication_capacity.rc == 0 + +- name: Checking if SDR already exists or not for PowerFlex version below 4.x + ansible.builtin.command: > + scli --mdm_ip {{ powerflex_sdr_mdm_primary_ip }} + --query_sdr + --sdr_name "{{ powerflex_sdr_hostname }}" + delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}" + register: check_sdr_exists + changed_when: check_sdr_exists.rc == 0 + failed_when: false + when: powerflex_sdr_array_version == "3" + +- name: Checking if SDR already exists or not for PowerFlex version 4.x + ansible.builtin.command: > + scli --management_system_ip {{ hostname }} + --query_sdr + --sdr_name "{{ powerflex_sdr_hostname }}" + delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}" + register: check_sdr_exists + changed_when: check_sdr_exists.rc == 0 + failed_when: false + when: powerflex_sdr_array_version != "3" + +- name: Skipping add SDR if already exists + ansible.builtin.debug: + msg: "SDR name {{ powerflex_sdr_hostname }} already exists, will skip adding SDR." + when: check_sdr_exists.rc == 0 + delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}" + +- name: Adding SDR for PowerFlex version below 4.x + ansible.builtin.command: > + scli --add_sdr --mdm_ip {{ powerflex_sdr_mdm_primary_ip }} + --sdr_ip_role all + --sdr_ip {{ powerflex_sdr_ip }} + --sdr_name "{{ powerflex_sdr_hostname }}" + --protection_domain_name {{ powerflex_protection_domain_name }} + register: powerflex_add_sdr_output + delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}" + changed_when: powerflex_add_sdr_output.rc == 0 + when: check_sdr_exists.rc == 7 and powerflex_sdr_array_version == "3" + +- name: Adding SDR for PowerFlex version 4.x + ansible.builtin.command: > + scli --add_sdr --management_system_ip {{ hostname }} + --sdr_ip_role all + --sdr_ip {{ powerflex_sdr_ip }} + --sdr_name "{{ powerflex_sdr_hostname }}" + --protection_domain_name {{ powerflex_protection_domain_name }} + register: powerflex_add_sdr_output + delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}" + changed_when: powerflex_add_sdr_output.rc == 0 + when: check_sdr_exists.rc == 7 and powerflex_sdr_array_version != "3" + +- name: Logging out of the mdm + ansible.builtin.command: scli --logout + register: powerflex_mdm_logout + delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}" + changed_when: powerflex_mdm_logout.rc == 0 + run_once: true diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/tasks/main.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/tasks/main.yml new file mode 100644 index 000000000..440173b8d --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/tasks/main.yml @@ -0,0 +1,8 @@ +--- +- name: Add SDR + ansible.builtin.include_tasks: add_sdr.yml + when: powerflex_sdr_state == 'present' + +- name: Remove SDR + ansible.builtin.include_tasks: remove_sdr.yml + when: powerflex_sdr_state == 'absent' diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/tasks/remove_sdr.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/tasks/remove_sdr.yml new file mode 100644 index 000000000..3bf33b6ea --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/tasks/remove_sdr.yml @@ -0,0 +1,120 @@ +--- +- name: Get configured MDM IP addresses + dellemc.powerflex.mdm_cluster: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" + validate_certs: "{{ validate_certs }}" + state: "present" + register: powerflex_sdr_mdm_ip_result + delegate_to: "{{ lookup('ansible.builtin.env', 'RUNON', default='localhost') }}" + +- name: Set fact - PowerFlex version + ansible.builtin.set_fact: + powerflex_sdr_array_version: "{{ powerflex_sdr_mdm_ip_result.mdm_cluster_details.master.versionInfo[1] }}" + +- name: Include the sdr_set_facts.yml + ansible.builtin.include_tasks: sdr_set_facts.yml + +- name: Login to mdm for PowerFlex version below 4.x + ansible.builtin.command: > + scli --login --mdm_ip {{ powerflex_sdr_mdm_primary_ip }} + --username admin + --password "{{ powerflex_mdm_password }}" + --approve_certificate + run_once: true + register: powerflex_initial_login + delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}" + changed_when: powerflex_initial_login.rc == 0 + 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 + run_once: true + register: powerflex_initial_login + 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 + ansible.builtin.debug: + var: powerflex_initial_login.stdout + delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}" + +- name: Checking if SDR already exists or not for PowerFlex version below 4.x + ansible.builtin.command: > + scli --mdm_ip {{ powerflex_sdr_mdm_primary_ip }} + --query_sdr + --sdr_name "{{ powerflex_sdr_hostname }}" + delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}" + register: check_sdr_exists + failed_when: false + changed_when: check_sdr_exists.rc == 0 + when: powerflex_sdr_array_version == "3" + +- name: Checking if SDR already exists or not for PowerFlex version 4.x + ansible.builtin.command: > + scli --management_system_ip {{ hostname }} + --query_sdr + --sdr_name "{{ powerflex_sdr_hostname }}" + delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}" + register: check_sdr_exists + failed_when: false + changed_when: check_sdr_exists.rc == 0 + when: powerflex_sdr_array_version != "3" + +- name: Skipping remove SDR if does not exist + ansible.builtin.debug: + msg: "SDR name {{ powerflex_sdr_hostname }} does not exist, will skip removing SDR." + when: check_sdr_exists.rc == 7 + delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}" + +- name: Removing SDR for PowerFlex version below 4.x + ansible.builtin.command: > + scli --remove_sdr --mdm_ip {{ powerflex_sdr_mdm_primary_ip }} + --sdr_name "{{ powerflex_sdr_hostname }}" + register: powerflex_remove_sdr_output + delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}" + changed_when: powerflex_remove_sdr_output.rc == 0 + when: check_sdr_exists.rc == 0 and powerflex_sdr_array_version == "3" + +- name: Removing SDR for PowerFlex version 4.x + ansible.builtin.command: > + scli --remove_sdr --management_system_ip {{ hostname }} + --sdr_name "{{ powerflex_sdr_hostname }}" + register: powerflex_remove_sdr_output + delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}" + changed_when: powerflex_remove_sdr_output.rc == 0 + when: check_sdr_exists.rc == 0 and powerflex_sdr_array_version != "3" + +- name: Uninstall package + register: powerflex_sdr_uninstall_output + environment: + I_AM_SURE: "{{ i_am_sure | int }}" + ansible.builtin.package: + name: "{{ item }}" + state: "absent" + with_items: + - EMC-ScaleIO-sdr + when: ansible_distribution in ("RedHat", "CentOS", "SLES") + +- name: Uninstall deb package + ansible.builtin.apt: + name: "{{ item }}" + state: absent + with_items: + - emc-scaleio-sdr + when: ansible_distribution == "Ubuntu" + +- name: Logging out of the mdm + ansible.builtin.command: scli --logout + register: powerflex_mdm_logout + run_once: true + delegate_to: "{{ powerflex_sdr_mdm_primary_hostname }}" + changed_when: powerflex_mdm_logout.rc == 0 diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/tasks/sdr_set_facts.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/tasks/sdr_set_facts.yml new file mode 100644 index 000000000..086b8b5bd --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/tasks/sdr_set_facts.yml @@ -0,0 +1,7 @@ +--- +- name: Set facts for powerflex primary ip and hostname for mdm and sdr + ansible.builtin.set_fact: + powerflex_sdr_mdm_primary_ip: "{{ hostvars[groups['mdm'][0]]['ansible_host'] }}" + powerflex_sdr_mdm_primary_hostname: "{{ hostvars[groups['mdm'][0]]['inventory_hostname'] }}" + powerflex_sdr_ip: "{{ hostvars[inventory_hostname]['ansible_host'] }}" + powerflex_sdr_hostname: "{{ inventory_hostname }}" diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/vars/main.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/vars/main.yml new file mode 100644 index 000000000..6a0f1ad81 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_sdr/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for powerflex_sdr |