diff options
Diffstat (limited to 'ansible_collections/dellemc/powerflex/roles/powerflex_mdm')
21 files changed, 903 insertions, 0 deletions
diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/README.md b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/README.md new file mode 100644 index 000000000..aa54a27a0 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/README.md @@ -0,0 +1,142 @@ +# powerflex_mdm + +Role to manage the installation and uninstallation of Powerflex MDM. + +## Table of contents + +* [Requirements](#requirements) +* [Ansible collections](#ansible-collections) +* [Role Variables](#role-variables) +* [Examples](#examples) +* [Usage instructions](#usage-instructions) +* [Notes](#notes) +* [Author Information](#author-information) + +## Requirements + +``` +ansible +python +``` + +## Ansible collections + +Collections required to use the role. + +``` +dellemc.powerflex +ansible.posix +community.general +``` + +## 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>true</td> + <td>Location of installation and rpm gpg files to be installed. + <br> The 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>str</td> + <td>/var/tmp</td> + </tr> + <tr> + <td>powerflex_mdm_password</td> + <td>true</td> + <td>Password for mdm cluster.<br></td> + <td></td> + <td>str</td> + <td>Password123</td> + </tr> + <tr> + <td>powerflex_mdm_state</td> + <td>false</td> + <td>Specify state of MDM.<br></td> + <td>absent, present</td> + <td>str</td> + <td>present</td> + </tr> + <tr> + <td>powerflex_mdm_virtual_ip</td> + <td>false</td> + <td>Virtual IP address of MDM.<br></td> + <td></td> + <td>str</td> + <td></td> + </tr> + <tr> + <td>powerflex_mdm_cert_password</td> + <td>false</td> + <td>The password to generate the certificate cli. + <br>Required while installing MDM for Powerlex 4.x.<br></td> + <td></td> + <td>str</td> + <td>Password123!</td> + </tr> +</tbody> +</table> + +## Examples +---- +``` + - name: "Install and configure powerflex mdm" + ansible.builtin.import_role: + name: "powerflex_mdm" + vars: + powerflex_common_file_install_location: "/opt/scaleio/rpm" + powerflex_mdm_password: password + powerflex_mdm_state: present + + - name: "Uninstall powerflex mdm" + ansible.builtin.import_role: + name: "powerflex_mdm" + vars: + powerflex_mdm_state: absent + +``` + +## Usage instructions +---- +### To install all dependency packages, including mdm, on node: +- PowerFlex 3.6: + ``` + ansible-playbook -i inventory site.yml + ``` +- PowerFlex 4.5: + ``` + ansible-playbook -i inventory site_powerflex45.yml + ``` + +### To uninstall mdm: +- 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. + +## Notes +- The ```community.general``` collection must be installed for MDM installation on SLES OS. + +## Author Information +------------------ + +Dell Technologies <br> +Bhavneet Sharma (ansible.team@Dell.com) 2023 diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/defaults/main.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/defaults/main.yml new file mode 100644 index 000000000..340da8bb8 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/defaults/main.yml @@ -0,0 +1,9 @@ +--- +# Skip Java installation for powerflex (assume it's on the system) +powerflex_skip_java: false +powerflex_mdm_primary_hostname: '' +powerflex_mdm_primary_ip: '' +powerflex_role_environment: + MDM_IP: "{{ powerflex_mdm_ips }}" + MDM_ROLE_IS_MANAGER: 1 +file_glob_name: mdm diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/meta/argument_spec.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/meta/argument_spec.yml new file mode 100644 index 000000000..be80c1970 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/meta/argument_spec.yml @@ -0,0 +1,28 @@ +--- +argument_specs: + main: + version_added: "1.8.0" + short_description: Role to manage the installation and uninstallation of Powerflex MDM + description: + - Role to manage the installation and uninstallation of Powerflex MDM. + options: + powerflex_mdm_state: + required: true + type: str + description: State of the Powerflex MDM. + powerflex_mdm_password: + required: true + type: str + description: Password for the Powerflex MDM. + powerflex_common_file_install_location: + required: true + type: str + description: Common file installation location. + powerflex_mdm_virtual_ip: + type: str + description: Virtual IP address of MDM. + powerflex_mdm_cert_password: + type: str + description: + - Password to generate cli certificate for MDM. + - Required while installing MDM for Powerlex 4.x. diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/meta/main.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/meta/main.yml new file mode 100644 index 000000000..889114f46 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/meta/main.yml @@ -0,0 +1,29 @@ +--- +galaxy_info: + author: Bhavneet Sharma + description: Role to manage the installation and uninstallation of Powerflex MDM. + company: Dell Technologies + role_name: powerflex_mdm + namespace: dellemc + + 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" + + galaxy_tags: [] +dependencies: + - role: powerflex_common diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/molecule/mdm_installation/converge.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/molecule/mdm_installation/converge.yml new file mode 100644 index 000000000..707de56fe --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/molecule/mdm_installation/converge.yml @@ -0,0 +1,63 @@ +--- +- name: MDM installation + hosts: mdm + vars_files: + - ../../../../playbooks/roles/vars_files/connection.yml + tasks: + - name: Install common packages + ansible.builtin.import_role: + name: powerflex_common + + - name: Install and configure Powerflex MDM + ansible.builtin.import_role: + name: powerflex_mdm + vars: + powerflex_mdm_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 add primary mdm in normal mode + ansible.builtin.assert: + that: + - "'Successfully created the MDM Cluster' in powerflex_mdm_add_primary_output.stdout" + when: not ansible_check_mode and powerflex_mdm_add_primary_output.changed + + - name: Verifying add secondary mdm in normal mode + ansible.builtin.assert: + that: + - "'Successfully added a standby MDM' in powerflex_mdm_add_secondary_output.stdout" + when: not ansible_check_mode and powerflex_mdm_add_secondary_output.changed + + - name: Verifying add tertiary mdm in normal mode + ansible.builtin.assert: + that: + - "'Successfully added a standby MDM' in powerflex_mdm_add_tertiary_output.stdout" + when: not ansible_check_mode and powerflex_mdm_add_tertiary_output.changed + + - name: Verifying primary mdm configuration in Idempotency + ansible.builtin.assert: + that: + - "'The Primary MDM is already configured' in powerflex_mdm_add_primary_output.stderr_lines[0]" + when: not ansible_check_mode and not powerflex_mdm_add_primary_output.changed + + - name: Verifying secondary mdm configuration in Idempotency + ansible.builtin.assert: + that: + - "'An MDM with the same name already exists' in powerflex_mdm_add_secondary_output.stderr_lines[0]" + when: not ansible_check_mode and not powerflex_mdm_add_secondary_output.changed + + - name: Verifying tertiary mdm configuration in Idempotency + ansible.builtin.assert: + that: + - "'An MDM with the same name already exists' in powerflex_mdm_add_tertiary_output.stderr_lines[0]" + when: not ansible_check_mode and powerflex_mdm_tertiary_ip is defined and not powerflex_mdm_add_tertiary_output.changed diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/molecule/mdm_installation/molecule.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/molecule/mdm_installation/molecule.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/molecule/mdm_installation/molecule.yml @@ -0,0 +1 @@ +--- diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/molecule/mdm_uninstallation/converge.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/molecule/mdm_uninstallation/converge.yml new file mode 100644 index 000000000..ede8baf5a --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/molecule/mdm_uninstallation/converge.yml @@ -0,0 +1,53 @@ +--- +- name: MDM uninstallation + hosts: mdm + vars_files: + - ../../../../playbooks/roles/vars_files/connection.yml + tasks: + - name: Uninstall powerflex MDM + ansible.builtin.import_role: + name: powerflex_mdm + vars: + powerflex_mdm_state: 'absent' + + - name: Verifying uninstall package in check mode + ansible.builtin.assert: + that: + - powerflex_mdm_uninstall_output.msg == "Check mode: No changes made" + when: ansible_check_mode + + - name: Verifying remove secondary mdm in normal mode + ansible.builtin.assert: + that: + - "'Successfully removed the standby MDM' in powerflex_mdm_remove_secondary.stdout" + when: not ansible_check_mode and powerflex_mdm_remove_secondary.changed + + - name: Verifying remove tertiary mdm in normal mode + ansible.builtin.assert: + that: + - "'Successfully removed the standby MDM' in powerflex_mdm_remove_tertiary.stdout" + when: not ansible_check_mode and powerflex_mdm_tertiary_ip is defined and powerflex_mdm_remove_tertiary.changed + + - name: Verifying uninstall package in normal mode + ansible.builtin.assert: + that: + - "'Removed: EMC-ScaleIO-mdm' in powerflex_mdm_uninstall_output.results[0].results[0]" + when: not ansible_check_mode and powerflex_mdm_uninstall_output.changed + + - name: Verifying remove secondary mdm in Idempotency + ansible.builtin.assert: + that: + - "'No such file or directory' in powerflex_mdm_remove_secondary.msg" + when: not ansible_check_mode and not powerflex_mdm_remove_secondary.changed + + - name: Verifying remove tertiary mdm in Idempotency + ansible.builtin.assert: + that: + - "'No such file or directory' in powerflex_mdm_remove_tertiary.msg" + when: not ansible_check_mode and powerflex_mdm_tertiary_ip is defined and not powerflex_mdm_remove_tertiary.changed + + - name: Verifying uninstall package in Idempotency + ansible.builtin.assert: + that: + - "'Nothing to do' in powerflex_mdm_uninstall_output.results[0].msg" + when: not ansible_check_mode and not powerflex_mdm_uninstall_output.changed diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/molecule/mdm_uninstallation/molecule.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/molecule/mdm_uninstallation/molecule.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/molecule/mdm_uninstallation/molecule.yml @@ -0,0 +1 @@ +--- diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/add_certs.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/add_certs.yml new file mode 100644 index 000000000..f517d5229 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/add_certs.yml @@ -0,0 +1,168 @@ +--- +- name: Generate CA certificate + register: powerflex_mdm_generate_mgmt_ca_cert + ansible.builtin.command: python3 certificate_generator_MDM_USER.py --generate_ca mgmt_ca.pem + args: + chdir: /opt/emc/scaleio/mdm/cfg + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + changed_when: powerflex_mdm_generate_mgmt_ca_cert.rc == 0 + +- name: Create CLI certificate + register: powerflex_mdm_generate_cli_cert + ansible.builtin.command: > + python3 certificate_generator_MDM_USER.py --generate_cli cli_certificate.p12 -CA mgmt_ca.pem --password {{ powerflex_mdm_cert_password }} + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + args: + chdir: /opt/emc/scaleio/mdm/cfg + changed_when: powerflex_mdm_generate_cli_cert.rc == 0 + +- name: Create MDM certificate + register: powerflex_mdm_generate_mdm_cert + ansible.builtin.command: python3 certificate_generator_MDM_USER.py --generate_mdm mdm_certificate.pem -CA mgmt_ca.pem + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + args: + chdir: /opt/emc/scaleio/mdm/cfg + changed_when: powerflex_mdm_generate_mdm_cert.rc == 0 + +- name: Create additional MDM certificates + register: powerflex_mdm_generate_additional_mdm_cert + ansible.builtin.command: python3 certificate_generator_MDM_USER.py --generate_mdm sec_mdm_certificate.pem -CA mgmt_ca.pem + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + args: + chdir: /opt/emc/scaleio/mdm/cfg + changed_when: powerflex_mdm_generate_additional_mdm_cert.rc == 0 + +- name: Fetch all certs to localhost + register: powerflex_mdm_fetch_certs + ansible.builtin.fetch: + src: /opt/emc/scaleio/mdm/cfg/{{ item }} + dest: /tmp/ + flat: true + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + with_items: + - sec_mdm_certificate.pem + - cli_certificate.p12 + - mgmt_ca.pem + +- name: Copy MDM certificates to Secondary manager MDM node + register: powerflex_mdm_copy_additional_certs_to_secondary + ansible.builtin.copy: + src: /tmp/sec_mdm_certificate.pem + dest: /opt/emc/scaleio/mdm/cfg/mdm_certificate.pem + mode: preserve + delegate_to: "{{ powerflex_mdm_secondary_hostname }}" + when: powerflex_mdm_secondary_ip is defined + +- name: Copy CLI certificates to Secondary manager MDM node + register: powerflex_mdm_copy_cli_certs_to_secondary + ansible.builtin.copy: + src: /tmp/cli_certificate.p12 + dest: /opt/emc/scaleio/mdm/cfg/cli_certificate.p12 + mode: preserve + delegate_to: "{{ powerflex_mdm_secondary_hostname }}" + when: powerflex_mdm_secondary_ip is defined + +- name: Copy mgmt_ca.pem certificates to Secondary manager MDM node + register: powerflex_mdm_copy_mgmt_certs_to_secondary + ansible.builtin.copy: + src: /tmp/mgmt_ca.pem + dest: /opt/emc/scaleio/mdm/cfg/mgmt_ca.pem + mode: preserve + delegate_to: "{{ powerflex_mdm_secondary_hostname }}" + when: powerflex_mdm_secondary_ip is defined + +- name: Copy MDM certificates to Tertiary manager MDM node + register: powerflex_mdm_copy_additional_certs_to_tertiary + ansible.builtin.copy: + src: /tmp/sec_mdm_certificate.pem + dest: /opt/emc/scaleio/mdm/cfg/mdm_certificate.pem + mode: preserve + delegate_to: "{{ powerflex_mdm_tertiary_hostname }}" + when: powerflex_mdm_tertiary_ip is defined + +- name: Copy CLI certificates to Tertiary manager MDM node + register: powerflex_mdm_copy_cli_certs_to_tertiary + ansible.builtin.copy: + src: /tmp/cli_certificate.p12 + dest: /opt/emc/scaleio/mdm/cfg/cli_certificate.p12 + mode: preserve + delegate_to: "{{ powerflex_mdm_tertiary_hostname }}" + when: powerflex_mdm_tertiary_ip is defined + +- name: Copy mgmt_ca.pem certificates to Tertiary manager MDM node + register: powerflex_mdm_copy_mgmt_certs_to_tertiary + ansible.builtin.copy: + src: /tmp/mgmt_ca.pem + dest: /opt/emc/scaleio/mdm/cfg/mgmt_ca.pem + mode: preserve + delegate_to: "{{ powerflex_mdm_tertiary_hostname }}" + when: powerflex_mdm_tertiary_ip is defined + +- name: Add CA certificate on primary MDM + register: powerflex_mdm_add_mgmt_cert_to_ca_primary + ansible.builtin.command: scli --add_certificate --certificate_file mgmt_ca.pem + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + args: + chdir: /opt/emc/scaleio/mdm/cfg + changed_when: powerflex_mdm_add_mgmt_cert_to_ca_primary.rc == 0 + +- name: Add CA certificate on secondary MDM + register: powerflex_mdm_add_mgmt_cert_to_ca_secondary + ansible.builtin.command: scli --add_certificate --certificate_file mgmt_ca.pem + delegate_to: "{{ powerflex_mdm_secondary_hostname }}" + when: powerflex_mdm_secondary_ip is defined + args: + chdir: /opt/emc/scaleio/mdm/cfg + changed_when: powerflex_mdm_add_mgmt_cert_to_ca_secondary.rc == 0 + +- name: Add CA certificate on tertiary MDM + register: powerflex_mdm_add_mgmt_cert_to_ca_tertiary + ansible.builtin.command: scli --add_certificate --certificate_file mgmt_ca.pem + delegate_to: "{{ powerflex_mdm_tertiary_hostname }}" + when: powerflex_mdm_tertiary_ip is defined + args: + chdir: /opt/emc/scaleio/mdm/cfg + changed_when: powerflex_mdm_add_mgmt_cert_to_ca_tertiary.rc == 0 + +- name: Start MDM service on primary MDM + register: powerflex_mdm_start_service_primary + ansible.builtin.service: + name: "mdm.service" + state: "restarted" + enabled: true + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + +- name: Start MDM service on secondary MDM + register: powerflex_mdm_start_service_secondary + ansible.builtin.service: + name: "mdm.service" + state: "restarted" + enabled: true + delegate_to: "{{ powerflex_mdm_secondary_hostname }}" + when: powerflex_mdm_secondary_ip is defined + +- name: Start MDM service on tertiary MDM + register: powerflex_mdm_start_service_tertiary + ansible.builtin.service: + name: "mdm.service" + state: "restarted" + enabled: true + delegate_to: "{{ powerflex_mdm_tertiary_hostname }}" + when: powerflex_mdm_tertiary_ip is defined + +- name: Check MDM service status + register: powerflex_mdm_check_service + ansible.builtin.command: systemctl status mdm.service + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + changed_when: powerflex_mdm_check_service.rc == 0 + +- name: Delete certificates from localhost + register: powerflex_mdm_delete_localhost_certs + ansible.builtin.file: + path: /tmp/{{ item }} + state: absent + with_items: + - sec_mdm_certificate.pem + - cli_certificate.p12 + - mgmt_ca.pem + delegate_to: "{{ lookup('ansible.builtin.env', 'RUNON', default='localhost') }}" diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/install_mdm.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/install_mdm.yml new file mode 100644 index 000000000..76bbba5a6 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/install_mdm.yml @@ -0,0 +1,32 @@ +--- +- name: Include the mdm_set_facts.yml + ansible.builtin.include_tasks: "mdm_set_facts.yml" + +- name: Include vars + ansible.builtin.include_vars: "../vars/{{ ansible_distribution }}.yml" + +- name: Pre-requisite on rhel6 based os + ansible.posix.sysctl: + name: kernel.shmmax + value: 209715200 + when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "6" + +- name: List the rpm file + register: powerflex_mdm_package_file_version + ansible.builtin.find: + paths: "{{ powerflex_common_file_install_location }}" + patterns: "*{{ file_glob_name }}*.rpm" + delegate_to: "{{ lookup('ansible.builtin.env', 'RUNON', default='localhost') }}" + +- name: Extract file versions + ansible.builtin.set_fact: + version: "{{ powerflex_mdm_package_file_version.files[0].path | regex_search('mdm-(\\d+)', '\\1') }}" + when: powerflex_mdm_package_file_version.files | length > 0 + +- name: Install MDM for PowerFlex below 4.x + ansible.builtin.include_tasks: install_powerflex3x_mdm.yml + when: version[0] < "4" + +- name: Install MDM for PowerFlex 4.x + ansible.builtin.include_tasks: install_powerflex4x_mdm.yml + when: version[0] >= "4" diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/install_powerflex3x_mdm.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/install_powerflex3x_mdm.yml new file mode 100644 index 000000000..178bd8696 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/install_powerflex3x_mdm.yml @@ -0,0 +1,128 @@ +--- +- name: Include install_powerflex.yml + ansible.builtin.include_tasks: ../../powerflex_common/tasks/install_powerflex.yml + +- name: Wait for MDM to be active + ansible.builtin.wait_for: + port: 9011 + state: started + run_once: true + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + +- name: Add primary MDM with virtual ip + ansible.builtin.command: > + scli --create_mdm_cluster + --master_mdm_ip {{ powerflex_mdm_primary_ip }} + --master_mdm_management_ip {{ powerflex_mdm_primary_ip }} + --master_mdm_name {{ powerflex_mdm_primary_hostname }} + --master_mdm_virtual_ip_interface {{ ansible_default_ipv4.interface }} + --cluster_virtual_ip {{ powerflex_mdm_virtual_ip }} + --accept_license --approve_certificate + run_once: true + register: powerflex_mdm_add_primary_output + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + until: ("{{ powerflex_mdm_add_primary_output.rc }} == 0") or ("{{ powerflex_mdm_add_primary_output.rc }} == 7") + ignore_errors: true + when: + - powerflex_mdm_virtual_ip is defined + - powerflex_mdm_virtual_ip | length > 0 + changed_when: powerflex_mdm_add_primary_output.rc == 0 + +- name: Add primary MDM without virtual ip + ansible.builtin.command: > + scli --create_mdm_cluster + --master_mdm_ip {{ powerflex_mdm_primary_ip }} + --master_mdm_management_ip {{ powerflex_mdm_primary_ip }} + --master_mdm_name {{ powerflex_mdm_primary_hostname }} + --master_mdm_virtual_ip_interface {{ ansible_default_ipv4.interface }} + --accept_license --approve_certificate + run_once: true + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + until: ("{{ powerflex_mdm_add_primary_output.rc }} == 0") or ("{{ powerflex_mdm_add_primary_output.rc }} == 7") + register: powerflex_mdm_add_primary_output + ignore_errors: true + when: + - powerflex_mdm_virtual_ip | length == 0 + changed_when: powerflex_mdm_add_primary_output.rc == 0 + +- name: Wait for MDM to be active + ansible.builtin.wait_for: + port: 6611 + state: started + run_once: true + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + +- name: Initial login to primary MDM + ansible.builtin.command: scli --login --username admin --password admin + run_once: true + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + ignore_errors: true + register: powerflex_mdm_initial_login + changed_when: powerflex_mdm_initial_login.rc == 0 + +- name: Login with new password primary MDM + ansible.builtin.command: > + scli --login --username admin --password "{{ powerflex_mdm_password }}" + run_once: true + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + when: powerflex_mdm_initial_login.rc == 7 + changed_when: powerflex_mdm_initial_login.rc == 0 + +- name: Set password for MDM cluster + ansible.builtin.command: > + scli --set_password --old_password admin + --new_password "{{ powerflex_mdm_password }}" + run_once: true + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + when: powerflex_mdm_initial_login.rc == 0 + changed_when: powerflex_mdm_initial_login.rc == 0 + +- name: Secondary node login + ansible.builtin.command: > + scli --login --mdm_ip {{ powerflex_mdm_primary_ip }} + --username admin --password {{ powerflex_mdm_password }} --approve_certificate + run_once: true + register: powerflex_mdm_secondary_login + changed_when: powerflex_mdm_secondary_login.rc == 0 + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + +- name: Add secondary MDM + ansible.builtin.command: > + scli --add_standby_mdm + --new_mdm_ip {{ powerflex_mdm_secondary_ip }} + --mdm_role manager + --new_mdm_name {{ powerflex_mdm_secondary_hostname }} + --new_mdm_management_ip {{ powerflex_mdm_secondary_ip }} + --new_mdm_virtual_ip_interface {{ ansible_default_ipv4.interface }} + --approve_certificate + run_once: true + register: powerflex_mdm_add_secondary_output + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + ignore_errors: true + changed_when: powerflex_mdm_add_secondary_output.rc == 0 + +- name: Tertiary node login + ansible.builtin.command: > + scli --login --mdm_ip {{ powerflex_mdm_primary_ip }} --username admin + --password {{ powerflex_mdm_password }} --approve_certificate + run_once: true + delegate_to: "{{ powerflex_mdm_tertiary_hostname }}" + when: powerflex_mdm_tertiary_ip is defined + register: powerflex_mdm_tertiary_login + changed_when: powerflex_mdm_tertiary_login.rc == 0 + +- name: Add tertiary MDM + ansible.builtin.command: > + scli --add_standby_mdm + --new_mdm_ip {{ powerflex_mdm_tertiary_ip }} + --mdm_role manager + --new_mdm_name {{ powerflex_mdm_tertiary_hostname }} + --new_mdm_management_ip {{ powerflex_mdm_tertiary_ip }} + --new_mdm_virtual_ip_interface {{ ansible_default_ipv4.interface }} + --approve_certificate + run_once: true + register: powerflex_mdm_add_tertiary_output + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + ignore_errors: true + when: powerflex_mdm_tertiary_ip is defined + changed_when: powerflex_mdm_add_tertiary_output.rc == 0 diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/install_powerflex4x_mdm.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/install_powerflex4x_mdm.yml new file mode 100644 index 000000000..67164337d --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/install_powerflex4x_mdm.yml @@ -0,0 +1,101 @@ +--- +- name: Install java + ansible.builtin.include_tasks: "../../powerflex_common/tasks/install_java_{{ ansible_distribution }}.yml" + +- name: Include install_powerflex.yml + ansible.builtin.include_tasks: ../../powerflex_common/tasks/install_powerflex.yml + +- name: Include the add_certs.yml + ansible.builtin.include_tasks: add_certs.yml + +- name: Add primary MDM with virtual ip + ansible.builtin.command: > + scli --create_mdm_cluster + --primary_mdm_ip {{ powerflex_mdm_primary_ip }} + --primary_mdm_management_ip {{ powerflex_mdm_primary_ip }} + --primary_mdm_name {{ powerflex_mdm_primary_hostname }} + --primary_mdm_virtual_ip_interface {{ ansible_default_ipv4.interface }} + --cluster_virtual_ip {{ powerflex_mdm_virtual_ip }} + --accept_license --approve_certificate + run_once: true + register: powerflex_mdm_add_primary_output + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + until: ("{{ powerflex_mdm_add_primary_output.rc }} == 0") or ("{{ powerflex_mdm_add_primary_output.rc }} == 7") + ignore_errors: true + when: + - powerflex_mdm_virtual_ip is defined + - powerflex_mdm_virtual_ip | length > 0 + changed_when: powerflex_mdm_add_primary_output.rc == 0 + +- name: Add primary MDM without virtual ip + ansible.builtin.command: > + scli --create_mdm_cluster + --primary_mdm_ip {{ powerflex_mdm_primary_ip }} + --primary_mdm_management_ip {{ powerflex_mdm_primary_ip }} + --primary_mdm_name {{ powerflex_mdm_primary_hostname }} + --primary_mdm_virtual_ip_interface {{ ansible_default_ipv4.interface }} + --accept_license --approve_certificate + run_once: true + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + until: ("{{ powerflex_mdm_add_primary_output.rc }} == 0") or ("{{ powerflex_mdm_add_primary_output.rc }} == 7") + register: powerflex_mdm_add_primary_output + ignore_errors: true + when: + - powerflex_mdm_virtual_ip | length == 0 + changed_when: powerflex_mdm_add_primary_output.rc == 0 + +- name: Wait for MDM to be active + ansible.builtin.wait_for: + port: 8611 + state: started + run_once: true + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + +- name: Login to primary MDM node + register: powerflex_mdm_secondary_login + ansible.builtin.command: > + scli --login --p12_path /opt/emc/scaleio/mdm/cfg/cli_certificate.p12 --p12_password {{ powerflex_mdm_cert_password }} + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + run_once: true + when: powerflex_mdm_secondary_ip is defined + changed_when: powerflex_mdm_secondary_login.rc == 0 + +- name: Add secondary MDM + ansible.builtin.command: > + scli --add_standby_mdm + --new_mdm_ip {{ powerflex_mdm_secondary_ip }} + --mdm_role manager + --new_mdm_name {{ powerflex_mdm_secondary_hostname }} + --new_mdm_management_ip {{ powerflex_mdm_secondary_ip }} + --new_mdm_virtual_ip_interface {{ ansible_default_ipv4.interface }} + --approve_certificate + run_once: true + register: powerflex_mdm_add_secondary_output + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + ignore_errors: true + changed_when: powerflex_mdm_add_secondary_output.rc == 0 + +- name: Login to Primary MDM node + register: powerflex_mdm_tertiary_login + ansible.builtin.command: > + scli --login --p12_path /opt/emc/scaleio/mdm/cfg/cli_certificate.p12 --p12_password {{ powerflex_mdm_cert_password }} + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + run_once: true + when: powerflex_mdm_tertiary_ip is defined + changed_when: powerflex_mdm_tertiary_login.rc == 0 + +- name: Add tertiary MDM + ansible.builtin.command: > + scli --add_standby_mdm + --new_mdm_ip {{ powerflex_mdm_tertiary_ip }} + --mdm_role manager + --new_mdm_name {{ powerflex_mdm_tertiary_hostname }} + --new_mdm_management_ip {{ powerflex_mdm_tertiary_ip }} + --new_mdm_virtual_ip_interface {{ ansible_default_ipv4.interface }} + --approve_certificate + run_once: true + register: powerflex_mdm_add_tertiary_output + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + ignore_errors: true + when: powerflex_mdm_tertiary_ip is defined + changed_when: powerflex_mdm_add_tertiary_output.rc == 0 diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/main.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/main.yml new file mode 100644 index 000000000..a5e2703ac --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/main.yml @@ -0,0 +1,8 @@ +--- +- name: Install and Configure MDM cluster + ansible.builtin.include_tasks: install_mdm.yml + when: powerflex_mdm_state == "present" + +- name: Uninstall MDM cluster + ansible.builtin.include_tasks: remove_mdm.yml + when: powerflex_mdm_state == "absent" diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/mdm_set_facts.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/mdm_set_facts.yml new file mode 100644 index 000000000..c24b889eb --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/mdm_set_facts.yml @@ -0,0 +1,40 @@ +--- +- name: Set facts for MDM counts + ansible.builtin.set_fact: + mdm_count: "{{ groups['mdm'] | length }}" + +- name: Set facts for powerflex_mdm_primary_ip + ansible.builtin.set_fact: + powerflex_mdm_primary_ip: "{{ hostvars[groups['mdm'][0]]['ansible_host'] }}" + +- name: Set facts for powerflex_mdm_primary_hostname + ansible.builtin.set_fact: + powerflex_mdm_primary_hostname: "{{ hostvars[groups['mdm'][0]]['inventory_hostname'] }}" + +- name: Set facts for powerflex_mdm_secondary_ip + ansible.builtin.set_fact: + powerflex_mdm_secondary_ip: "{{ hostvars[groups['mdm'][1]]['ansible_host'] }}" + +- name: Set facts for powerflex_mdm_secondary_hostname + ansible.builtin.set_fact: + powerflex_mdm_secondary_hostname: "{{ hostvars[groups['mdm'][1]]['inventory_hostname'] }}" + +- name: Set facts for powerflex_mdm_tertiary_ip + ansible.builtin.set_fact: + powerflex_mdm_tertiary_ip: "{{ hostvars[groups['mdm'][2]]['ansible_host'] }}" + when: mdm_count | int > 2 + +- name: Set facts for powerflex_mdm_tertiary_hostname + ansible.builtin.set_fact: + powerflex_mdm_tertiary_hostname: "{{ hostvars[groups['mdm'][2]]['inventory_hostname'] }}" + when: mdm_count | int > 2 + +- name: Set facts for powerflex_mdm_ips if mdm_count is 2 + ansible.builtin.set_fact: + powerflex_mdm_ips: "{{ powerflex_mdm_secondary_ip }},{{ powerflex_mdm_primary_ip }}" + when: mdm_count | int == 2 + +- name: Set facts for powerflex_mdm_ips if mdm_count is more than 2 + ansible.builtin.set_fact: + powerflex_mdm_ips: "{{ powerflex_mdm_secondary_ip }},{{ powerflex_mdm_primary_ip }},{{ powerflex_mdm_tertiary_ip }}" + when: mdm_count | int > 2 diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/remove_mdm.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/remove_mdm.yml new file mode 100644 index 000000000..5c200c5e3 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/remove_mdm.yml @@ -0,0 +1,58 @@ +--- +- name: Include the mdm_set_facts.yml + ansible.builtin.include_tasks: mdm_set_facts.yml + +- name: List the rpm file + register: powerflex_mdm_package_file_version + ansible.builtin.find: + paths: "/var/tmp/" + patterns: "*{{ file_glob_name }}*.rpm" + +- name: Extract file versions + ansible.builtin.set_fact: + version: "{{ powerflex_mdm_package_file_version.files[0].path | regex_search('mdm-(\\d+)', '\\1') }}" + when: powerflex_mdm_package_file_version.files | length > 0 + +- name: MDM Cluster login below PowerFlex 4.x + ansible.builtin.command: > + scli --login --mdm_ip {{ powerflex_mdm_primary_ip }} + --username admin --password {{ powerflex_mdm_password }} --approve_certificate + run_once: true + ignore_errors: true + register: powerflex_mdm_cluster_login + changed_when: powerflex_mdm_cluster_login.rc == 0 + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + when: version[0] < "4" + +- name: Login to primary MDM node for PowerFlex 4.x + register: powerflex_mdm_primary_login + ansible.builtin.command: > + scli --login --username {{ username }} --management_system_ip {{ hostname }} --password "{{ password }}" + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + run_once: true + ignore_errors: true + changed_when: powerflex_mdm_primary_login.rc == 0 + when: version[0] >= "4" + +- name: Remove secondary MDM + ansible.builtin.command: > + scli --remove_standby_mdm --remove_mdm_ip {{ powerflex_mdm_secondary_ip }} + run_once: true + register: powerflex_mdm_remove_secondary + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + ignore_errors: true + when: powerflex_mdm_secondary_ip is defined + changed_when: powerflex_mdm_remove_secondary.rc == 0 + +- name: Remove tertiary MDM + ansible.builtin.command: > + scli --remove_standby_mdm --remove_mdm_ip {{ powerflex_mdm_tertiary_ip }} + run_once: true + register: powerflex_mdm_remove_tertiary + delegate_to: "{{ powerflex_mdm_primary_hostname }}" + ignore_errors: true + when: powerflex_mdm_tertiary_ip is defined + changed_when: powerflex_mdm_remove_tertiary.rc == 0 + +- name: Include uninstall_mdm.yml + ansible.builtin.include_tasks: uninstall_mdm.yml diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/uninstall_mdm.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/uninstall_mdm.yml new file mode 100644 index 000000000..a4302cb6d --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/tasks/uninstall_mdm.yml @@ -0,0 +1,19 @@ +--- +- name: Uninstall MDM package + register: powerflex_mdm_uninstall_output + environment: + I_AM_SURE: "{{ i_am_sure | int }}" + ansible.builtin.package: + name: "{{ item }}" + state: "absent" + with_items: + - EMC-ScaleIO-mdm + when: ansible_distribution in ("RedHat", "CentOS", "SLES") + +- name: Uninstall deb package + ansible.builtin.apt: + name: "{{ item }}" + state: absent + with_items: + - emc-scaleio-mdm + when: ansible_distribution == "Ubuntu" diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/vars/CentOS.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/vars/CentOS.yml new file mode 100644 index 000000000..1f3617cf0 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/vars/CentOS.yml @@ -0,0 +1,5 @@ +--- +powerflex_mdm_packages: + - bash-completion + - python2 + - binutils diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/vars/RedHat.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/vars/RedHat.yml new file mode 100644 index 000000000..1f3617cf0 --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/vars/RedHat.yml @@ -0,0 +1,5 @@ +--- +powerflex_mdm_packages: + - bash-completion + - python2 + - binutils diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/vars/SLES.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/vars/SLES.yml new file mode 100644 index 000000000..f71b51d9a --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/vars/SLES.yml @@ -0,0 +1,3 @@ +--- +powerflex_mdm_packages: + - python3 diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/vars/Ubuntu.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/vars/Ubuntu.yml new file mode 100644 index 000000000..3d64b947c --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/vars/Ubuntu.yml @@ -0,0 +1,4 @@ +--- +powerflex_mdm_packages: + - bash-completion + - python2.7 diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/vars/main.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/vars/main.yml new file mode 100644 index 000000000..94678a3cf --- /dev/null +++ b/ansible_collections/dellemc/powerflex/roles/powerflex_mdm/vars/main.yml @@ -0,0 +1,6 @@ +--- +file_glob_name: mdm +file_gpg_name: RPM-GPG-KEY-ScaleIO +powerflex_role_environment: + MDM_IP: "{{ powerflex_mdm_ips }}" + MDM_ROLE_IS_MANAGER: 1 |