| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
- name: Test that we have an ACI APIC host, ACI username and ACI password |
| 8 |
fail: |
| 9 |
msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' |
| 10 |
when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined |
| 11 |
|
| 12 |
|
| 13 |
- name: Set vars |
| 14 |
set_fact: |
| 15 |
aci_info: &aci_info |
| 16 |
host: "{{ aci_hostname }}" |
| 17 |
username: "{{ aci_username }}" |
| 18 |
password: "{{ aci_password }}" |
| 19 |
validate_certs: '{{ aci_validate_certs | default(false) }}' |
| 20 |
use_ssl: '{{ aci_use_ssl | default(true) }}' |
| 21 |
use_proxy: '{{ aci_use_proxy | default(true) }}' |
| 22 |
output_level: '{{ aci_output_level | default("info") }}' |
| 23 |
|
| 24 |
|
| 25 |
- name: Remove ansible_tenant if it already exists |
| 26 |
cisco.aci.aci_tenant: |
| 27 |
<<: *aci_info |
| 28 |
name: ansible_tenant |
| 29 |
state: absent |
| 30 |
|
| 31 |
- name: Remove ansible_phys_domain if it already exists |
| 32 |
cisco.aci.aci_domain: |
| 33 |
<<: *aci_info |
| 34 |
domain: ansible_phys_dom |
| 35 |
domain_type: phys |
| 36 |
state: absent |
| 37 |
|
| 38 |
- name: Remove ansible_vmm_domain if it already exists |
| 39 |
cisco.aci.aci_domain: |
| 40 |
<<: *aci_info |
| 41 |
domain: ansible_vmm_dom |
| 42 |
domain_type: vmm |
| 43 |
vm_provider: vmware |
| 44 |
state: absent |
| 45 |
|
| 46 |
|
| 47 |
- name: Create ansible_tenant |
| 48 |
cisco.aci.aci_tenant: |
| 49 |
<<: *aci_info |
| 50 |
name: ansible_tenant |
| 51 |
state: present |
| 52 |
|
| 53 |
|
| 54 |
- name: Create ansible_phys_domain |
| 55 |
cisco.aci.aci_domain: |
| 56 |
<<: *aci_info |
| 57 |
domain: ansible_phys_dom |
| 58 |
domain_type: phys |
| 59 |
state: present |
| 60 |
|
| 61 |
- name: Create ansible_vmm_domain |
| 62 |
cisco.aci.aci_domain: |
| 63 |
<<: *aci_info |
| 64 |
domain: ansible_vmm_dom |
| 65 |
domain_type: vmm |
| 66 |
vm_provider: vmware |
| 67 |
state: present |
| 68 |
|
| 69 |
|
| 70 |
- name: Create L4-L7 Physical Device in check mode |
| 71 |
cisco.aci.aci_l4l7_device: &l4_l7_physical |
| 72 |
<<: *aci_info |
| 73 |
tenant: ansible_tenant |
| 74 |
device: ansible_device |
| 75 |
domain: ansible_phys_dom |
| 76 |
func_type: go_to |
| 77 |
context_aware: single |
| 78 |
managed: false |
| 79 |
dev_type: physical |
| 80 |
svc_type: adc |
| 81 |
trunking: false |
| 82 |
prom_mode: true |
| 83 |
state: present |
| 84 |
check_mode: true |
| 85 |
register: create_l4l7_device_cm |
| 86 |
|
| 87 |
- name: Create L4-L7 Physical Device |
| 88 |
cisco.aci.aci_l4l7_device: |
| 89 |
<<: *l4_l7_physical |
| 90 |
register: create_l4l7_device |
| 91 |
|
| 92 |
- name: Create L4-L7 Physical Device again |
| 93 |
cisco.aci.aci_l4l7_device: |
| 94 |
<<: *l4_l7_physical |
| 95 |
register: create_l4l7_device_again |
| 96 |
|
| 97 |
- name: Create L4-L7 Virtual Device |
| 98 |
cisco.aci.aci_l4l7_device: &l4_l7_virtual |
| 99 |
<<: *aci_info |
| 100 |
tenant: ansible_tenant |
| 101 |
device: ansible_virt_device |
| 102 |
domain: ansible_vmm_dom |
| 103 |
func_type: go_to |
| 104 |
context_aware: single |
| 105 |
managed: false |
| 106 |
dev_type: virtual |
| 107 |
svc_type: adc |
| 108 |
trunking: false |
| 109 |
prom_mode: true |
| 110 |
state: present |
| 111 |
register: create_virt_l4l7_device |
| 112 |
|
| 113 |
- name: Create L4-L7 Virtual Device again |
| 114 |
cisco.aci.aci_l4l7_device: |
| 115 |
<<: *l4_l7_virtual |
| 116 |
register: create_virt_l4l7_device_again |
| 117 |
|
| 118 |
- name: Verify L4-L7 device has been created |
| 119 |
ansible.builtin.assert: |
| 120 |
that: |
| 121 |
- create_l4l7_device_cm is changed |
| 122 |
- create_l4l7_device is changed |
| 123 |
- create_l4l7_device_again is not changed |
| 124 |
- create_virt_l4l7_device is changed |
| 125 |
- create_virt_l4l7_device_again is not changed |
| 126 |
- create_l4l7_device_cm.proposed.vnsLDevVip.attributes.dn == "uni/tn-ansible_tenant/lDevVip-ansible_device" |
| 127 |
- create_l4l7_device_cm.proposed.vnsLDevVip.attributes.name == "ansible_device" |
| 128 |
- create_l4l7_device_cm.proposed.vnsLDevVip.attributes.contextAware == "single-Context" |
| 129 |
- create_l4l7_device_cm.proposed.vnsLDevVip.attributes.devtype == "PHYSICAL" |
| 130 |
- create_l4l7_device_cm.proposed.vnsLDevVip.attributes.funcType == "GoTo" |
| 131 |
- create_l4l7_device_cm.proposed.vnsLDevVip.attributes.managed == "no" |
| 132 |
- create_l4l7_device_cm.proposed.vnsLDevVip.attributes.promMode == "yes" |
| 133 |
- create_l4l7_device_cm.proposed.vnsLDevVip.attributes.svcType == "ADC" |
| 134 |
- create_l4l7_device_cm.proposed.vnsLDevVip.attributes.trunking == "no" |
| 135 |
- create_l4l7_device.current.0.vnsLDevVip.attributes.dn == "uni/tn-ansible_tenant/lDevVip-ansible_device" |
| 136 |
- create_l4l7_device.current.0.vnsLDevVip.attributes.name == "ansible_device" |
| 137 |
- create_l4l7_device.current.0.vnsLDevVip.attributes.contextAware == "single-Context" |
| 138 |
- create_l4l7_device.current.0.vnsLDevVip.attributes.devtype == "PHYSICAL" |
| 139 |
- create_l4l7_device.current.0.vnsLDevVip.attributes.funcType == "GoTo" |
| 140 |
- create_l4l7_device.current.0.vnsLDevVip.attributes.isCopy == "no" |
| 141 |
- create_l4l7_device.current.0.vnsLDevVip.attributes.managed == "no" |
| 142 |
- create_l4l7_device.current.0.vnsLDevVip.attributes.promMode == "yes" |
| 143 |
- create_l4l7_device.current.0.vnsLDevVip.attributes.svcType == "ADC" |
| 144 |
- create_l4l7_device.current.0.vnsLDevVip.attributes.trunking == "no" |
| 145 |
- create_virt_l4l7_device.current.0.vnsLDevVip.attributes.dn == "uni/tn-ansible_tenant/lDevVip-ansible_virt_device" |
| 146 |
- create_virt_l4l7_device.current.0.vnsLDevVip.attributes.name == "ansible_virt_device" |
| 147 |
- create_virt_l4l7_device.current.0.vnsLDevVip.attributes.contextAware == "single-Context" |
| 148 |
- create_virt_l4l7_device.current.0.vnsLDevVip.attributes.devtype == "VIRTUAL" |
| 149 |
- create_virt_l4l7_device.current.0.vnsLDevVip.attributes.funcType == "GoTo" |
| 150 |
- create_virt_l4l7_device.current.0.vnsLDevVip.attributes.isCopy == "no" |
| 151 |
- create_virt_l4l7_device.current.0.vnsLDevVip.attributes.managed == "no" |
| 152 |
- create_virt_l4l7_device.current.0.vnsLDevVip.attributes.promMode == "yes" |
| 153 |
- create_virt_l4l7_device.current.0.vnsLDevVip.attributes.svcType == "ADC" |
| 154 |
- create_virt_l4l7_device.current.0.vnsLDevVip.attributes.trunking == "no" |
| 155 |
- create_l4l7_device.previous == [] |
| 156 |
- create_virt_l4l7_device.previous == [] |
| 157 |
- create_l4l7_device_again.previous == create_l4l7_device_again.current == create_l4l7_device.current |
| 158 |
- create_virt_l4l7_device_again.previous == create_virt_l4l7_device_again.current == create_virt_l4l7_device.current |
| 159 |
|
| 160 |
- name: Verify domain binding object has been created |
| 161 |
ansible.builtin.assert: |
| 162 |
that: |
| 163 |
- create_l4l7_device.current.0.vnsLDevVip.children.0.vnsRsALDevToPhysDomP.attributes.tDn == "uni/phys-ansible_phys_dom" |
| 164 |
- create_virt_l4l7_device.current.0.vnsLDevVip.children.0.vnsRsALDevToDomP.attributes.tDn == "uni/vmmp-VMware/dom-ansible_vmm_dom" |
| 165 |
|
| 166 |
- name: Verify domain binding object is still correct |
| 167 |
ansible.builtin.assert: |
| 168 |
that: |
| 169 |
- create_l4l7_device_again.current.0.vnsLDevVip.children.0.vnsRsALDevToPhysDomP.attributes.tDn == "uni/phys-ansible_phys_dom" |
| 170 |
- create_virt_l4l7_device_again.current.0.vnsLDevVip.children.0.vnsRsALDevToDomP.attributes.tDn == "uni/vmmp-VMware/dom-ansible_vmm_dom" |
| 171 |
|
| 172 |
|
| 173 |
- name: Update L4-L7 device |
| 174 |
cisco.aci.aci_l4l7_device: |
| 175 |
<<: *aci_info |
| 176 |
tenant: ansible_tenant |
| 177 |
device: ansible_device |
| 178 |
domain: ansible_phys_dom |
| 179 |
func_type: go_through |
| 180 |
context_aware: multi |
| 181 |
managed: false |
| 182 |
dev_type: physical |
| 183 |
svc_type: fw |
| 184 |
trunking: true |
| 185 |
prom_mode: false |
| 186 |
state: present |
| 187 |
register: update_l4l7_device |
| 188 |
|
| 189 |
- name: Verify L4-L7 device has been updated |
| 190 |
ansible.builtin.assert: |
| 191 |
that: |
| 192 |
- update_l4l7_device is changed |
| 193 |
- update_l4l7_device.current.0.vnsLDevVip.attributes.dn == "uni/tn-ansible_tenant/lDevVip-ansible_device" |
| 194 |
- update_l4l7_device.current.0.vnsLDevVip.attributes.name == "ansible_device" |
| 195 |
- update_l4l7_device.current.0.vnsLDevVip.attributes.contextAware == "multi-Context" |
| 196 |
- update_l4l7_device.current.0.vnsLDevVip.attributes.devtype == "PHYSICAL" |
| 197 |
- update_l4l7_device.current.0.vnsLDevVip.attributes.funcType == "GoThrough" |
| 198 |
- update_l4l7_device.current.0.vnsLDevVip.attributes.isCopy == "no" |
| 199 |
- update_l4l7_device.current.0.vnsLDevVip.attributes.managed == "no" |
| 200 |
- update_l4l7_device.current.0.vnsLDevVip.attributes.promMode == "no" |
| 201 |
- update_l4l7_device.current.0.vnsLDevVip.attributes.svcType == "FW" |
| 202 |
- update_l4l7_device.current.0.vnsLDevVip.attributes.trunking == "yes" |
| 203 |
|
| 204 |
- name: Verify domain binding object |
| 205 |
ansible.builtin.assert: |
| 206 |
that: |
| 207 |
- update_l4l7_device.current.0.vnsLDevVip.children.0.vnsRsALDevToPhysDomP.attributes.tDn == "uni/phys-ansible_phys_dom" |
| 208 |
|
| 209 |
- name: Create another L4-L7 device to test active active mode |
| 210 |
cisco.aci.aci_l4l7_device: |
| 211 |
<<: *aci_info |
| 212 |
tenant: ansible_tenant |
| 213 |
device: ansible_device2 |
| 214 |
domain: ansible_phys_dom |
| 215 |
func_type: l1 |
| 216 |
context_aware: multi |
| 217 |
managed: false |
| 218 |
dev_type: physical |
| 219 |
svc_type: others |
| 220 |
trunking: true |
| 221 |
prom_mode: false |
| 222 |
active_active_mode: true |
| 223 |
state: present |
| 224 |
register: another_l4l7_device_active |
| 225 |
|
| 226 |
- name: Verify domain binding object |
| 227 |
ansible.builtin.assert: |
| 228 |
that: |
| 229 |
- another_l4l7_device_active is changed |
| 230 |
- another_l4l7_device_active.current.0.vnsLDevVip.attributes.funcType == "L1" |
| 231 |
- another_l4l7_device_active.current.0.vnsLDevVip.attributes.activeActive == "yes" |
| 232 |
|
| 233 |
|
| 234 |
- name: Query L4-L7 Device |
| 235 |
cisco.aci.aci_l4l7_device: |
| 236 |
<<: *aci_info |
| 237 |
tenant: ansible_tenant |
| 238 |
device: ansible_device |
| 239 |
state: query |
| 240 |
register: query_l4l7_device |
| 241 |
|
| 242 |
- name: Verify L4-L7 Device attributes |
| 243 |
ansible.builtin.assert: |
| 244 |
that: |
| 245 |
- query_l4l7_device is not changed |
| 246 |
- query_l4l7_device.current.0.vnsLDevVip.attributes.dn == "uni/tn-ansible_tenant/lDevVip-ansible_device" |
| 247 |
- query_l4l7_device.current.0.vnsLDevVip.attributes.name == "ansible_device" |
| 248 |
- query_l4l7_device.current.0.vnsLDevVip.attributes.contextAware == "multi-Context" |
| 249 |
- query_l4l7_device.current.0.vnsLDevVip.attributes.devtype == "PHYSICAL" |
| 250 |
- query_l4l7_device.current.0.vnsLDevVip.attributes.funcType == "GoThrough" |
| 251 |
- query_l4l7_device.current.0.vnsLDevVip.attributes.isCopy == "no" |
| 252 |
- query_l4l7_device.current.0.vnsLDevVip.attributes.managed == "no" |
| 253 |
- query_l4l7_device.current.0.vnsLDevVip.attributes.promMode == "no" |
| 254 |
- query_l4l7_device.current.0.vnsLDevVip.attributes.svcType == "FW" |
| 255 |
- query_l4l7_device.current.0.vnsLDevVip.attributes.trunking == "yes" |
| 256 |
|
| 257 |
- name: Query all L4-L7 Devices |
| 258 |
cisco.aci.aci_l4l7_device: |
| 259 |
<<: *aci_info |
| 260 |
state: query |
| 261 |
register: query_l4l7_device_all |
| 262 |
|
| 263 |
- name: Verify L4-L7 Device query idempotence |
| 264 |
ansible.builtin.assert: |
| 265 |
that: |
| 266 |
- query_l4l7_device_all is not changed |
| 267 |
- query_l4l7_device_all.current | length >= 3 |
| 268 |
- "'uni/tn-ansible_tenant/lDevVip-ansible_device' in query_l4l7_device_all.current | map(attribute='vnsLDevVip.attributes.dn') | list" |
| 269 |
- "'uni/tn-ansible_tenant/lDevVip-ansible_virt_device' in query_l4l7_device_all.current | map(attribute='vnsLDevVip.attributes.dn') | list" |
| 270 |
|
| 271 |
|
| 272 |
- name: Delete L4-L7 Device |
| 273 |
cisco.aci.aci_l4l7_device: &remove_l4l7_device |
| 274 |
<<: *aci_info |
| 275 |
tenant: ansible_tenant |
| 276 |
device: ansible_device |
| 277 |
state: absent |
| 278 |
check_mode: true |
| 279 |
register: remove_l4l7_device_cm |
| 280 |
|
| 281 |
- name: Delete L4-L7 Device |
| 282 |
cisco.aci.aci_l4l7_device: |
| 283 |
<<: *remove_l4l7_device |
| 284 |
register: remove_l4l7_device |
| 285 |
|
| 286 |
- name: Verify L4-L7 Device deletion |
| 287 |
ansible.builtin.assert: |
| 288 |
that: |
| 289 |
- remove_l4l7_device_cm is changed |
| 290 |
- remove_l4l7_device is changed |
| 291 |
- remove_l4l7_device_cm.proposed == {} |
| 292 |
- remove_l4l7_device_cm.previous == remove_l4l7_device.previous == update_l4l7_device.current |
| 293 |
- remove_l4l7_device.current == [] |
| 294 |
|
| 295 |
|
| 296 |
- name: Delete L4-L7 Device again |
| 297 |
cisco.aci.aci_l4l7_device: |
| 298 |
<<: *remove_l4l7_device |
| 299 |
register: remove_l4l7_device_again |
| 300 |
|
| 301 |
- name: Verify L4-L7 Device deletion idempotence |
| 302 |
ansible.builtin.assert: |
| 303 |
that: |
| 304 |
- remove_l4l7_device_again is not changed |
| 305 |
- remove_l4l7_device_again.current == [] == remove_l4l7_device_again.previous |
| 306 |
|
| 307 |
|
| 308 |
- name: Remove ansible_tenant |
| 309 |
cisco.aci.aci_tenant: |
| 310 |
<<: *aci_info |
| 311 |
name: ansible_tenant |
| 312 |
state: absent |
| 313 |
|
| 314 |
- name: Remove ansible_phys_domain |
| 315 |
cisco.aci.aci_domain: |
| 316 |
<<: *aci_info |
| 317 |
domain: ansible_phys_dom |
| 318 |
domain_type: phys |
| 319 |
state: absent |
| 320 |
|
| 321 |
- name: Remove ansible_vmm_domain |
| 322 |
cisco.aci.aci_domain: |
| 323 |
<<: *aci_info |
| 324 |
domain: ansible_vmm_dom |
| 325 |
domain_type: vmm |
| 326 |
vm_provider: vmware |
| 327 |
state: absent |