diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-18 05:52:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-18 05:52:35 +0000 |
commit | 7fec0b69a082aaeec72fee0612766aa42f6b1b4d (patch) | |
tree | efb569b86ca4da888717f5433e757145fa322e08 /ansible_collections/ibm/spectrum_virtualize/playbooks | |
parent | Releasing progress-linux version 7.7.0+dfsg-3~progress7.99u1. (diff) | |
download | ansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.tar.xz ansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.zip |
Merging upstream version 9.4.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/ibm/spectrum_virtualize/playbooks')
7 files changed, 519 insertions, 0 deletions
diff --git a/ansible_collections/ibm/spectrum_virtualize/playbooks/multi_volume_create_host_mapping_zone_multipath/Readme.txt b/ansible_collections/ibm/spectrum_virtualize/playbooks/multi_volume_create_host_mapping_zone_multipath/Readme.txt new file mode 100644 index 000000000..e6bc84319 --- /dev/null +++ b/ansible_collections/ibm/spectrum_virtualize/playbooks/multi_volume_create_host_mapping_zone_multipath/Readme.txt @@ -0,0 +1,28 @@ +Objective: +This playbook creates FC host, multiple volumes, zones on Flashsystem Cluster and performs mapping of all volumes to host. + +Prerequisite: +- IBM Spectrum Virtualize and Brocade ansible collection plugins must be installed +- For more information on Brocade switch ansible collection, please refer to https://github.com/brocade/ansible/blob/master/README.rst + +These playbooks maps multiple volumes of cluster to fc host +- It uses spectrum virtualize ansible modules as well as brocade ansible modules to create zone + +There are total 2 files used for this use-case + +1. multiple_vol_creation_zone_map_vars + This file has all the variables required for playbooks + - cluster_* : Parameters starting with cluster contain cluster details where user wants to create volume, hosst etc + - brocade_switch_* : Parameters starting with brocade_switch contain brocade switch details + - application_host_*: Parameters starting with application_host contain application host details which is performing read/write of data + - volume_details : Parameters starting with volume contain volume details which will be mapped to host + - portset_* : Parameters starting with portset contain portset details required for creating fc host + +2. multi_volume_create_host_mapping_zone_multipath + - This playbook fetches the list of SCSI_HOST WWPN's associated with given fcioportid from specV cluster + - Creates zone with the name given and add specV ports fetched and host WWPN's given + - Creates multiple volumes based on volume details provided + - Maps the multiple volumes to Host to form multiple paths + +Authors: Ajinkya Nanavati (ananava1@in.ibm.com) + Mohit Chitlange (mochitla@in.ibm.com) diff --git a/ansible_collections/ibm/spectrum_virtualize/playbooks/multi_volume_create_host_mapping_zone_multipath/multiple_vol_creation_zone_map.yml b/ansible_collections/ibm/spectrum_virtualize/playbooks/multi_volume_create_host_mapping_zone_multipath/multiple_vol_creation_zone_map.yml new file mode 100644 index 000000000..597e668ee --- /dev/null +++ b/ansible_collections/ibm/spectrum_virtualize/playbooks/multi_volume_create_host_mapping_zone_multipath/multiple_vol_creation_zone_map.yml @@ -0,0 +1,204 @@ +- name: Using Spectrum Virtualize collection to migrate given volumes + hosts: localhost + vars_files: + - multiple_vol_creation_zone_map_vars + collections: + - ibm.spectrum_virtualize + - brocade.fos + vars: + brocade_credentials: + fos_ip_addr: "{{ brocade_switch_ip }}" + fos_user_name: "{{ brocade_switch_username }}" + fos_password: "{{ brocade_switch_password }}" + https: False + gather_facts: no + connection: local + tasks: + + - name: Fetch authorization token for source + register: specv_token + ibm_svc_auth: + clustername: "{{ cluster_ip }}" + username: "{{ cluster_username }}" + password: "{{ cluster_password }}" + + - name: Get deatils of the targetportfc + register: fcdetails + ibm.spectrum_virtualize.ibm_svc_info: + clustername: "{{ cluster_ip }}" + token: "{{ specv_token.token }}" + gather_subset: [targetportfc] + log_path: /tmp/fcdetails.debug + + - name: get the WWPN list from lstargetportfc for given fc_port_id + set_fact: + specv_wwpn: "{{ specv_wwpn|default([]) + [item['WWPN']]}}" + when: (item.protocol == 'scsi' and item.host_io_permitted == 'yes' and item.fc_io_port_id in cluster_fcioportid) + loop: "{{ fcdetails.TargetPortFC }}" + + - name: modify specv wwpn the way switch want + set_fact: + specv_wwpn_switch_format: "{{ specv_wwpn_switch_format|default([]) +[item|map('join')|join(':')] }}" + loop: "{{ (specv_wwpn)|map('batch', 2)|map('list')|list|lower }}" + + - name: get all zoning information from switch + brocade_facts: + credential: "{{brocade_credentials}}" + vfid: -1 + gather_subset: + - brocade_zoning + + - name: copy the active config in var active_switch_config + set_fact: + active_switch_config: "{{ ansible_facts.brocade_zoning['effective-configuration'].cfg_name }}" + + - name: Create zones on Brocade switch + vars: + zone: + - name: "{{ application_host_zone_name }}" + members: "{{ application_host_wwpns + specv_wwpn_switch_format }}" + brocade.fos.brocade_zoning_zone: + credential: "{{ brocade_credentials }}" + vfid: -1 + zones: "{{ zone }}" + members_add_only: True + + - name: Add zone to active configuration + vars: + cfgs: + - name: "{{ active_switch_config }}" + members: + - "{{ application_host_zone_name }}" + brocade_zoning_cfg: + credential: "{{ brocade_credentials }}" + vfid: -1 + members_add_only: True + cfgs: "{{ cfgs }}" + active_cfg: "{{ active_switch_config }}" + + - name: create host list for specv without colon format + set_fact: + application_host_wwpns_specvformat_list: "{{ application_host_wwpns_specvformat_list | default([]) + [(item | replace(':',''))|upper]}}" + loop: "{{application_host_wwpns }}" + + - name: create host list for specv without colon format + set_fact: + application_host_wwpns_specvformat: "{{application_host_wwpns_specvformat |default('')+item +':'}}" + loop: "{{application_host_wwpns_specvformat_list| select() }}" + + - set_fact: + application_host_wwpns_specvformat: "{{ application_host_wwpns_specvformat[:-1]}}" + + - name: Creating Host on specv + ibm_svc_host: + clustername: "{{ cluster_ip }}" + token: "{{ specv_token.token }}" + name: "{{ host_name }}" + state: present + fcwwpn: "{{ application_host_wwpns_specvformat }}" + + - name: Create a fc porset + ibm.spectrum_virtualize.ibm_svc_manage_portset: + clustername: "{{ cluster_ip }}" + token: "{{ specv_token.token }}" + name: "{{ portset_name }}" + porttype: fc + portset_type: host + state: present + + - name: Add port ID to the portset + ibm.spectrum_virtualize.ibm_sv_manage_fcportsetmember: + clustername: "{{ cluster_ip }}" + token: "{{ specv_token.token }}" + name: "{{ portset_name }}" + fcportid: "{{item}}" + state: present + loop: "{{ cluster_fcioportid }}" + + - name: Create vdisk + register: results_cvdisk + ibm_svc_vdisk: + clustername: "{{cluster_ip}}" + token: "{{ specv_token.token }}" + domain: + state: present + name: "{{item.vol_name}}" + mdiskgrp: "{{item.mdiskgrp}}" + easytier: 'off' + size: "{{item.size}}" + unit: "{{item.unit}}" + loop: "{{ volume_details }}" + + - name: map Host to Vdisk + ibm_svc_vol_map: + clustername: "{{cluster_ip}}" + token: "{{ specv_token.token }}" + domain: + state: present + volname: "{{item.vol_name}}" + host: "{{host_name}}" + loop: "{{ volume_details }}" + + - name: Rescan the paths on the host and run multipath + shell: "ssh {{application_host_username}}@{{application_host_ip}} rescan-scsi-bus.sh -i --forcerescan;sleep 40;" + + - shell: "ssh {{application_host_username}}@{{application_host_ip}} multipath -ll" + register: ps + + - name: Separate facts + set_fact: + multipath_var: "{{ ps.stdout.split('mpath') }}" + + - debug: + msg: "{{ multipath_var}}" + + - name: Get deatils of the given volume + register: volinfo + ibm.spectrum_virtualize.ibm_svc_info: + clustername: "{{ cluster_ip }}" + token: "{{ specv_token.token }}" + gather_subset: [vol] + log_path: /tmp/volinfo.debug + + - name: create volume list + set_fact: + vol_name_list: "{{ vol_name_list|default([])+ [item['vol_name']] }}" + loop: "{{ volume_details }}" + + - debug: + msg: "{{ vol_name_list }}" + + - name: find vollist data + set_fact: + vol_list_full_data: "{{ vol_list_full_data|default([])+ [item] }}" + vol_name_uid: "{{ vol_name_uid|default([])+[[item['volume_name'],item['vdisk_UID']|lower]]}}" + when: (item.volume_name in vol_name_list ) + loop: "{{ volinfo.Volume }}" + + - debug: + msg: "{{ vol_name_uid }}" + + - name: Find vdisk UID present in host with path + set_fact: + dm_device: "{{dm_device| default([]) +[ [item.0] + [item.1] + [item.2]]}}" + when: (item.1 in item.2) + with_nested: + - "{{ vol_name_uid }}" + - "{{ multipath_var }}" + + - name: find unmapped volume + set_fact: + vdisk_mapped_multipath: "{{vdisk_mapped_multipath| default([]) + [item[0]]}}" + loop: "{{ dm_device }}" + + - debug: + msg: "{{ vdisk_mapped_multipath }}" + + - name: find unmapped volume + set_fact: + unmaped_vol_name_list: "{{ unmaped_vol_name_list|default([])+ [item] }}" + when: (item not in vdisk_mapped_multipath) + loop: "{{ vol_name_list }}" + + - debug: + msg: "{{ unmaped_vol_name_list }}" diff --git a/ansible_collections/ibm/spectrum_virtualize/playbooks/multi_volume_create_host_mapping_zone_multipath/multiple_vol_creation_zone_map_vars.txt b/ansible_collections/ibm/spectrum_virtualize/playbooks/multi_volume_create_host_mapping_zone_multipath/multiple_vol_creation_zone_map_vars.txt new file mode 100644 index 000000000..8a4fcdb18 --- /dev/null +++ b/ansible_collections/ibm/spectrum_virtualize/playbooks/multi_volume_create_host_mapping_zone_multipath/multiple_vol_creation_zone_map_vars.txt @@ -0,0 +1,30 @@ +application_host_details: +application_host_name: linux_host +application_host_ip: a.b.c.d +application_host_username: username +application_host_password: password +application_host_zone_name: test +application_host_wwpns: ["10:00:00:90:fa:94:20:d0","10:00:00:90:fa:94:20:d2"] + +cluster_ip: x.x.x.x +cluster_username: username1 +cluster_password: password1 +cluster_fcioportid: ['1'] + +host_name: linux_ansible +portset_name: portset_ansible +portset_type: host +port_type: fc +brocade_switch_ip: z.z.z.z +brocade_switch_username: username2 +brocade_switch_password: password2 + +volume_details: + - vol_name: vdisk_3 + mdiskgrp: "0" + size: "5" + unit: "gb" + - vol_name: vdisk_4 + mdiskgrp: "0" + size: "5" + unit: "gb" diff --git a/ansible_collections/ibm/spectrum_virtualize/playbooks/volume_migration_on_svc_iscsi/Readme.txt b/ansible_collections/ibm/spectrum_virtualize/playbooks/volume_migration_on_svc_iscsi/Readme.txt new file mode 100644 index 000000000..8b2970259 --- /dev/null +++ b/ansible_collections/ibm/spectrum_virtualize/playbooks/volume_migration_on_svc_iscsi/Readme.txt @@ -0,0 +1,45 @@ +Objective: +Migrate volume from one Flash System to another Flash System in application transparent manner with target host as ISCSI. + +Prerequisite: +- IBM Spectrum Virtualize ansible collection plugins must be installed + +These playbooks migrate a volume from a source cluster to the destination cluster. +These playbooks are designed to migrate volume mapped to Fibre Channel (FC) host or ISCSI host from source cluster to ISCSI host on destination cluster. + +There are total 3 files used for this use-case. + 1. vol_migration_vars: + This file has all the variables required for playbooks + - src_cluster_* : Parameters starting with src_cluster contain source cluster details from where user wants to migrate volume + - src_cluster_* : Parameters starting with src_cluster contain source cluster details from where user wants to migrate volume + - dest_cluster* : Parameters starting with dest_cluster contain destination cluster details to where volume will be migrated + - application_host_* : Parameters starting with application_host contain application host details which is performing read/write of data + - application_iscsi_ip : This contains in detail information for ip to be given to node with detail information as follows + - node_name: Node name of cluster + - portset: portset name to be used + - ip_address: <ip address> + - subnet_prefix: <prefix> + - gateway: <gateway> + - port: <port_id> + - src_vol_name : This suggest volume name of source cluster which is to be migrated + - dest_vol_name : This create volume name at destination cluster + - rel_name : This is name of relationship to be created between source and destination cluster + 2. initiate_migration_for_given_volume: + - This playbook initiates the migration + - Most importantly, it also starts data copy from source cluster to destination cluster + Note: + User should not run playbook create_zone_map_volume_and_rescan until relationship is in consistent_syncronized state + 3. create_host_map_volume_and_rescan + - Execute this playbook once the relationship created by above playbook is in consistent_syncronized state + - create iscsi host on flashsystem from iqn defined in variable application_host_iqn from variable file + - configuring ip on each node for iscsi host connectivity + - establish iscsi session from host to flashsystem nodes + - Maps the volume to the Host and starts scsi rescan on the host + - Switch replication direction of a migration relationship once host is mapped + - Again rescan the volume on the host to get the updated path details + - Delete source volume and migration relationship which was created + - Again rescan the multipath and expect migrated volume has the only path from destiantion cluster + + Authors: Ajinkya Nanavati (ananava1@in.ibm.com) + Mohit Chitlange (mochitla@in.ibm.com) + Devendra Mahajan (demahaj1@in.ibm.com) diff --git a/ansible_collections/ibm/spectrum_virtualize/playbooks/volume_migration_on_svc_iscsi/create_iscsi_host_map_vol_switch.yml b/ansible_collections/ibm/spectrum_virtualize/playbooks/volume_migration_on_svc_iscsi/create_iscsi_host_map_vol_switch.yml new file mode 100644 index 000000000..b7a0f1bb3 --- /dev/null +++ b/ansible_collections/ibm/spectrum_virtualize/playbooks/volume_migration_on_svc_iscsi/create_iscsi_host_map_vol_switch.yml @@ -0,0 +1,143 @@ +- name: Using Spectrum Virtualize collection to migrate given volume + hosts: localhost + vars_files: + - vol_migration_vars + collections: + - ibm.spectrum_virtualize + + gather_facts: no + vars: + dest_vol_name: "{{ dest_vol_name if dest_vol_name is defined else src_vol_name }}" + dest_host_name: "{{ host_name }}" + connection: local + tasks: + - name: Fetch authorization token for source + register: src_token + ibm_svc_auth: + clustername: "{{ src_cluster_ip }}" + username: "{{ src_cluster_username }}" + password: "{{ src_cluster_password }}" + + - name: Fetch authorization token for destination + register: dest_token + ibm_svc_auth: + clustername: "{{ dest_cluster_ip }}" + username: "{{ dest_cluster_username }}" + password: "{{ dest_cluster_password }}" + + - name: Get deatils of the given volume + register: volinfo + ibm.spectrum_virtualize.ibm_svc_info: + clustername: "{{ dest_cluster_ip }}" + token: "{{ dest_token.token }}" + gather_subset: [vol] + objectname: "{{ dest_vol_name }}" + log_path: /tmp/volinfo.debug + + - name: Get the volume UID data + set_fact: + vol_uid: "{{ volinfo.Volume[0]['vdisk_UID'] | lower }}" + when: volinfo.Volume[0] is defined + + - name: Creating Host on SVC + ibm_svc_host: + clustername: "{{ dest_cluster_ip }}" + token: "{{ dest_token.token }}" + name: "{{ dest_host_name }}" + state: present + iscsiname: "{{ application_host_iqn }}" + + - name: map Vdisk to host + ibm_svc_vol_map: + clustername: "{{ dest_cluster_ip }}" + token: "{{ dest_token.token }}" + state: present + volname: "{{ dest_vol_name }}" + host: "{{ dest_host_name }}" + scsi: 0 + + - name: Create IP provisioning + ibm.spectrum_virtualize.ibm_svc_manage_ip: + clustername: "{{ dest_cluster_ip }}" + token: "{{ dest_token.token }}" + log_path: /tmp/playbook.debug + node: "{{ item.node_name }}" + port: "{{ item.port }}" + portset: "{{ item.portset }}" + ip_address: "{{ item.ip_address }}" + subnet_prefix: "{{ item.subnet_prefix }}" + gateway: "{{ item.gateway }}" + state: present + loop: "{{ application_iscsi_ip }}" + + - name: Create iscsi session + shell: ssh {{ application_host_username }}@{{ application_host_ip }} "iscsiadm --mode discovery --type sendtargets --portal {{item.ip_address}} -l" + loop: "{{ application_iscsi_ip }}" + + - shell: ssh {{ application_host_username }}@{{ application_host_ip }} "multipath -ll" + register: ps + + - name: Separate facts + set_fact: + multipath_var: "{{ ps.stdout.split('mpath') }}" + + - debug: + msg: "{{ multipath_var}}" + + - name: Find vdisk UID present in host with path + set_fact: + dm_device: "{{item}}" + loop: "{{ multipath_var }}" + when: vol_uid in item + + - debug: + msg: "{{ dm_device}}" + + - name: Switch replication direction of a migration relationship + ibm_svc_manage_migration: + relationship_name: "{{ rel_name if rel_name is defined else src_vol_name }}" + clustername: "{{ src_cluster_ip }}" + token: "{{ src_token.token }}" + state: switch + + - shell: ssh {{ application_host_username }}@{{ application_host_ip }} "rescan-scsi-bus.sh -i --forcerescan; sleep 40;" + - shell: ssh {{ application_host_username }}@{{ application_host_ip }} "multipath -ll" + register: ps + + - name: Separate facts + set_fact: + multipath_var: "{{ ps.stdout.split('mpath') }}" + + - name: Find vdisk UID present in host with path + set_fact: + dm_device: "{{item}}" + loop: "{{ multipath_var }}" + when: vol_uid in item + + - debug: + msg: "{{ dm_device }}" + + - name: Delete source volume and migration relationship + ibm_svc_manage_migration: + clustername: "{{ src_cluster_ip }}" + state: cleanup + source_volume: "{{ src_vol_name }}" + token: "{{ src_token.token }}" + log_path: /tmp/ansible.log + + - shell: ssh {{ application_host_username }}@{{ application_host_ip }} "rescan-scsi-bus.sh -i --forcerescan; sleep 40;" + - shell: ssh {{ application_host_username }}@{{ application_host_ip }} "multipath -ll" + register: ps + + - name: Separate facts + set_fact: + multipath_var: "{{ ps.stdout.split('mpath') }}" + + - name: Find vdisk UID present in host with path + set_fact: + dm_device: "{{item}}" + loop: "{{ multipath_var }}" + when: vol_uid in item + + - debug: + msg: "{{ dm_device}}" diff --git a/ansible_collections/ibm/spectrum_virtualize/playbooks/volume_migration_on_svc_iscsi/initiate_migration_for_given_volume.yml b/ansible_collections/ibm/spectrum_virtualize/playbooks/volume_migration_on_svc_iscsi/initiate_migration_for_given_volume.yml new file mode 100644 index 000000000..b01e6122b --- /dev/null +++ b/ansible_collections/ibm/spectrum_virtualize/playbooks/volume_migration_on_svc_iscsi/initiate_migration_for_given_volume.yml @@ -0,0 +1,33 @@ +- name: Using Spectrum Virtualize collection to initiate migration + hosts: localhost + vars_files: + - vol_migration_vars + collections: + - ibm.spectrum_virtualize + gather_facts: no + connection: local + tasks: + - name: Fetch authorization token for source + register: src_token + ibm_svc_auth: + clustername: "{{ src_cluster_ip }}" + username: "{{ src_cluster_username }}" + password: "{{ src_cluster_password }}" + - name: Fetch authorization token for destination + register: dest_token + ibm_svc_auth: + clustername: "{{ dest_cluster_ip }}" + username: "{{ dest_cluster_username }}" + password: "{{ dest_cluster_password }}" + - name: Initiate a volume migration with replicate_hosts as false + ibm_svc_manage_migration: + source_volume: "{{ src_vol_name }}" + target_volume: "{{ dest_vol_name if dest_vol_name is defined else src_vol_name }}" + clustername: "{{ src_cluster_ip }}" + remote_cluster: "{{ dest_cluster_name }}" + token: "{{ src_token.token }}" + state: initiate + replicate_hosts: false + remote_token: "{{ dest_token.token }}" + relationship_name: "{{ rel_name if rel_name is defined else src_vol_name }}" + remote_pool: "{{ dest_cluster_pool_name }}" diff --git a/ansible_collections/ibm/spectrum_virtualize/playbooks/volume_migration_on_svc_iscsi/vol_migration_vars.txt b/ansible_collections/ibm/spectrum_virtualize/playbooks/volume_migration_on_svc_iscsi/vol_migration_vars.txt new file mode 100644 index 000000000..14905b86b --- /dev/null +++ b/ansible_collections/ibm/spectrum_virtualize/playbooks/volume_migration_on_svc_iscsi/vol_migration_vars.txt @@ -0,0 +1,36 @@ +src_cluster_name: Master +src_cluster_ip: x.x.x.x +src_cluster_username: username +src_cluster_password: password + +dest_cluster_name: Aux_far +dest_cluster_ip: y.y.y.y +dest_cluster_username: username1 +dest_cluster_password: password1 +dest_cluster_pool_name: mdiskgrp0 + +application_host_details: +application_host_name: linux_host +application_host_ip: a.b.c.d +application_host_username: username2 +application_host_password: password2 +application_host_iqn: "iqn.1994-05.com.redhat:5e54d1815f55" + +application_iscsi_ip: + - node_name: node1 + portset: portset0 + ip_address: 192.168.100.121 + subnet_prefix: 24 + gateway: 192.168.100.1 + port: 6 + - node_name: node2 + portset: portset0 + ip_address: 192.168.100.122 + subnet_prefix: 24 + gateway: 192.168.100.1 + port: 6 + +src_vol_name: vdisk_application1 +host_name: linux_host +dest_vol_name: vdisk_application1 +rel_name: r1 |