| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
- name: Test that we have an ACI APIC host, ACI username and ACI password |
| 6 |
ansible.builtin.fail: |
| 7 |
msg: "Please define the following variables: aci_hostname, aci_username and aci_password." |
| 8 |
when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined |
| 9 |
|
| 10 |
- name: Set vars |
| 11 |
ansible.builtin.set_fact: |
| 12 |
aci_info: &aci_info |
| 13 |
host: "{{ aci_hostname }}" |
| 14 |
username: "{{ aci_username }}" |
| 15 |
password: "{{ aci_password }}" |
| 16 |
validate_certs: "{{ aci_validate_certs | default(false) }}" |
| 17 |
use_ssl: "{{ aci_use_ssl | default(true) }}" |
| 18 |
use_proxy: "{{ aci_use_proxy | default(true) }}" |
| 19 |
output_level: "{{ aci_output_level | default('info') }}" |
| 20 |
|
| 21 |
|
| 22 |
- name: Remove tenant |
| 23 |
cisco.aci.aci_rest: &tenant_absent |
| 24 |
<<: *aci_info |
| 25 |
path: /api/mo/uni/tn-[ansible_test].json |
| 26 |
method: delete |
| 27 |
|
| 28 |
|
| 29 |
- name: Add tenant (check mode) |
| 30 |
cisco.aci.aci_rest: &tenant_present |
| 31 |
<<: *aci_info |
| 32 |
path: /api/mo/uni.json |
| 33 |
method: post |
| 34 |
content: |
| 35 |
fvTenant: |
| 36 |
attributes: |
| 37 |
name: ansible_test |
| 38 |
register: cm_add_tenant |
| 39 |
check_mode: true |
| 40 |
|
| 41 |
- name: Verify checkmode did not create tenant |
| 42 |
cisco.aci.aci_tenant: |
| 43 |
<<: *aci_info |
| 44 |
name: ansible_test |
| 45 |
state: query |
| 46 |
register: cm_verify_checkmode_tenant |
| 47 |
|
| 48 |
- name: Verify checkmode POST operation |
| 49 |
ansible.builtin.assert: |
| 50 |
that: |
| 51 |
- cm_add_tenant is changed |
| 52 |
- cm_add_tenant.proposed.fvTenant.attributes.name == "ansible_test" |
| 53 |
- cm_add_tenant.proposed.fvTenant.attributes.annotation == "orchestrator:ansible" |
| 54 |
- cm_verify_checkmode_tenant.current == [] |
| 55 |
|
| 56 |
- name: Add tenant (normal mode) |
| 57 |
cisco.aci.aci_rest: *tenant_present |
| 58 |
register: nm_add_tenant |
| 59 |
|
| 60 |
- name: Add tenant again (normal mode) |
| 61 |
cisco.aci.aci_rest: *tenant_present |
| 62 |
register: nm_add_tenant_again |
| 63 |
|
| 64 |
- name: Verify add_tenant |
| 65 |
ansible.builtin.assert: |
| 66 |
that: |
| 67 |
- nm_add_tenant is changed |
| 68 |
- nm_add_tenant_again is not changed |
| 69 |
|
| 70 |
|
| 71 |
- name: Change description of tenant (normal mode) |
| 72 |
cisco.aci.aci_rest: &tenant_changed |
| 73 |
<<: *aci_info |
| 74 |
path: /api/mo/uni.json |
| 75 |
method: post |
| 76 |
content: |
| 77 |
fvTenant: |
| 78 |
attributes: |
| 79 |
name: ansible_test |
| 80 |
descr: Ansible test tenant |
| 81 |
register: nm_add_tenant_descr |
| 82 |
|
| 83 |
- name: Change description of tenant again (normal mode) |
| 84 |
cisco.aci.aci_rest: *tenant_changed |
| 85 |
register: nm_add_tenant_descr_again |
| 86 |
|
| 87 |
- name: Verify add_tenant_descr |
| 88 |
ansible.builtin.assert: |
| 89 |
that: |
| 90 |
- nm_add_tenant_descr is changed |
| 91 |
- nm_add_tenant.imdata.0.fvTenant.attributes.annotation == "orchestrator:ansible" |
| 92 |
- nm_add_tenant_descr_again is not changed |
| 93 |
|
| 94 |
|
| 95 |
- name: Add tenant again with no description (normal mode) |
| 96 |
cisco.aci.aci_rest: *tenant_present |
| 97 |
register: nm_add_tenant_again_no_descr |
| 98 |
|
| 99 |
- name: Verify add_tenant_again_no_descr |
| 100 |
ansible.builtin.assert: |
| 101 |
that: |
| 102 |
- nm_add_tenant_again_no_descr is not changed |
| 103 |
|
| 104 |
|
| 105 |
- name: Query all tenants (normal mode) |
| 106 |
cisco.aci.aci_rest: &tenant_query_all |
| 107 |
<<: *aci_info |
| 108 |
path: /api/mo/uni/tn-[ansible_test].json |
| 109 |
method: get |
| 110 |
register: nm_query_all_tenants |
| 111 |
|
| 112 |
- name: Verify query_all_tenants |
| 113 |
ansible.builtin.assert: |
| 114 |
that: |
| 115 |
- nm_query_all_tenants is not changed |
| 116 |
|
| 117 |
|
| 118 |
- name: Query our tenant |
| 119 |
cisco.aci.aci_rest: &tenant_query |
| 120 |
<<: *aci_info |
| 121 |
path: /api/mo/uni/tn-[ansible_test].json |
| 122 |
method: get |
| 123 |
register: nm_query_tenant |
| 124 |
|
| 125 |
- name: Verify query_tenant |
| 126 |
ansible.builtin.assert: |
| 127 |
that: |
| 128 |
- nm_query_tenant is not changed |
| 129 |
|
| 130 |
|
| 131 |
- name: Remove tenant (normal mode) |
| 132 |
cisco.aci.aci_rest: *tenant_absent |
| 133 |
register: nm_remove_tenant |
| 134 |
|
| 135 |
- name: Remove tenant again (normal mode) |
| 136 |
cisco.aci.aci_rest: *tenant_absent |
| 137 |
register: nm_remove_tenant_again |
| 138 |
|
| 139 |
- name: Verify remove_tenant |
| 140 |
ansible.builtin.assert: |
| 141 |
that: |
| 142 |
- nm_remove_tenant is changed |
| 143 |
- nm_remove_tenant_again is not changed |
| 144 |
|
| 145 |
|
| 146 |
- name: Query non-existing tenant (normal mode) |
| 147 |
cisco.aci.aci_rest: *tenant_query |
| 148 |
register: nm_query_non_tenant |
| 149 |
|
| 150 |
- name: Verify query_non_tenant |
| 151 |
ansible.builtin.assert: |
| 152 |
that: |
| 153 |
- nm_query_non_tenant is not changed |
| 154 |
|
| 155 |
|
| 156 |
- name: Add tenant with annotation option |
| 157 |
cisco.aci.aci_rest: |
| 158 |
<<: *aci_info |
| 159 |
path: /api/mo/uni.json |
| 160 |
method: post |
| 161 |
annotation: test:inoption |
| 162 |
content: |
| 163 |
fvTenant: |
| 164 |
attributes: |
| 165 |
descr: Ansible test tenant |
| 166 |
name: ansible_test |
| 167 |
register: nm_add_tenant_annotation_option |
| 168 |
|
| 169 |
- name: Add tenant with annotation in content |
| 170 |
cisco.aci.aci_rest: |
| 171 |
<<: *aci_info |
| 172 |
path: /api/mo/uni.json |
| 173 |
method: post |
| 174 |
content: |
| 175 |
fvTenant: |
| 176 |
attributes: |
| 177 |
descr: Ansible test tenant |
| 178 |
name: ansible_test |
| 179 |
annotation: test:incontent |
| 180 |
register: nm_add_tenant_annotation_content |
| 181 |
|
| 182 |
- name: Add tenant with annotation in content and option |
| 183 |
cisco.aci.aci_rest: |
| 184 |
<<: *aci_info |
| 185 |
path: /api/mo/uni.json |
| 186 |
method: post |
| 187 |
annotation: test:inoption |
| 188 |
content: |
| 189 |
fvTenant: |
| 190 |
attributes: |
| 191 |
descr: Ansible test tenant |
| 192 |
name: ansible_test |
| 193 |
annotation: test:optionincontent |
| 194 |
register: nm_add_tenant_annotation_option_content |
| 195 |
|
| 196 |
- name: Add tag to tenant with annotation unsupported |
| 197 |
cisco.aci.aci_rest: |
| 198 |
<<: *aci_info |
| 199 |
path: /api/mo/uni/tn-ansible_test/tagKey-foo.json |
| 200 |
method: post |
| 201 |
annotation: test:inoption |
| 202 |
content: |
| 203 |
tagTag: |
| 204 |
attributes: |
| 205 |
value: bar |
| 206 |
register: nm_add_tag_no_annotation |
| 207 |
|
| 208 |
- name: Remove tenant |
| 209 |
cisco.aci.aci_rest: *tenant_absent |
| 210 |
|
| 211 |
- name: Add tenant with children objects including annotation |
| 212 |
cisco.aci.aci_rest: |
| 213 |
<<: *aci_info |
| 214 |
path: /api/mo/uni.json |
| 215 |
method: post |
| 216 |
annotation: test:inoption |
| 217 |
content: |
| 218 |
fvTenant: |
| 219 |
attributes: |
| 220 |
descr: Ansible test tenant |
| 221 |
name: ansible_test |
| 222 |
children: |
| 223 |
- fvCtx: |
| 224 |
attributes: |
| 225 |
name: VRF1 |
| 226 |
- fvAp: |
| 227 |
attributes: |
| 228 |
name: Application1 |
| 229 |
children: |
| 230 |
- fvAEPg: |
| 231 |
attributes: |
| 232 |
name: WebTier |
| 233 |
annotation: test:inchild |
| 234 |
register: nm_add_tenant_annotation_children |
| 235 |
|
| 236 |
- name: Verify annotation support |
| 237 |
assert: |
| 238 |
that: |
| 239 |
- nm_add_tenant_annotation_option.imdata.0.fvTenant.attributes.annotation == "test:inoption" |
| 240 |
- nm_add_tenant_annotation_content.imdata.0.fvTenant.attributes.annotation == "test:incontent" |
| 241 |
- nm_add_tenant_annotation_option_content.imdata.0.fvTenant.attributes.annotation == "test:optionincontent" |
| 242 |
- nm_add_tag_no_annotation.imdata.0.tagTag.attributes.annotation is undefined |
| 243 |
- nm_add_tenant_annotation_children.imdata.0.fvTenant.attributes.annotation == "test:inoption" |
| 244 |
- nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.attributes.annotation == "test:inoption" |
| 245 |
- nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.children.0.fvAEPg.attributes.annotation == "test:inchild" |
| 246 |
- nm_add_tenant_annotation_children.imdata.0.fvTenant.children.2.fvCtx.attributes.annotation == "test:inoption" |
| 247 |
|
| 248 |
|
| 249 |
- name: Ensure Port Channel interface policy does not exists |
| 250 |
cisco.aci.aci_rest: |
| 251 |
<<: *aci_info |
| 252 |
path: api/mo/uni/infra/lacpifp-link_aggregation_control_protocol.json |
| 253 |
method: delete |
| 254 |
register: rm_link_aggregation_control_protocol |
| 255 |
|
| 256 |
- name: Add Port Channel interface policy YML with prio attribute int value (check_mode) |
| 257 |
environment: |
| 258 |
ACI_NORMALIZE_PAYLOAD_VALUES: "true" |
| 259 |
cisco.aci.aci_rest: &cm_add_link_aggregation_control_protocol_yml |
| 260 |
<<: *aci_info |
| 261 |
path: api/mo/uni/infra/lacpifp-link_aggregation_control_protocol.json |
| 262 |
method: post |
| 263 |
content: |
| 264 |
lacpIfPol: |
| 265 |
attributes: |
| 266 |
name: "link_aggregation_control_protocol" |
| 267 |
prio: 32768 |
| 268 |
descr: "test" |
| 269 |
check_mode: true |
| 270 |
register: cm_add_link_aggregation_control_protocol |
| 271 |
|
| 272 |
- name: Add Port Channel interface policy YML with prio attribute int value |
| 273 |
environment: |
| 274 |
ACI_NORMALIZE_PAYLOAD_VALUES: "true" |
| 275 |
cisco.aci.aci_rest: |
| 276 |
<<: *cm_add_link_aggregation_control_protocol_yml |
| 277 |
register: nm_add_link_aggregation_control_protocol |
| 278 |
|
| 279 |
- name: Add Port Channel interface policy YML with prio attribute int value again |
| 280 |
environment: |
| 281 |
ACI_NORMALIZE_PAYLOAD_VALUES: "true" |
| 282 |
cisco.aci.aci_rest: |
| 283 |
<<: *cm_add_link_aggregation_control_protocol_yml |
| 284 |
register: nm_add_link_aggregation_control_protocol_again |
| 285 |
|
| 286 |
- name: Delete Port Channel interface policy |
| 287 |
cisco.aci.aci_rest: |
| 288 |
<<: *aci_info |
| 289 |
path: api/mo/uni/infra/lacpifp-link_aggregation_control_protocol.json |
| 290 |
method: delete |
| 291 |
register: rm_link_aggregation_control_protocol |
| 292 |
|
| 293 |
- name: Assertion check for add Port Channel interface policy YML with prio attribute int value |
| 294 |
ansible.builtin.assert: |
| 295 |
that: |
| 296 |
- cm_add_link_aggregation_control_protocol is changed |
| 297 |
- cm_add_link_aggregation_control_protocol.proposed.lacpIfPol.attributes.annotation == "orchestrator:ansible" |
| 298 |
- cm_add_link_aggregation_control_protocol.proposed.lacpIfPol.attributes.descr == "test" |
| 299 |
- cm_add_link_aggregation_control_protocol.proposed.lacpIfPol.attributes.name == "link_aggregation_control_protocol" |
| 300 |
- cm_add_link_aggregation_control_protocol.proposed.lacpIfPol.attributes.prio == "32768" |
| 301 |
- nm_add_link_aggregation_control_protocol is changed |
| 302 |
- nm_add_link_aggregation_control_protocol.imdata.0.lacpIfPol.attributes.annotation == "orchestrator:ansible" |
| 303 |
- nm_add_link_aggregation_control_protocol.imdata.0.lacpIfPol.attributes.descr == "test" |
| 304 |
- nm_add_link_aggregation_control_protocol.imdata.0.lacpIfPol.attributes.dn == "uni/infra/lacpifp-link_aggregation_control_protocol" |
| 305 |
- nm_add_link_aggregation_control_protocol.imdata.0.lacpIfPol.attributes.name == "link_aggregation_control_protocol" |
| 306 |
- nm_add_link_aggregation_control_protocol.imdata.0.lacpIfPol.attributes.prio == "32768" |
| 307 |
- nm_add_link_aggregation_control_protocol.imdata.0.lacpIfPol.attributes.rn == "" |
| 308 |
- nm_add_link_aggregation_control_protocol.imdata.0.lacpIfPol.attributes.status == "created" |
| 309 |
- nm_add_link_aggregation_control_protocol.proposed.lacpIfPol.attributes.annotation == "orchestrator:ansible" |
| 310 |
- nm_add_link_aggregation_control_protocol.proposed.lacpIfPol.attributes.descr == "test" |
| 311 |
- nm_add_link_aggregation_control_protocol.proposed.lacpIfPol.attributes.name == "link_aggregation_control_protocol" |
| 312 |
- nm_add_link_aggregation_control_protocol.proposed.lacpIfPol.attributes.prio == "32768" |
| 313 |
- nm_add_link_aggregation_control_protocol_again is not changed |
| 314 |
- nm_add_link_aggregation_control_protocol_again.imdata == [] |
| 315 |
- nm_add_link_aggregation_control_protocol_again.proposed.lacpIfPol.attributes.annotation == "orchestrator:ansible" |
| 316 |
- nm_add_link_aggregation_control_protocol_again.proposed.lacpIfPol.attributes.descr == "test" |
| 317 |
- nm_add_link_aggregation_control_protocol_again.proposed.lacpIfPol.attributes.name == "link_aggregation_control_protocol" |
| 318 |
- nm_add_link_aggregation_control_protocol_again.proposed.lacpIfPol.attributes.prio == "32768" |
| 319 |
- nm_add_link_aggregation_control_protocol_again.proposed == nm_add_link_aggregation_control_protocol.proposed == cm_add_link_aggregation_control_protocol.proposed |
| 320 |
- rm_link_aggregation_control_protocol is changed |
| 321 |
- rm_link_aggregation_control_protocol.imdata.0.lacpIfPol.attributes.annotation == "orchestrator:ansible" |
| 322 |
- rm_link_aggregation_control_protocol.imdata.0.lacpIfPol.attributes.descr == "test" |
| 323 |
- rm_link_aggregation_control_protocol.imdata.0.lacpIfPol.attributes.dn == "uni/infra/lacpifp-link_aggregation_control_protocol" |
| 324 |
- rm_link_aggregation_control_protocol.imdata.0.lacpIfPol.attributes.name == "link_aggregation_control_protocol" |
| 325 |
- rm_link_aggregation_control_protocol.imdata.0.lacpIfPol.attributes.prio == "32768" |
| 326 |
- rm_link_aggregation_control_protocol.imdata.0.lacpIfPol.attributes.rn == "" |
| 327 |
- rm_link_aggregation_control_protocol.imdata.0.lacpIfPol.attributes.status == "deleted" |