| 1 | - name: Using the IBM Storage Virtualize collection For PBHA configuration |
| 2 | hosts: localhost |
| 3 | gather_facts: false |
| 4 | connection: local |
| 5 | vars_files: |
| 6 | - inventory.ini |
| 7 | vars: |
| 8 | volume_count: "{{ number_of_volumes | default(10) }}" |
| 9 | vol_prefix: "{{ volume_prefix | default('vol_') }}" |
| 10 | tasks: |
| 11 | - name: Fetch auth token for primary cluster |
| 12 | register: primary_auth |
| 13 | no_log: true |
| 14 | ibm.storage_virtualize.ibm_svc_auth: |
| 15 | clustername: "{{ users_data[0].cluster_ip }}" |
| 16 | username: "{{ users_data[0].cluster_username }}" |
| 17 | password: "{{ users_data[0].cluster_password }}" |
| 18 | log_path: "{{ log_path | default('/tmp/ansiblePB.debug') }}" |
| 19 | |
| 20 | - name: Fetch auth token for secondary cluster |
| 21 | register: secondary_auth |
| 22 | no_log: true |
| 23 | ibm.storage_virtualize.ibm_svc_auth: |
| 24 | clustername: "{{ users_data[1].cluster_ip }}" |
| 25 | username: "{{ users_data[1].cluster_username }}" |
| 26 | password: "{{ users_data[1].cluster_password }}" |
| 27 | log_path: "{{ log_path | default('/tmp/ansiblePB.debug') }}" |
| 28 | |
| 29 | - name: Create mdiskgrp_drp and provisionpolicy on both the clusters |
| 30 | ansible.builtin.include_tasks: create_mdiskgrp_provisioning_policy.yml |
| 31 | no_log: true |
| 32 | loop: "{{ users_data }}" |
| 33 | |
| 34 | - name: Get mdiskgrp info |
| 35 | register: results |
| 36 | ibm.storage_virtualize.ibm_svc_info: |
| 37 | clustername: "{{ users_data[0].cluster_ip }}" |
| 38 | token: "{{ primary_auth.token }}" |
| 39 | log_path: "{{ log_path | default('/tmp/ansiblePB.debug') }}" |
| 40 | gather_subset: "pool" |
| 41 | objectname: "{{ pool_name }}" |
| 42 | |
| 43 | - name: Set replication pool link UID |
| 44 | ansible.builtin.set_fact: |
| 45 | uid: "{{ results.Pool.replication_pool_link_uid }}" |
| 46 | |
| 47 | - name: Get primary cluster id info |
| 48 | register: results |
| 49 | ibm.storage_virtualize.ibm_svc_info: |
| 50 | clustername: "{{ users_data[0].cluster_ip }}" |
| 51 | token: "{{ primary_auth.token }}" |
| 52 | log_path: "{{ log_path | default('/tmp/ansiblePB.debug') }}" |
| 53 | gather_subset: "partnership" |
| 54 | filtervalue: "name={{ users_data[0].cluster_name }}" |
| 55 | |
| 56 | - name: Set primary cluster id |
| 57 | ansible.builtin.set_fact: |
| 58 | clusterid1: "{{ item.id }}" |
| 59 | loop: "{{ results.Partnership }}" |
| 60 | |
| 61 | - name: Get secondary cluster id info |
| 62 | register: results |
| 63 | ibm.storage_virtualize.ibm_svc_info: |
| 64 | clustername: "{{ users_data[1].cluster_ip }}" |
| 65 | token: "{{ secondary_auth.token }}" |
| 66 | log_path: "{{ log_path | default('/tmp/ansiblePB.debug') }}" |
| 67 | gather_subset: "partnership" |
| 68 | filtervalue: "name={{ users_data[1].cluster_name }}" |
| 69 | |
| 70 | - name: Set secondary cluster id |
| 71 | ansible.builtin.set_fact: |
| 72 | clusterid2: "{{ item.id }}" |
| 73 | loop: "{{ results.Partnership }}" |
| 74 | |
| 75 | - name: Set provisionpolicy and replicationpoollinkuid on primary site |
| 76 | ibm.storage_virtualize.ibm_svc_mdiskgrp: |
| 77 | clustername: "{{ users_data[0].cluster_ip }}" |
| 78 | token: "{{ primary_auth.token }}" |
| 79 | log_path: "{{ log_path | default('/tmp/ansiblePB.debug') }}" |
| 80 | name: "{{ pool_name }}" |
| 81 | state: "present" |
| 82 | replicationpoollinkuid: "{{ uid }}" |
| 83 | replication_partner_clusterid: "{{ users_data[1].cluster_name }}" |
| 84 | provisioningpolicy: "{{ provisioning_policy_name | default('provisioning_policy0') }}" |
| 85 | |
| 86 | - name: Set provisionpolicy and replicationpoollinkuid on secondary site |
| 87 | ibm.storage_virtualize.ibm_svc_mdiskgrp: |
| 88 | clustername: "{{ users_data[1].cluster_ip }}" |
| 89 | token: "{{ secondary_auth.token }}" |
| 90 | log_path: "{{ log_path | default('/tmp/ansiblePB.debug') }}" |
| 91 | name: "{{ pool_name }}" |
| 92 | state: "present" |
| 93 | replicationpoollinkuid: "{{ uid }}" |
| 94 | replication_partner_clusterid: "{{ users_data[0].cluster_name }}" |
| 95 | provisioningpolicy: "{{ provisioning_policy_name | default('provisioning_policy0') }}" |
| 96 | |
| 97 | - name: Set up the quorum application on the primary system |
| 98 | ibm.storage_virtualize.ibm_svctask_command: |
| 99 | command: "svctask mkquorumapp -partnersystem {{ users_data[1].cluster_name }}" |
| 100 | clustername: "{{ users_data[0].cluster_ip }}" |
| 101 | username: "{{ users_data[0].cluster_username }}" |
| 102 | password: "{{ users_data[0].cluster_password }}" |
| 103 | log_path: "{{ log_path | default('/tmp/ansiblePB.debug') }}" |
| 104 | |
| 105 | - name: Create HA-replication policy |
| 106 | ibm.storage_virtualize.ibm_sv_manage_replication_policy: |
| 107 | clustername: "{{ users_data[0].cluster_ip }}" |
| 108 | token: "{{ primary_auth.token }}" |
| 109 | log_path: "{{ log_path | default('/tmp/ansiblePB.debug') }}" |
| 110 | name: "{{ ha_policy_name }}" |
| 111 | topology: "2-site-ha" |
| 112 | location1system: "{{ clusterid1 }}" |
| 113 | location1iogrp: 0 |
| 114 | location2system: "{{ clusterid2 }}" |
| 115 | location2iogrp: 0 |
| 116 | state: "present" |
| 117 | |
| 118 | - name: Create Storage Partition and attach it to replicationpolicy. |
| 119 | ibm.storage_virtualize.ibm_sv_manage_storage_partition: |
| 120 | clustername: "{{ users_data[0].cluster_ip }}" |
| 121 | token: "{{ primary_auth.token }}" |
| 122 | log_path: "{{ log_path | default('/tmp/ansiblePB.debug') }}" |
| 123 | name: "{{ partition_name }}" |
| 124 | state: "present" |
| 125 | replicationpolicy: "{{ ha_policy_name }}" |
| 126 | |
| 127 | - name: Create volume group |
| 128 | ibm.storage_virtualize.ibm_svc_manage_volumegroup: |
| 129 | clustername: "{{ users_data[0].cluster_ip }}" |
| 130 | token: "{{ primary_auth.token }}" |
| 131 | log_path: "{{ log_path | default('/tmp/ansiblePB.debug') }}" |
| 132 | name: "{{ volume_group_name }}" |
| 133 | partition: "{{ partition_name }}" |
| 134 | state: "present" |
| 135 | |
| 136 | - name: Create volumes and add to volumegroup |
| 137 | ibm.storage_virtualize.ibm_svc_manage_volume: |
| 138 | clustername: "{{ users_data[0].cluster_ip }}" |
| 139 | token: "{{ primary_auth.token }}" |
| 140 | log_path: "{{ log_path | default('/tmp/ansiblePB.debug') }}" |
| 141 | name: "{{ vol_prefix }}{{ item }}" |
| 142 | state: "present" |
| 143 | pool: "{{ pool_name }}" |
| 144 | size: "{{ volume_size }}" |
| 145 | unit: "gb" |
| 146 | volumegroup: "{{ volume_group_name }}" |
| 147 | with_sequence: start=1 end="{{ volume_count }}" |
| 148 | |
| 149 | - name: Define a new FC host |
| 150 | ibm.storage_virtualize.ibm_svc_host: |
| 151 | clustername: "{{ users_data[0].cluster_ip }}" |
| 152 | token: "{{ primary_auth.token }}" |
| 153 | log_path: "{{ log_path | default('/tmp/ansiblePB.debug') }}" |
| 154 | name: "{{ host_name }}" |
| 155 | state: "present" |
| 156 | fcwwpn: "{{ fcwwpn }}" |
| 157 | partition: "{{ partition_name }}" |
| 158 | |
| 159 | - name: MasterVdisks-host mapping |
| 160 | register: results |
| 161 | ibm.storage_virtualize.ibm_svc_vol_map: |
| 162 | clustername: "{{ users_data[0].cluster_ip }}" |
| 163 | token: "{{ primary_auth.token }}" |
| 164 | log_path: "{{ log_path | default('/tmp/ansiblePB.debug') }}" |
| 165 | state: "present" |
| 166 | volname: "{{ vol_prefix }}{{ item }}" |
| 167 | host: "{{ host_name }}" |
| 168 | with_sequence: start=1 end="{{ volume_count }}" |