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