| 1 |
--- |
| 2 |
- block: |
| 3 |
- name: Define anchor for Intersight API login info |
| 4 |
ansible.builtin.set_fact: |
| 5 |
api_info: &api_info |
| 6 |
api_private_key: "{{ api_private_key }}" |
| 7 |
api_key_id: "{{ api_key_id }}" |
| 8 |
api_uri: "{{ api_uri | default(omit) }}" |
| 9 |
validate_certs: "{{ validate_certs | default(omit) }}" |
| 10 |
organization: "{{ organization }}" |
| 11 |
|
| 12 |
- name: Make sure Env is clean |
| 13 |
cisco.intersight.intersight_wwn_pool: |
| 14 |
<<: *api_info |
| 15 |
name: "{{ item.pool_name }}" |
| 16 |
pool_purpose: "{{ item.pool_purpose }}" |
| 17 |
state: absent |
| 18 |
loop: |
| 19 |
- { pool_name: test_wwn_pool, pool_purpose: "WWNN" } |
| 20 |
- { pool_name: test_wwn_pool, pool_purpose: "WWPN" } |
| 21 |
|
| 22 |
- name: Create WWNN pool - check-mode |
| 23 |
cisco.intersight.intersight_wwn_pool: |
| 24 |
<<: *api_info |
| 25 |
name: test_wwn_pool |
| 26 |
description: "Test wwnn pool description" |
| 27 |
tags: |
| 28 |
- "Key": "Site" |
| 29 |
"Value": "Test" |
| 30 |
pool_purpose: "WWNN" |
| 31 |
id_blocks: |
| 32 |
- "wwn_from": "20:00:00:25:B5:00:00:00" |
| 33 |
"size": 100 |
| 34 |
- "wwn_from": "20:00:00:25:B5:FF:00:00" |
| 35 |
"size": 100 |
| 36 |
check_mode: true |
| 37 |
register: creation_res_check_mode |
| 38 |
|
| 39 |
- name: Verify WWNN pool was not created - check-mode |
| 40 |
ansible.builtin.assert: |
| 41 |
that: |
| 42 |
- creation_res_check_mode is changed |
| 43 |
- creation_res_check_mode.api_response == {} |
| 44 |
|
| 45 |
- name: Create WWNN pool |
| 46 |
cisco.intersight.intersight_wwn_pool: |
| 47 |
<<: *api_info |
| 48 |
name: test_wwn_pool |
| 49 |
description: "Test wwnn pool description" |
| 50 |
tags: |
| 51 |
- "Key": "Site" |
| 52 |
"Value": "Test" |
| 53 |
pool_purpose: "WWNN" |
| 54 |
id_blocks: |
| 55 |
- "wwn_from": "20:00:00:25:B5:00:00:00" |
| 56 |
"size": 100 |
| 57 |
- "wwn_from": "20:00:00:25:B5:FF:00:00" |
| 58 |
"size": 100 |
| 59 |
register: creation_res |
| 60 |
|
| 61 |
- name: Fetch WWNN pool info after creation |
| 62 |
cisco.intersight.intersight_wwn_pool_info: |
| 63 |
<<: *api_info |
| 64 |
name: test_wwn_pool |
| 65 |
pool_purpose: "WWNN" |
| 66 |
register: creation_info_res_a |
| 67 |
|
| 68 |
- name: Verify WWNN pool creation by info |
| 69 |
ansible.builtin.assert: |
| 70 |
that: |
| 71 |
- creation_res.changed |
| 72 |
- creation_info_res_a.api_response[0].Name == 'test_wwn_pool' |
| 73 |
- creation_info_res_a.api_response[0].PoolPurpose == 'WWNN' |
| 74 |
- creation_info_res_a.api_response[0].IdBlocks[0]["Size"] == 100 |
| 75 |
- creation_info_res_a.api_response[0].IdBlocks[0]["From"] == "20:00:00:25:B5:00:00:00" |
| 76 |
- creation_info_res_a.api_response[0].IdBlocks[1]["Size"] == 100 |
| 77 |
- creation_info_res_a.api_response[0].IdBlocks[1]["From"] == "20:00:00:25:B5:FF:00:00" |
| 78 |
|
| 79 |
- name: Verify WWNN pool creation response aligns with info response |
| 80 |
ansible.builtin.assert: |
| 81 |
that: |
| 82 |
- creation_res.api_response.Name == creation_info_res_a.api_response[0].Name |
| 83 |
- creation_res.api_response.PoolPurpose == creation_info_res_a.api_response[0].PoolPurpose |
| 84 |
- creation_res.api_response.IdBlocks[0]["Size"] == creation_info_res_a.api_response[0].IdBlocks[0]["Size"] |
| 85 |
- creation_res.api_response.IdBlocks[0]["From"] == creation_info_res_a.api_response[0].IdBlocks[0]["From"] |
| 86 |
|
| 87 |
- name: Create WWNN pool (idempotency check) |
| 88 |
cisco.intersight.intersight_wwn_pool: |
| 89 |
<<: *api_info |
| 90 |
name: test_wwn_pool |
| 91 |
description: "Test wwnn pool description" |
| 92 |
tags: |
| 93 |
- "Key": "Site" |
| 94 |
"Value": "Test" |
| 95 |
pool_purpose: "WWNN" |
| 96 |
id_blocks: |
| 97 |
- "wwn_from": "20:00:00:25:B5:00:00:00" |
| 98 |
"size": 100 |
| 99 |
- "wwn_from": "20:00:00:25:B5:FF:00:00" |
| 100 |
"size": 100 |
| 101 |
register: creation_res_ide |
| 102 |
|
| 103 |
- name: Verify WWNN pool creation (idempotency check) |
| 104 |
ansible.builtin.assert: |
| 105 |
that: |
| 106 |
- not creation_res_ide.changed |
| 107 |
|
| 108 |
- name: Create WWPN pool with the same pool name |
| 109 |
cisco.intersight.intersight_wwn_pool: |
| 110 |
<<: *api_info |
| 111 |
name: test_wwn_pool |
| 112 |
description: "Test wwpn pool description" |
| 113 |
tags: |
| 114 |
- "Key": "Site" |
| 115 |
"Value": "Test" |
| 116 |
pool_purpose: "WWPN" |
| 117 |
id_blocks: |
| 118 |
- "wwn_from": "20:00:00:25:B5:00:BB:00" |
| 119 |
"size": 200 |
| 120 |
- "wwn_from": "20:00:00:25:B5:FF:BB:00" |
| 121 |
"size": 200 |
| 122 |
register: creation_res |
| 123 |
|
| 124 |
- name: Fetch WWPN pool info after creation |
| 125 |
cisco.intersight.intersight_wwn_pool_info: |
| 126 |
<<: *api_info |
| 127 |
name: test_wwn_pool |
| 128 |
pool_purpose: "WWPN" |
| 129 |
register: creation_info_res_b |
| 130 |
|
| 131 |
- name: Verify WWPN pool creation by info |
| 132 |
ansible.builtin.assert: |
| 133 |
that: |
| 134 |
- creation_res.changed |
| 135 |
- creation_info_res_b.api_response[0].Name == 'test_wwn_pool' |
| 136 |
- creation_info_res_b.api_response[0].PoolPurpose == 'WWPN' |
| 137 |
- creation_info_res_b.api_response[0].IdBlocks[0]["Size"] == 200 |
| 138 |
- creation_info_res_b.api_response[0].IdBlocks[0]["From"] == "20:00:00:25:B5:00:BB:00" |
| 139 |
- creation_info_res_b.api_response[0].IdBlocks[1]["Size"] == 200 |
| 140 |
- creation_info_res_b.api_response[0].IdBlocks[1]["From"] == "20:00:00:25:B5:FF:BB:00" |
| 141 |
|
| 142 |
- name: Verify WWPN pool creation response aligns with info response |
| 143 |
ansible.builtin.assert: |
| 144 |
that: |
| 145 |
- creation_res.api_response.Name == creation_info_res_b.api_response[0].Name |
| 146 |
- creation_res.api_response.PoolPurpose == creation_info_res_b.api_response[0].PoolPurpose |
| 147 |
- creation_res.api_response.IdBlocks[0]["Size"] == creation_info_res_b.api_response[0].IdBlocks[0]["Size"] |
| 148 |
- creation_res.api_response.IdBlocks[0]["From"] == creation_info_res_b.api_response[0].IdBlocks[0]["From"] |
| 149 |
|
| 150 |
|
| 151 |
- name: Validate failure due to missing id_blocks |
| 152 |
cisco.intersight.intersight_wwn_pool: |
| 153 |
<<: *api_info |
| 154 |
name: test_wwn_pool_validate |
| 155 |
description: "Test wwn pool description" |
| 156 |
tags: |
| 157 |
- "Key": "Site" |
| 158 |
"Value": "Test" |
| 159 |
- "Key": "Site2" |
| 160 |
"Value": "Test3" |
| 161 |
state: present |
| 162 |
pool_purpose: "WWPN" |
| 163 |
register: failure_res |
| 164 |
failed_when: |
| 165 |
- "'wwn id_blocks parameter must be provided and contain at least one block' not in failure_res.msg" |
| 166 |
|
| 167 |
- name: Validate failure due to missing pool_purpose |
| 168 |
cisco.intersight.intersight_wwn_pool: |
| 169 |
<<: *api_info |
| 170 |
name: test_wwn_pool_validate |
| 171 |
description: "Test wwn pool description" |
| 172 |
tags: |
| 173 |
- "Key": "Site" |
| 174 |
"Value": "Test" |
| 175 |
- "Key": "Site2" |
| 176 |
"Value": "Test3" |
| 177 |
state: present |
| 178 |
id_blocks: |
| 179 |
- "wwn_from": "20:00:00:25:B5:00:BB:00" |
| 180 |
"size": 200 |
| 181 |
- "wwn_from": "20:00:00:25:B5:FF:BB:00" |
| 182 |
"size": 200 |
| 183 |
register: failure_res |
| 184 |
failed_when: |
| 185 |
- "'missing required arguments: pool_purpose' not in failure_res.msg" |
| 186 |
|
| 187 |
- name: Fetch all wwn pools under default organization |
| 188 |
cisco.intersight.intersight_wwn_pool_info: |
| 189 |
<<: *api_info |
| 190 |
register: creation_info_res_c |
| 191 |
|
| 192 |
- name: Check that there are at least 2 wwn pools under this organization |
| 193 |
ansible.builtin.assert: |
| 194 |
that: |
| 195 |
- creation_info_res_c.api_response | length > 1 |
| 196 |
|
| 197 |
- name: Fetch all wwn pools with the same name |
| 198 |
cisco.intersight.intersight_wwn_pool_info: |
| 199 |
<<: *api_info |
| 200 |
name: test_wwn_pool |
| 201 |
register: creation_info_res_d |
| 202 |
|
| 203 |
- name: Check that there are at least 2 wwn pools with this name |
| 204 |
ansible.builtin.assert: |
| 205 |
that: |
| 206 |
- creation_info_res_d.api_response | length > 1 |
| 207 |
|
| 208 |
- name: Fetch 1 WWPN pool |
| 209 |
cisco.intersight.intersight_wwn_pool_info: |
| 210 |
<<: *api_info |
| 211 |
name: test_wwn_pool |
| 212 |
pool_purpose: "WWPN" |
| 213 |
register: creation_info_res_e |
| 214 |
|
| 215 |
- name: Check that there are at least 2 wwn pools with this name |
| 216 |
ansible.builtin.assert: |
| 217 |
that: |
| 218 |
- creation_info_res_e.api_response | length == 1 |
| 219 |
|
| 220 |
always: |
| 221 |
- name: Remove wwn pools |
| 222 |
cisco.intersight.intersight_wwn_pool: |
| 223 |
<<: *api_info |
| 224 |
name: "{{ item.pool_name }}" |
| 225 |
pool_purpose: "{{ item.pool_purpose }}" |
| 226 |
state: absent |
| 227 |
loop: |
| 228 |
- { pool_name: test_wwn_pool, pool_purpose: "WWNN" } |
| 229 |
- { pool_name: test_wwn_pool, pool_purpose: "WWPN" } |