| 1 |
# Test code for the ACI modules |
| 2 |
# Copyright: (c) 2017, Jacob McGill (@jmcgill298) |
| 3 |
|
| 4 |
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 5 |
|
| 6 |
- name: Test that we have an ACI APIC host, ACI username and ACI password |
| 7 |
ansible.builtin.fail: |
| 8 |
msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' |
| 9 |
when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined |
| 10 |
|
| 11 |
- name: Set vars |
| 12 |
ansible.builtin.set_fact: |
| 13 |
aci_info: &aci_info |
| 14 |
host: "{{ aci_hostname }}" |
| 15 |
username: "{{ aci_username }}" |
| 16 |
password: "{{ aci_password }}" |
| 17 |
validate_certs: '{{ aci_validate_certs | default(false) }}' |
| 18 |
use_ssl: '{{ aci_use_ssl | default(true) }}' |
| 19 |
use_proxy: '{{ aci_use_proxy | default(true) }}' |
| 20 |
output_level: debug |
| 21 |
|
| 22 |
- name: Node types |
| 23 |
ansible.builtin.set_fact: |
| 24 |
test_vars_leaf: &test_vars_leaf |
| 25 |
pod_id: 1 |
| 26 |
node_id: 1101 |
| 27 |
node_type: leaf |
| 28 |
interface: 1/33 |
| 29 |
description: testing |
| 30 |
test_vars_spine: &test_vars_spine |
| 31 |
pod_id: 1 |
| 32 |
node_id: 1201 |
| 33 |
node_type: spine |
| 34 |
interface: 1/33 |
| 35 |
description: testing |
| 36 |
test_vars_fex: &test_vars_fex |
| 37 |
pod_id: 1 |
| 38 |
node_id: 1101 |
| 39 |
interface: 1/33 |
| 40 |
fex_id: 123 |
| 41 |
description: testing |
| 42 |
|
| 43 |
- name: Verify Cloud and Non-Cloud Sites in use. |
| 44 |
ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml |
| 45 |
|
| 46 |
- name: Execute tasks only for non-cloud sites |
| 47 |
when: query_cloud.current == [] # This condition will execute only non-cloud sites |
| 48 |
block: # block specifies execution of tasks within, based on conditions |
| 49 |
- name: Leaf - Clean test environment with no description interface |
| 50 |
cisco.aci.aci_interface_description: |
| 51 |
<<: *aci_info |
| 52 |
<<: *test_vars_leaf |
| 53 |
state: absent |
| 54 |
|
| 55 |
- name: Spine - Clean test environment with no description interface |
| 56 |
cisco.aci.aci_interface_description: |
| 57 |
<<: *aci_info |
| 58 |
<<: *test_vars_spine |
| 59 |
state: absent |
| 60 |
|
| 61 |
- name: Fex - Clean test environment with no description interface |
| 62 |
cisco.aci.aci_interface_description: |
| 63 |
<<: *aci_info |
| 64 |
<<: *test_vars_fex |
| 65 |
state: absent |
| 66 |
|
| 67 |
- name: Leaf - Query interface |
| 68 |
cisco.aci.aci_interface_description: |
| 69 |
<<: *aci_info |
| 70 |
<<: *test_vars_leaf |
| 71 |
state: query |
| 72 |
register: query_leaf_description |
| 73 |
|
| 74 |
- name: Leaf - Verify that no infraHPathS is present |
| 75 |
ansible.builtin.assert: |
| 76 |
that: |
| 77 |
- query_leaf_description.current.0.infraInfra.children.0.infraHPathS.children is not defined |
| 78 |
|
| 79 |
- name: Leaf - Set description on interface |
| 80 |
cisco.aci.aci_interface_description: |
| 81 |
<<: *aci_info |
| 82 |
<<: *test_vars_leaf |
| 83 |
state: present |
| 84 |
register: set_leaf_description |
| 85 |
|
| 86 |
- name: Leaf - Verify that description is set on interface |
| 87 |
ansible.builtin.assert: |
| 88 |
that: |
| 89 |
- set_leaf_description.current|length == 1 |
| 90 |
- set_leaf_description.current.0.infraHPathS.children.0.infraRsHPathAtt.attributes.tDn == "topology/pod-1/paths-1101/pathep-[eth1/33]" |
| 91 |
- set_leaf_description.current.0.infraHPathS.attributes.descr == "testing" |
| 92 |
- set_leaf_description.current.0.infraHPathS.attributes.annotation == 'orchestrator:ansible' |
| 93 |
|
| 94 |
- name: Query Leaf interface - 1101_eth1_33 |
| 95 |
cisco.aci.aci_interface_description: |
| 96 |
<<: *aci_info |
| 97 |
<<: *test_vars_leaf |
| 98 |
state: query |
| 99 |
register: query_leaf_interface_1101_eth1_33 |
| 100 |
|
| 101 |
- name: Assertion check for query Leaf interface - 1101_eth1_33 |
| 102 |
ansible.builtin.assert: |
| 103 |
that: |
| 104 |
- query_leaf_interface_1101_eth1_33.current.0.infraHPathS.children | length == 1 |
| 105 |
- query_leaf_interface_1101_eth1_33.current.0.infraHPathS.children.0.infraRsHPathAtt.attributes.rn == "rsHPathAtt-[topology/pod-1/paths-1101/pathep-[eth1/33]]" |
| 106 |
- query_leaf_interface_1101_eth1_33.current.0.infraHPathS.attributes.dn == "uni/infra/hpaths-1101_eth1_33" |
| 107 |
- query_leaf_interface_1101_eth1_33.current.0.infraHPathS.attributes.descr == "testing" |
| 108 |
- query_leaf_interface_1101_eth1_33.current.0.infraHPathS.attributes.name == "1101_eth1_33" |
| 109 |
|
| 110 |
- name: Query all leaf interfaces |
| 111 |
cisco.aci.aci_interface_description: |
| 112 |
<<: *aci_info |
| 113 |
node_type: leaf |
| 114 |
state: query |
| 115 |
register: query_all_leaf_interfaces |
| 116 |
|
| 117 |
- name: Verify query all leaf interfaces |
| 118 |
ansible.builtin.assert: |
| 119 |
that: |
| 120 |
- query_all_leaf_interfaces.current | length > 1 |
| 121 |
- query_all_leaf_interfaces.current.1.infraHPathS.children.0.infraRsHPathAtt.attributes.rn == "rsHPathAtt-[topology/pod-1/paths-1101/pathep-[eth1/33]]" |
| 122 |
- query_all_leaf_interfaces.current.1.infraHPathS.attributes.dn == "uni/infra/hpaths-1101_eth1_33" |
| 123 |
- query_all_leaf_interfaces.current.1.infraHPathS.attributes.descr == "testing" |
| 124 |
- query_all_leaf_interfaces.current.1.infraHPathS.attributes.name == "1101_eth1_33" |
| 125 |
|
| 126 |
- name: Leaf - Clean test environment with no description interface |
| 127 |
cisco.aci.aci_interface_description: |
| 128 |
<<: *aci_info |
| 129 |
<<: *test_vars_leaf |
| 130 |
state: absent |
| 131 |
|
| 132 |
- name: Leaf - Query interface |
| 133 |
cisco.aci.aci_interface_description: |
| 134 |
<<: *aci_info |
| 135 |
<<: *test_vars_leaf |
| 136 |
state: query |
| 137 |
register: query_leaf_description_again |
| 138 |
|
| 139 |
- name: Leaf - Verify that no infraHPathS is present |
| 140 |
ansible.builtin.assert: |
| 141 |
that: |
| 142 |
- query_leaf_description_again.current.0.infraInfra.children.0.infraHPathS.children is not defined |
| 143 |
|
| 144 |
- name: Spine - Clean test environment with no description interface |
| 145 |
cisco.aci.aci_interface_description: |
| 146 |
<<: *aci_info |
| 147 |
<<: *test_vars_spine |
| 148 |
state: absent |
| 149 |
|
| 150 |
- name: Spine - Query interface |
| 151 |
cisco.aci.aci_interface_description: |
| 152 |
<<: *aci_info |
| 153 |
<<: *test_vars_spine |
| 154 |
state: query |
| 155 |
register: query_spine_description |
| 156 |
|
| 157 |
- name: Spine - Verify that no infraSHPathS is present |
| 158 |
ansible.builtin.assert: |
| 159 |
that: |
| 160 |
- query_spine_description.current.0.infraInfra.children.0.infraSHPathS.children is not defined |
| 161 |
|
| 162 |
- name: Spine - Set description on interface |
| 163 |
cisco.aci.aci_interface_description: |
| 164 |
<<: *aci_info |
| 165 |
<<: *test_vars_spine |
| 166 |
state: present |
| 167 |
register: set_spine_description |
| 168 |
|
| 169 |
- name: Spine - Verify that description is set on interface |
| 170 |
ansible.builtin.assert: |
| 171 |
that: |
| 172 |
- set_spine_description.current|length == 1 |
| 173 |
- set_spine_description.current.0.infraSHPathS.children.0.infraRsSHPathAtt.attributes.tDn == "topology/pod-1/paths-1201/pathep-[eth1/33]" |
| 174 |
- set_spine_description.current.0.infraSHPathS.attributes.descr == "testing" |
| 175 |
|
| 176 |
- name: Query Spine interface - 1201_eth1_33 |
| 177 |
cisco.aci.aci_interface_description: |
| 178 |
<<: *aci_info |
| 179 |
<<: *test_vars_spine |
| 180 |
state: query |
| 181 |
register: query_spine_interface_1201_eth1_33 |
| 182 |
|
| 183 |
- name: Assertion check for query Spine interface - 1201_eth1_33 |
| 184 |
ansible.builtin.assert: |
| 185 |
that: |
| 186 |
- query_spine_interface_1201_eth1_33.current.0.infraSHPathS.children | length == 1 |
| 187 |
- query_spine_interface_1201_eth1_33.current.0.infraSHPathS.children.0.infraRsSHPathAtt.attributes.rn == "rsSHPathAtt-[topology/pod-1/paths-1201/pathep-[eth1/33]]" |
| 188 |
- query_spine_interface_1201_eth1_33.current.0.infraSHPathS.attributes.dn == "uni/infra/shpaths-1201_eth1_33" |
| 189 |
- query_spine_interface_1201_eth1_33.current.0.infraSHPathS.attributes.descr == "testing" |
| 190 |
- query_spine_interface_1201_eth1_33.current.0.infraSHPathS.attributes.name == "1201_eth1_33" |
| 191 |
|
| 192 |
- name: Query all spine interfaces |
| 193 |
cisco.aci.aci_interface_description: |
| 194 |
<<: *aci_info |
| 195 |
node_type: spine |
| 196 |
state: query |
| 197 |
register: query_all_spine_interfaces |
| 198 |
|
| 199 |
- name: Verify query all spine interfaces |
| 200 |
ansible.builtin.assert: |
| 201 |
that: |
| 202 |
- query_all_spine_interfaces.current | length >= 1 |
| 203 |
- query_all_spine_interfaces.current.1.infraSHPathS.children.0.infraRsSHPathAtt.attributes.rn == "rsSHPathAtt-[topology/pod-1/paths-1201/pathep-[eth1/33]]" |
| 204 |
- query_all_spine_interfaces.current.1.infraSHPathS.attributes.dn == "uni/infra/shpaths-1201_eth1_33" |
| 205 |
- query_all_spine_interfaces.current.1.infraSHPathS.attributes.descr == "testing" |
| 206 |
- query_all_spine_interfaces.current.1.infraSHPathS.attributes.name == "1201_eth1_33" |
| 207 |
|
| 208 |
- name: Spine - Clean test environment with no description interface |
| 209 |
cisco.aci.aci_interface_description: |
| 210 |
<<: *aci_info |
| 211 |
<<: *test_vars_spine |
| 212 |
state: absent |
| 213 |
|
| 214 |
- name: Spine - Query interface |
| 215 |
cisco.aci.aci_interface_description: |
| 216 |
<<: *aci_info |
| 217 |
<<: *test_vars_spine |
| 218 |
state: query |
| 219 |
register: query_spine_description_again |
| 220 |
|
| 221 |
- name: Spine - Verify that no infraSHPathS is present |
| 222 |
ansible.builtin.assert: |
| 223 |
that: |
| 224 |
- query_spine_description_again.current.0.infraInfra.children.0.infraSHPathS.children is not defined |
| 225 |
|
| 226 |
- name: Fex - Clean test environment with no description interface |
| 227 |
cisco.aci.aci_interface_description: |
| 228 |
<<: *aci_info |
| 229 |
<<: *test_vars_fex |
| 230 |
state: absent |
| 231 |
|
| 232 |
- name: Fex - Query interface |
| 233 |
cisco.aci.aci_interface_description: |
| 234 |
<<: *aci_info |
| 235 |
<<: *test_vars_fex |
| 236 |
state: query |
| 237 |
register: query_fex_description |
| 238 |
|
| 239 |
- name: Fex - Verify that no infraHPathS is present |
| 240 |
ansible.builtin.assert: |
| 241 |
that: |
| 242 |
- query_fex_description.current.0.infraInfra.children.0.infraHPathS.children is not defined |
| 243 |
|
| 244 |
- name: Fex - Set description on interface |
| 245 |
cisco.aci.aci_interface_description: |
| 246 |
<<: *aci_info |
| 247 |
<<: *test_vars_fex |
| 248 |
state: present |
| 249 |
register: set_fex_description |
| 250 |
|
| 251 |
- name: Fex - Verify that description is set on interface |
| 252 |
ansible.builtin.assert: |
| 253 |
that: |
| 254 |
- set_fex_description.current|length == 1 |
| 255 |
- set_fex_description.current.0.infraHPathS.children.0.infraRsHPathAtt.attributes.tDn == "topology/pod-1/paths-1101/extpaths-123/pathep-[eth1/33]" |
| 256 |
- set_fex_description.current.0.infraHPathS.attributes.descr == "testing" |
| 257 |
|
| 258 |
- name: Query Fex interface - 1101_eth123_1_33 |
| 259 |
cisco.aci.aci_interface_description: |
| 260 |
<<: *aci_info |
| 261 |
<<: *test_vars_fex |
| 262 |
state: query |
| 263 |
register: query_fex_interface_1201_eth1_33 |
| 264 |
|
| 265 |
- name: Assertion check for query Fex interface - 1101_eth123_1_33 |
| 266 |
ansible.builtin.assert: |
| 267 |
that: |
| 268 |
- query_fex_interface_1201_eth1_33.current.0.infraHPathS.children | length == 1 |
| 269 |
- query_fex_interface_1201_eth1_33.current.0.infraHPathS.children.0.infraRsHPathAtt.attributes.rn == "rsHPathAtt-[topology/pod-1/paths-1101/extpaths-123/pathep-[eth1/33]]" |
| 270 |
- query_fex_interface_1201_eth1_33.current.0.infraHPathS.attributes.descr == "testing" |
| 271 |
- query_fex_interface_1201_eth1_33.current.0.infraHPathS.attributes.name == "1101_eth123_1_33" |
| 272 |
|
| 273 |
- name: Fex - Clean test environment with no description interface |
| 274 |
cisco.aci.aci_interface_description: |
| 275 |
<<: *aci_info |
| 276 |
<<: *test_vars_fex |
| 277 |
state: absent |
| 278 |
|
| 279 |
- name: Fex - Query interface |
| 280 |
cisco.aci.aci_interface_description: |
| 281 |
<<: *aci_info |
| 282 |
<<: *test_vars_fex |
| 283 |
state: query |
| 284 |
register: query_fex_description_again |
| 285 |
|
| 286 |
- name: Fex - Verify that no infraHPathS is present |
| 287 |
ansible.builtin.assert: |
| 288 |
that: |
| 289 |
- query_fex_description_again.current.0.infraInfra.children.0.infraHPathS.children is not defined |