---
####################################################################
# Example : External Path Group Playbook
####################################################################
- name: External Path Group
  hosts: localhost
  gather_facts: false

  vars_files:
    - ../ansible_vault_vars/ansible_vault_storage_var.yml

  vars:
    # Common connection info for all tasks
    connection_info:
      address: "{{ storage_address }}"
      username: "{{ vault_storage_username }}"
      password: "{{ vault_storage_secret }}"

  tasks:
    ####################################################################
    # Task Name : Add external paths to an external path group
    ####################################################################
    - name: Add external paths to an external path group
      hitachivantara.vspone_block.vsp.hv_external_path_group:
        connection_info: "{{ connection_info }}"
        state: "add_external_path"
        spec:
          external_path_group_id: 1
          external_fc_paths:
            - port: "CL6-A"
              external_wwn: "50060e8012277d61"
            - port: "CL6-B"
              external_wwn: "50060e8012277d71"
          external_iscsi_target_paths:
            - port: "CL1-C"
              external_iscsi_ip_address: "172.25.59.213"
              external_iscsi_name: "iqn.1994-04.jp.co.hitachi:rsd.has.t.10045.1c019"
            - port: "CL1-C"
              external_iscsi_ip_address: "172.25.59.214"
              external_iscsi_name: "iqn.1994-04.jp.co.hitachi:rsd.has.t.10045.1c020"
      register: result

    - name: Debug the result variable
      ansible.builtin.debug:
        var: result

    ####################################################################
    # Task Name : Remove external paths from an external path group
    ####################################################################
    - name: Remove external paths from an external path group
      hitachivantara.vspone_block.vsp.hv_external_path_group:
        connection_info: "{{ connection_info }}"
        state: "remove_external_path"
        spec:
          external_path_group_id: 1
          external_fc_paths:
            - port: "CL6-A"
              external_wwn: "50060e8012277d61"
            - port: "CL6-B"
              external_wwn: "50060e8012277d71"
          external_iscsi_target_paths:
            - port: "CL1-C"
              external_iscsi_ip_address: "172.25.59.213"
              external_iscsi_name: "iqn.1994-04.jp.co.hitachi:rsd.has.t.10045.1c019"
            - port: "CL1-C"
              external_iscsi_ip_address: "172.25.59.214"
              external_iscsi_name: "iqn.1994-04.jp.co.hitachi:rsd.has.t.10045.1c020"
      register: result
    - name: Debug the result variable
      ansible.builtin.debug:
        var: result
