| 1 |
--- |
| 2 |
- name: ensure vlan pool does not exist for tests to kick off |
| 3 |
cisco.aci.aci_encap_pool: &aci_pool_absent_static |
| 4 |
host: "{{ aci_hostname }}" |
| 5 |
username: "{{ aci_username }}" |
| 6 |
password: "{{ aci_password }}" |
| 7 |
validate_certs: '{{ aci_validate_certs | default(false) }}' |
| 8 |
use_ssl: '{{ aci_use_ssl | default(true) }}' |
| 9 |
use_proxy: '{{ aci_use_proxy | default(true) }}' |
| 10 |
output_level: debug |
| 11 |
state: absent |
| 12 |
pool: anstest |
| 13 |
pool_type: vlan |
| 14 |
pool_allocation_mode: static |
| 15 |
|
| 16 |
- name: ensure vlan pool does not exist for tests to kick off |
| 17 |
cisco.aci.aci_encap_pool: &aci_pool_absent_dynamic |
| 18 |
<<: *aci_pool_absent_static |
| 19 |
pool_allocation_mode: dynamic |
| 20 |
|
| 21 |
- name: create static vlan pool - check mode works |
| 22 |
cisco.aci.aci_encap_pool: &aci_pool_present_static |
| 23 |
<<: *aci_pool_absent_static |
| 24 |
state: present |
| 25 |
descr: Ansible Test |
| 26 |
check_mode: true |
| 27 |
register: create_check_mode |
| 28 |
|
| 29 |
- name: assertion test - present |
| 30 |
ansible.builtin.assert: |
| 31 |
that: |
| 32 |
- create_check_mode is changed |
| 33 |
- create_check_mode.sent.fvnsVlanInstP.attributes.allocMode == 'static' |
| 34 |
- create_check_mode.sent.fvnsVlanInstP.attributes.descr == 'Ansible Test' |
| 35 |
- create_check_mode.sent.fvnsVlanInstP.attributes.name == 'anstest' |
| 36 |
|
| 37 |
- name: create static vlan pool - creation works |
| 38 |
cisco.aci.aci_encap_pool: |
| 39 |
<<: *aci_pool_present_static |
| 40 |
register: create_static |
| 41 |
|
| 42 |
- name: assertion test - present |
| 43 |
ansible.builtin.assert: |
| 44 |
that: |
| 45 |
- create_static is changed |
| 46 |
- create_static.previous == [] |
| 47 |
- create_static.sent == create_check_mode.sent |
| 48 |
|
| 49 |
- name: create dynamic vlan pool - creation works |
| 50 |
cisco.aci.aci_encap_pool: &aci_pool_present_dynamic |
| 51 |
<<: *aci_pool_absent_dynamic |
| 52 |
state: present |
| 53 |
descr: Ansible Test |
| 54 |
register: create_dynamic |
| 55 |
|
| 56 |
- name: assertion test - present |
| 57 |
ansible.builtin.assert: |
| 58 |
that: |
| 59 |
- create_dynamic is changed |
| 60 |
- create_dynamic.previous == [] |
| 61 |
- create_dynamic.sent.fvnsVlanInstP.attributes.allocMode == 'dynamic' |
| 62 |
- create_dynamic.sent.fvnsVlanInstP.attributes.descr == 'Ansible Test' |
| 63 |
- create_dynamic.sent.fvnsVlanInstP.attributes.name == 'anstest' |
| 64 |
- create_dynamic.current.0.fvnsVlanInstP.attributes.annotation == 'orchestrator:ansible' |
| 65 |
|
| 66 |
- name: create static vlan pool again - idempotency works |
| 67 |
cisco.aci.aci_encap_pool: |
| 68 |
<<: *aci_pool_present_static |
| 69 |
register: idempotent_static |
| 70 |
|
| 71 |
- name: assertion test - present |
| 72 |
ansible.builtin.assert: |
| 73 |
that: |
| 74 |
- idempotent_static is not changed |
| 75 |
- idempotent_static.previous.0.fvnsVlanInstP.attributes.allocMode == 'static' |
| 76 |
- idempotent_static.previous.0.fvnsVlanInstP.attributes.descr == 'Ansible Test' |
| 77 |
- idempotent_static.previous.0.fvnsVlanInstP.attributes.dn == 'uni/infra/vlanns-[anstest]-static' |
| 78 |
- idempotent_static.previous.0.fvnsVlanInstP.attributes.name == 'anstest' |
| 79 |
- idempotent_static.sent == {} |
| 80 |
|
| 81 |
- name: create dynamic vlan pool again - idempotency works |
| 82 |
cisco.aci.aci_encap_pool: |
| 83 |
<<: *aci_pool_present_dynamic |
| 84 |
register: idempotent_dynamic |
| 85 |
|
| 86 |
- name: assertion test - present |
| 87 |
ansible.builtin.assert: |
| 88 |
that: |
| 89 |
- idempotent_dynamic is not changed |
| 90 |
- idempotent_dynamic.previous.0.fvnsVlanInstP.attributes.allocMode == 'dynamic' |
| 91 |
- idempotent_dynamic.previous.0.fvnsVlanInstP.attributes.descr == 'Ansible Test' |
| 92 |
- idempotent_dynamic.previous.0.fvnsVlanInstP.attributes.dn == 'uni/infra/vlanns-[anstest]-dynamic' |
| 93 |
- idempotent_dynamic.previous.0.fvnsVlanInstP.attributes.name == 'anstest' |
| 94 |
- idempotent_dynamic.sent == {} |
| 95 |
|
| 96 |
- name: update static vlan pool - update works |
| 97 |
cisco.aci.aci_encap_pool: |
| 98 |
<<: *aci_pool_present_static |
| 99 |
descr: Ansible Test Change |
| 100 |
register: update_static |
| 101 |
|
| 102 |
- name: assertion test - present |
| 103 |
ansible.builtin.assert: |
| 104 |
that: |
| 105 |
- update_static is changed |
| 106 |
- update_static.sent.fvnsVlanInstP.attributes.descr == 'Ansible Test Change' |
| 107 |
|
| 108 |
- name: update dynamic vlan pool - update works |
| 109 |
cisco.aci.aci_encap_pool: |
| 110 |
<<: *aci_pool_present_dynamic |
| 111 |
descr: Ansible Test Change |
| 112 |
register: update_dynamic |
| 113 |
|
| 114 |
- name: assertion test - present |
| 115 |
ansible.builtin.assert: |
| 116 |
that: |
| 117 |
- update_dynamic is changed |
| 118 |
- update_dynamic.sent.fvnsVlanInstP.attributes.descr == 'Ansible Test Change' |
| 119 |
|
| 120 |
- name: missing param - failure message works |
| 121 |
cisco.aci.aci_encap_pool: |
| 122 |
<<: *aci_pool_present_dynamic |
| 123 |
pool_allocation_mode: "{{ fake_var | default(omit) }}" |
| 124 |
ignore_errors: true |
| 125 |
register: vlan_alloc_fail |
| 126 |
|
| 127 |
- name: assertion test - present |
| 128 |
ansible.builtin.assert: |
| 129 |
that: |
| 130 |
- vlan_alloc_fail is failed |
| 131 |
- "vlan_alloc_fail.msg == 'ACI requires parameter \\'pool_allocation_mode\\' for \\'pool_type\\' of \\'vlan\\' and \\'vsan\\' when parameter \\'pool\\' is provided'" |
| 132 |
|
| 133 |
- name: missing param - failure message works |
| 134 |
cisco.aci.aci_encap_pool: |
| 135 |
<<: *aci_pool_present_dynamic |
| 136 |
pool: "{{ fake_var | default(omit) }}" |
| 137 |
ignore_errors: true |
| 138 |
register: vlan_pool_fail |
| 139 |
|
| 140 |
- name: assertion test - present |
| 141 |
ansible.builtin.assert: |
| 142 |
that: |
| 143 |
- vlan_pool_fail is failed |
| 144 |
- 'vlan_pool_fail.msg == "state is present but all of the following are missing: pool"' |
| 145 |
|
| 146 |
- name: missing param - failure message works |
| 147 |
cisco.aci.aci_encap_pool: |
| 148 |
<<: *aci_pool_present_dynamic |
| 149 |
pool_type: "{{ fake_var | default(omit) }}" |
| 150 |
ignore_errors: true |
| 151 |
register: vlan_pool_type_fail |
| 152 |
|
| 153 |
- name: assertion test - present |
| 154 |
ansible.builtin.assert: |
| 155 |
that: |
| 156 |
- vlan_pool_type_fail is failed |
| 157 |
- 'vlan_pool_type_fail.msg == "missing required arguments: pool_type"' |
| 158 |
|
| 159 |
- name: get all vlan pools - get class works |
| 160 |
cisco.aci.aci_encap_pool: |
| 161 |
<<: *aci_pool_absent_static |
| 162 |
state: query |
| 163 |
pool: "{{ fake_var | default(omit) }}" |
| 164 |
pool_allocation_mode: "{{ fake_var | default(omit) }}" |
| 165 |
register: get_all_pools |
| 166 |
|
| 167 |
- name: assertion test - query |
| 168 |
ansible.builtin.assert: |
| 169 |
that: |
| 170 |
- get_all_pools is not changed |
| 171 |
- get_all_pools.method == "GET" |
| 172 |
- get_all_pools.current | length > 1 |
| 173 |
|
| 174 |
- name: get created static vlan pool - get mo works |
| 175 |
cisco.aci.aci_encap_pool: |
| 176 |
<<: *aci_pool_absent_static |
| 177 |
state: query |
| 178 |
register: get_static_pool |
| 179 |
|
| 180 |
- name: assertion test - query |
| 181 |
ansible.builtin.assert: |
| 182 |
that: |
| 183 |
- get_static_pool is not changed |
| 184 |
- get_static_pool.method == "GET" |
| 185 |
- get_static_pool.current | length == 1 |
| 186 |
- get_static_pool.current.0.fvnsVlanInstP.attributes.allocMode == "static" |
| 187 |
- get_static_pool.current.0.fvnsVlanInstP.attributes.name == "anstest" |
| 188 |
|
| 189 |
- name: get created dynamic vlan pool - get mo works |
| 190 |
cisco.aci.aci_encap_pool: |
| 191 |
<<: *aci_pool_absent_dynamic |
| 192 |
state: query |
| 193 |
register: get_dynamic_pool |
| 194 |
|
| 195 |
- name: assertion test - query |
| 196 |
ansible.builtin.assert: |
| 197 |
that: |
| 198 |
- get_dynamic_pool is not changed |
| 199 |
- get_dynamic_pool.method == "GET" |
| 200 |
- get_dynamic_pool.current | length == 1 |
| 201 |
- get_dynamic_pool.current.0.fvnsVlanInstP.attributes.allocMode == "dynamic" |
| 202 |
- get_dynamic_pool.current.0.fvnsVlanInstP.attributes.name == "anstest" |
| 203 |
|
| 204 |
- name: get created dynamic vlan pool - get mo works |
| 205 |
cisco.aci.aci_encap_pool: |
| 206 |
<<: *aci_pool_absent_dynamic |
| 207 |
state: query |
| 208 |
pool_type: "{{ fake_var | default(omit) }}" |
| 209 |
ignore_errors: true |
| 210 |
register: vlan_query_pool_type_fail |
| 211 |
|
| 212 |
- name: assertion test - query |
| 213 |
ansible.builtin.assert: |
| 214 |
that: |
| 215 |
- vlan_query_pool_type_fail is failed |
| 216 |
- 'vlan_query_pool_type_fail.msg == "missing required arguments: pool_type"' |
| 217 |
|
| 218 |
- name: delete static vlan pool - deletion works |
| 219 |
cisco.aci.aci_encap_pool: |
| 220 |
<<: *aci_pool_absent_static |
| 221 |
register: delete_static |
| 222 |
|
| 223 |
- name: assertion test - absent |
| 224 |
ansible.builtin.assert: |
| 225 |
that: |
| 226 |
- delete_static is changed |
| 227 |
- delete_static.method == "DELETE" |
| 228 |
- delete_static.previous.0.fvnsVlanInstP.attributes.allocMode == "static" |
| 229 |
- delete_static.previous.0.fvnsVlanInstP.attributes.name == "anstest" |
| 230 |
|
| 231 |
- name: delete dynamic vlan pool - check mode works |
| 232 |
cisco.aci.aci_encap_pool: |
| 233 |
<<: *aci_pool_absent_dynamic |
| 234 |
check_mode: true |
| 235 |
register: delete_check_mode |
| 236 |
|
| 237 |
- name: assertion test - absent |
| 238 |
ansible.builtin.assert: |
| 239 |
that: |
| 240 |
- delete_check_mode is changed |
| 241 |
|
| 242 |
- name: delete dynamic vlan pool - deletion works |
| 243 |
cisco.aci.aci_encap_pool: |
| 244 |
<<: *aci_pool_absent_dynamic |
| 245 |
register: delete_dynamic |
| 246 |
|
| 247 |
- name: assertion test - absent |
| 248 |
ansible.builtin.assert: |
| 249 |
that: |
| 250 |
- delete_dynamic is changed |
| 251 |
- delete_dynamic.method == "DELETE" |
| 252 |
- delete_dynamic.previous.0.fvnsVlanInstP.attributes.allocMode == "dynamic" |
| 253 |
- delete_dynamic.previous.0.fvnsVlanInstP.attributes.name == "anstest" |
| 254 |
|
| 255 |
- name: delete static vlan pool again - idempotency works |
| 256 |
cisco.aci.aci_encap_pool: |
| 257 |
<<: *aci_pool_absent_static |
| 258 |
register: idempotent_delete_static |
| 259 |
|
| 260 |
- name: assertion test - absent |
| 261 |
ansible.builtin.assert: |
| 262 |
that: |
| 263 |
- idempotent_delete_static is not changed |
| 264 |
- idempotent_delete_static.previous == [] |
| 265 |
|
| 266 |
- name: delete dynamic vlan pool again - idempotency works |
| 267 |
cisco.aci.aci_encap_pool: |
| 268 |
<<: *aci_pool_absent_dynamic |
| 269 |
register: idempotent_delete_dynamic |
| 270 |
|
| 271 |
- name: assertion test - absent |
| 272 |
ansible.builtin.assert: |
| 273 |
that: |
| 274 |
- idempotent_delete_dynamic is not changed |
| 275 |
- idempotent_delete_dynamic.previous == [] |