| 1 |
# Automated Host-Side Actions for Partition Migration |
| 2 |
|
| 3 |
## Table of Contents |
| 4 |
|
| 5 |
- [Objective](#objective) |
| 6 |
- [Prerequisites](#prerequisites) |
| 7 |
- [Playbooks](#playbooks) |
| 8 |
- [Configuration](#configuration) |
| 9 |
- [Inventory](#inventory) |
| 10 |
- [Variables](#variables) |
| 11 |
- [How It Works](#how-it-works) |
| 12 |
- [Ansible Logging](#ansible-logging) |
| 13 |
- [Extending to New Operating Systems](#extending-to-new-operating-systems) |
| 14 |
- [Authors](#authors) |
| 15 |
|
| 16 |
|
| 17 |
## Objective |
| 18 |
|
| 19 |
This Ansible playbook suite automates **host-side actions** required while migrating storage partitions from one IBM FlashSystem to another. |
| 20 |
It continuously monitors partition migration events on the FlashSystems and performs the appropriate actions on mapped hosts (Linux / Windows) to ensure paths are properly discovered, rescan, and validated before commit or rollback. |
| 21 |
|
| 22 |
## Prerequisites |
| 23 |
|
| 24 |
### Controller Requirements |
| 25 |
|
| 26 |
- IBM Storage Virtualize Ansible Collection plugins **v2.7.4 or above** must be installed. |
| 27 |
- The Ansible controller machine must have **Python 3.10+**. |
| 28 |
|
| 29 |
### Target Host Requirements |
| 30 |
|
| 31 |
#### Common |
| 32 |
|
| 33 |
- All remote hosts must have **Python 3.8+**. |
| 34 |
- Ensure: |
| 35 |
- **Zoning** is present between the host and the **target FlashSystem** (for FC). |
| 36 |
- **IP connectivity** is available between the host and the **iSCSI target** (for iSCSI). |
| 37 |
|
| 38 |
#### Windows Hosts |
| 39 |
|
| 40 |
- Must have either: |
| 41 |
- `sshpass`, or |
| 42 |
- `winRM` utility installed. |
| 43 |
- SSH access must be set up between the Windows host and the Ansible controller. |
| 44 |
- Playbooks use **PowerShell** and require **Administrator** privileges. |
| 45 |
- **Microsoft iSCSI Initiator Service** must be installed and running. |
| 46 |
|
| 47 |
#### Linux Hosts |
| 48 |
|
| 49 |
- `rescan-scsi-bus.sh` (package `scsitools`) installed. |
| 50 |
- Multipath utilities (e.g. `multipath`, `multipathd`) installed and configured. |
| 51 |
- Playbooks use `rescan-scsi-bus.sh`, which requires **root** privileges. |
| 52 |
- `iscsiadm` installed and available in `PATH`. |
| 53 |
|
| 54 |
### FlashSystem Requirements |
| 55 |
|
| 56 |
- **iSCSI** |
| 57 |
- Host-type **portset** must be configured with data IPs. |
| 58 |
- The user can either: |
| 59 |
- Provide specific IPs in `inventory.ini`, or |
| 60 |
- Let the playbook perform discovery/login on **all IPs** present in the portset. |
| 61 |
- **FC** |
| 62 |
- No specific requirement other than correct **zoning**. |
| 63 |
|
| 64 |
> [!NOTE] |
| 65 |
> - The playbooks **do not** create portsets or assign IPs to portsets. |
| 66 |
> - The same framework supports hosts using **FC**, **iSCSI**, or **both**. |
| 67 |
|
| 68 |
## Playbooks |
| 69 |
|
| 70 |
The main files in this directory are: |
| 71 |
|
| 72 |
- `main.yml` |
| 73 |
Entry-point playbook. Monitors partition migrations and orchestrates all other playbooks. |
| 74 |
Usage: ```ansible-playbook main.yml -i inventory.ini``` |
| 75 |
|
| 76 |
- `inventory.ini` |
| 77 |
Defines: |
| 78 |
- `application_server` (or other host groups): hosts mapped to FlashSystems |
| 79 |
- `flash_systems`: FlashSystems to monitor for migration events |
| 80 |
|
| 81 |
- `vars.yml` |
| 82 |
User-tunable parameters controlling behavior (min paths, deployment type, inventory path, log path, etc.). |
| 83 |
|
| 84 |
- `host_identification.yml` |
| 85 |
Identifies hosts mapped to a migrating partition, and determines OS (Linux / Windows / others). |
| 86 |
|
| 87 |
- `discover_multipath_devices.yml` |
| 88 |
Performs device and multipath discovery (e.g. iSCSI login, SCSI rescan, multipath detection) on target hosts. |
| 89 |
|
| 90 |
- `rescan_multipath_devices.yml` |
| 91 |
Handles `host_rescan_requested` events by rescanning devices and refreshing multipath information on mapped hosts. |
| 92 |
|
| 93 |
- `verify_multipath_devices.yml` |
| 94 |
For `commit_or_rollback` events, verifies active path counts per device and per node, and checks compliance with `min_active_path`. |
| 95 |
> Currently supports **Linux** only. |
| 96 |
|
| 97 |
- `iscsi_logout.yml` |
| 98 |
Handles iSCSI logout actions for appropriate scenarios (e.g. cleanup after migration / rollback). |
| 99 |
|
| 100 |
- `test_and_rescan_hosts.yml` |
| 101 |
Helper playbook to test connectivity and perform host-side rescans where needed. |
| 102 |
|
| 103 |
## Configuration |
| 104 |
|
| 105 |
### Inventory |
| 106 |
|
| 107 |
`inventory.ini` defines the hosts and FlashSystems with their access credentials. |
| 108 |
|
| 109 |
#### Example – FC |
| 110 |
|
| 111 |
``` |
| 112 |
[application_server] |
| 113 |
linux1 ansible_host=x.x.x.x ansible_user=root ansible_ssh_pass=password ansible_connection=ssh |
| 114 |
windows1 ansible_host=x.x.x.x ansible_user=Administrator ansible_ssh_pass=password ansible_connection=ssh ansible_shell_type=cmd |
| 115 |
|
| 116 |
[flash_systems] |
| 117 |
fs1 ansible_host=x.x.x.x ansible_user=superuser ansible_password=password |
| 118 |
fs2 ansible_host=x.x.x.x ansible_user=superuser ansible_password=password |
| 119 |
``` |
| 120 |
|
| 121 |
#### Example – iSCSI |
| 122 |
``` |
| 123 |
[application_server] |
| 124 |
win1 ansible_host=x.x.x.x ansible_user=admin ansible_ssh_pass=password ansible_connection=ssh ansible_shell_type=cmd ansible_iscsi_ips='["x.x.x.x","x.x.x.x"]' |
| 125 |
linux1 ansible_host=x.x.x.x ansible_user=root ansible_ssh_pass=password ansible_connection=ssh ansible_iscsi_ips='["x.x.x.x","x.x.x.x"]' |
| 126 |
linux2 ansible_host=x.x.x.x ansible_user=root ansible_ssh_pass=password ansible_connection=ssh |
| 127 |
|
| 128 |
[flash_systems] |
| 129 |
fs1 ansible_host=x.x.x.x ansible_user=superuser ansible_password=password |
| 130 |
fs2 ansible_host=x.x.x.x ansible_user=superuser ansible_password=password |
| 131 |
``` |
| 132 |
|
| 133 |
### Variables |
| 134 |
|
| 135 |
All user-configurable parameters are defined in vars.yml: |
| 136 |
| Parameter | Description | |
| 137 |
| -------------------- | --------------------------------------------------------------------------------------------------------| |
| 138 |
| `min_active_path` | Minimum required active paths per node-to-host for all devices. Use 0 to skip auto commit of migration. | |
| 139 |
| `hosts_name` | Host group name from `inventory.ini` (e.g., `application_server` or `localhost`) | |
| 140 |
| `deployment_type` | `1`: Localhost; `2`: Ansible Tower (or other central controller). | |
| 141 |
| `io_stability_time` | Wait time (in seconds) to ensure I/O stability before validation/commit. | |
| 142 |
| `inventory_file` | Path to the inventory file (e.g. inventory.ini). | |
| 143 |
| `logpath` | Path to store log files (update logrotate configuration if using a custom directory). | |
| 144 |
| `temp_file_location` | Directory to store temporary files during script execution. | |
| 145 |
|
| 146 |
|
| 147 |
## How It Works |
| 148 |
|
| 149 |
These playbooks monitor partition migration status on FlashSystems and trigger host-side actions to keep paths consistent and compliant. |
| 150 |
|
| 151 |
>[!NOTE] |
| 152 |
>The framework supports at least the following migration events: |
| 153 |
> - `host_rescan_requested` |
| 154 |
> - `commit_or_rollback` |
| 155 |
|
| 156 |
>[!WARNING] |
| 157 |
>The solution uses rescan-scsi-bus.sh on Linux. |
| 158 |
>This can impact I/O for other volumes mapped to the same host. |
| 159 |
>Carefully choose when to run the playbook (e.g. outside critical peak load). |
| 160 |
|
| 161 |
### Event Handling Workflow |
| 162 |
|
| 163 |
Monitoring / Dispatch (main.yml)- |
| 164 |
Continuously queries FlashSystems for active partition migrations. |
| 165 |
Identifies migration events and mapped hosts using host_identification.yml. |
| 166 |
For each event, dispatches the appropriate helper playbook. |
| 167 |
|
| 168 |
host_rescan_requested- |
| 169 |
Triggers rescan_multipath_devices.yml on the identified hosts. |
| 170 |
Performs device / SCSI rescan and multipath refresh. |
| 171 |
Retries up to 5 times if rescan validation fails (configurable via vars if required). |
| 172 |
|
| 173 |
commit_or_rollback- |
| 174 |
Triggers verify_multipath_devices.yml on Linux hosts. |
| 175 |
Verifies path counts per device, per node. |
| 176 |
Compares results against min_active_path configured in vars.yml. |
| 177 |
If all devices are compliant and min_active_path > 0: |
| 178 |
The playbook can auto-commit the migration on FlashSystem. |
| 179 |
|
| 180 |
If validation fails: |
| 181 |
The partition migration is not auto-committed, and details are logged for manual inspection. |
| 182 |
Skip Conditions for commit_or_rollback |
| 183 |
The commit_or_rollback event will be skipped if any of the following is true: |
| 184 |
Deployment type is set to 1 (localhost) but the partition has multiple hosts mapped. |
| 185 |
The number of detected hosts on FlashSystem does not match the hosts defined in the inventory. |
| 186 |
The partition includes hosts with unsupported operating systems. |
| 187 |
No host is mapped to the migrating partition. |
| 188 |
|
| 189 |
>[!NOTE] |
| 190 |
>By default, auto-commit is disabled by setting min_active_path = 0. |
| 191 |
>Fixing commit_or_rollback events and auto-committing will delete the partition from the source copy. |
| 192 |
|
| 193 |
Monitor: |
| 194 |
Ansible output for event handling and decisions. |
| 195 |
Logs written to the configured logpath (if any). |
| 196 |
|
| 197 |
## Ansible Logging |
| 198 |
To enable Ansible logging, set the following environment variable on the controller: |
| 199 |
``` |
| 200 |
export ANSIBLE_LOG_PATH=/var/log/ansible.log |
| 201 |
``` |
| 202 |
You can customize the path if needed; ensure the directory exists and has appropriate permissions. |
| 203 |
|
| 204 |
## Extending to New Operating Systems |
| 205 |
To support additional operating systems, add OS-specific blocks to the following playbooks: |
| 206 |
- host_identification.yml |
| 207 |
- Currently supports Linux and Windows. |
| 208 |
- For a new OS, ensure it can be identified (e.g. via facts or custom conditions). |
| 209 |
- Provide host identifiers in the desired format, for example: |
| 210 |
|
| 211 |
FC Example |
| 212 |
``` |
| 213 |
fc_host_wwpns_upper: [ |
| 214 |
"10000090FAA0B824", |
| 215 |
"10000090FAA0B825" |
| 216 |
] |
| 217 |
``` |
| 218 |
|
| 219 |
iSCSI Example |
| 220 |
``` |
| 221 |
iscsi_ips: [ |
| 222 |
"10.10.10.14", |
| 223 |
"10.10.10.15", |
| 224 |
"10.10.10.16", |
| 225 |
"10.10.10.17" |
| 226 |
] |
| 227 |
iscsi_name: [ |
| 228 |
"iqn.1994-05.com.redhat:529611838e5d" |
| 229 |
] |
| 230 |
``` |
| 231 |
|
| 232 |
- rescan_multipath_devices.yml |
| 233 |
- Currently supports Linux and Windows. |
| 234 |
- For new OS types, provide: |
| 235 |
- Rescan CLI path, or |
| 236 |
- The rescan method/commands required for that OS. |
| 237 |
|
| 238 |
- verify_multipath_devices.yml |
| 239 |
- Currently supports Linux. |
| 240 |
- For a new OS, ensure the script produces (or can convert to) output in the following format: |
| 241 |
|
| 242 |
``` |
| 243 |
{ |
| 244 |
"data": [ |
| 245 |
{ |
| 246 |
"active_paths_on_tgt": { |
| 247 |
"dm-0": { |
| 248 |
"node1": { |
| 249 |
"active_no_paths": 2, |
| 250 |
"inactive_no_paths": 0 |
| 251 |
}, |
| 252 |
"node2": { |
| 253 |
"active_no_paths": 2, |
| 254 |
"inactive_no_paths": 0 |
| 255 |
}, |
| 256 |
"uuid": "(36005076810da8186b80000000000006e)" |
| 257 |
}, |
| 258 |
"dm-1": { |
| 259 |
"node1": { |
| 260 |
"active_no_paths": 2, |
| 261 |
"inactive_no_paths": 0 |
| 262 |
}, |
| 263 |
"node2": { |
| 264 |
"active_no_paths": 2, |
| 265 |
"inactive_no_paths": 0 |
| 266 |
}, |
| 267 |
"uuid": "(36005076810da8186b80000000000006f)" |
| 268 |
}, |
| 269 |
"inventory_name": "linux1" |
| 270 |
}, |
| 271 |
"non_compliant_devices": [] |
| 272 |
} |
| 273 |
] |
| 274 |
} |
| 275 |
``` |
| 276 |
The verification logic expects this structure when evaluating compliance with min_active_path. |
| 277 |
|
| 278 |
## Authors |
| 279 |
|
| 280 |
- Prateek Mandge ([email protected]) |
| 281 |
- Mohit Chitlange ([email protected]) |
| 282 |
- Ashwin Joshi ([email protected]) |
| 283 |
- Chetan Borkar ([email protected]) |
| 284 |
- Sumit Kumar Gupta ([email protected]) |
| 285 |
- Aditya Bhosale ([email protected]) |