---
- name: Set fact # noqa var-naming[no-role-prefix]
  ansible.builtin.set_fact:
    ansible_distribution: "WindowsOS"
  when: " 'Windows' in ansible_distribution"

- name: Include uninstall_sdc.yml
  ansible.builtin.include_tasks: uninstall_sdc.yml

- name: Remove the SDC
  dellemc.powerflex.sdc:
    hostname: "{{ hostname }}"
    username: "{{ username }}"
    password: "{{ password }}"
    validate_certs: "{{ validate_certs }}"
    sdc_name: "{{ powerflex_sdc_name }}"
    state: "absent"
  register: powerflex_sdc_remove_output
  delegate_to: "{{ lookup('ansible.builtin.env', 'RUNON', default='localhost') }}"
  when: powerflex_sdc_name is defined and powerflex_sdc_name | length > 0
