| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
- name: Test that we have an ACI APIC host, ACI username and ACI password |
| 9 |
ansible.builtin.fail: |
| 10 |
msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' |
| 11 |
when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined |
| 12 |
|
| 13 |
- name: Set vars |
| 14 |
ansible.builtin.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 |
- name: Query system information |
| 25 |
cisco.aci.aci_system: |
| 26 |
<<: *aci_info |
| 27 |
id: 1 |
| 28 |
state: query |
| 29 |
register: version |
| 30 |
|
| 31 |
- name: Verify Cloud and Non-Cloud Sites in use. |
| 32 |
ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml |
| 33 |
|
| 34 |
- name: Execute tasks only for non-cloud sites |
| 35 |
when: |
| 36 |
- query_cloud.current == [] |
| 37 |
block: |
| 38 |
|
| 39 |
|
| 40 |
- name: Ensure tenant removed |
| 41 |
cisco.aci.aci_tenant: &aci_tenant_absent |
| 42 |
<<: *aci_info |
| 43 |
state: absent |
| 44 |
tenant: ansible_test |
| 45 |
|
| 46 |
|
| 47 |
- name: Create tenant |
| 48 |
cisco.aci.aci_tenant: &aci_tenant_present |
| 49 |
<<: *aci_tenant_absent |
| 50 |
state: present |
| 51 |
|
| 52 |
- name: Create BD |
| 53 |
cisco.aci.aci_bd: |
| 54 |
<<: *aci_tenant_present |
| 55 |
bd: ansible_test_bd |
| 56 |
|
| 57 |
- name: Create VRF |
| 58 |
cisco.aci.aci_vrf: |
| 59 |
<<: *aci_tenant_present |
| 60 |
vrf: ansible_test_vrf |
| 61 |
|
| 62 |
- name: Create AP |
| 63 |
cisco.aci.aci_ap: &aci_ap |
| 64 |
<<: *aci_tenant_present |
| 65 |
ap: ansible_test_ap |
| 66 |
|
| 67 |
- name: Create EPG |
| 68 |
cisco.aci.aci_epg: |
| 69 |
<<: *aci_ap |
| 70 |
epg: ansible_test_epg |
| 71 |
bd: ansible_test_bd |
| 72 |
|
| 73 |
- name: Bind End Point Group to Provider Contract |
| 74 |
cisco.aci.aci_epg_to_contract: |
| 75 |
<<: *aci_tenant_present |
| 76 |
ap: ansible_test_ap |
| 77 |
epg: ansible_test_epg |
| 78 |
contract_type: provider |
| 79 |
contract: ansible_test_contract |
| 80 |
|
| 81 |
- name: Bind End Point Group to Consumer Contract |
| 82 |
cisco.aci.aci_epg_to_contract: |
| 83 |
<<: *aci_tenant_present |
| 84 |
ap: ansible_test_ap |
| 85 |
epg: ansible_test_epg |
| 86 |
contract_type: consumer |
| 87 |
contract: ansible_test_contract |
| 88 |
|
| 89 |
- name: Create ESG |
| 90 |
cisco.aci.aci_esg: |
| 91 |
<<: *aci_ap |
| 92 |
esg: ansible_test_esg |
| 93 |
vrf: ansible_test_vrf |
| 94 |
when: version.current.0.topSystem.attributes.version is version('5', '>=') |
| 95 |
|
| 96 |
- name: Create L2Out |
| 97 |
cisco.aci.aci_l2out: |
| 98 |
<<: *aci_tenant_present |
| 99 |
l2out: ansible_test_l2out |
| 100 |
bd: ansible_test_bd |
| 101 |
domain: l2Dom |
| 102 |
vlan: 3200 |
| 103 |
|
| 104 |
- name: Create L2Out External End Point Group |
| 105 |
cisco.aci.aci_l2out_extepg: |
| 106 |
<<: *aci_tenant_present |
| 107 |
l2out: ansible_test_l2out |
| 108 |
extepg: ansible_test_external_epg |
| 109 |
|
| 110 |
- name: Create L2Out |
| 111 |
cisco.aci.aci_l3out: |
| 112 |
<<: *aci_tenant_present |
| 113 |
l3out: ansible_test_l3out |
| 114 |
vrf: ansible_test_vrf |
| 115 |
domain: l3dom |
| 116 |
|
| 117 |
- name: Create L3Out External End Point Group |
| 118 |
cisco.aci.aci_l3out_extepg: |
| 119 |
<<: *aci_tenant_present |
| 120 |
l3out: ansible_test_l3out |
| 121 |
extepg: ansible_test_external_epg |
| 122 |
|
| 123 |
- name: Bind L3out External End Point Group to Provider Contract |
| 124 |
cisco.aci.aci_l3out_extepg_to_contract: |
| 125 |
<<: *aci_tenant_present |
| 126 |
tenant: ansible_test |
| 127 |
l3out: ansible_test_l3out |
| 128 |
extepg: ansible_test_external_epg |
| 129 |
contract: ansible_test_contract |
| 130 |
contract_type: provider |
| 131 |
|
| 132 |
- name: Bind L3out External End Point Group to Consumer Contract |
| 133 |
cisco.aci.aci_l3out_extepg_to_contract: |
| 134 |
<<: *aci_tenant_present |
| 135 |
tenant: ansible_test |
| 136 |
l3out: ansible_test_l3out |
| 137 |
extepg: ansible_test_external_epg |
| 138 |
contract: ansible_test_contract |
| 139 |
contract_type: consumer |
| 140 |
|
| 141 |
- name: Create Contract |
| 142 |
cisco.aci.aci_contract: &aci_contract_present |
| 143 |
<<: *aci_tenant_present |
| 144 |
contract: ansible_test_contract |
| 145 |
|
| 146 |
- name: Create Subject |
| 147 |
cisco.aci.aci_contract_subject: |
| 148 |
<<: *aci_contract_present |
| 149 |
subject: ansible_test_subject |
| 150 |
|
| 151 |
|
| 152 |
- name: Execute tests for each parent class |
| 153 |
ansible.builtin.include_tasks: subject_label.yml |
| 154 |
loop: |
| 155 |
- { l2out: "{{ fake_var | default(omit) }}", l3out: "{{ fake_var | default(omit) }}", external_epg: "{{ fake_var | default(omit) }}", contract: "ansible_test_contract", subject: "ansible_test_subject", ap: "{{ fake_var | default(omit) }}", epg: "{{ fake_var | default(omit) }}", esg: "{{ fake_var | default(omit) }}"} |
| 156 |
- { l2out: "ansible_test_l2out", l3out: "{{ fake_var | default(omit) }}", external_epg: "ansible_test_external_epg", contract: "{{ fake_var | default(omit) }}", subject: "{{ fake_var | default(omit) }}", ap: "{{ fake_var | default(omit) }}", epg: "{{ fake_var | default(omit) }}", esg: "{{ fake_var | default(omit) }}"} |
| 157 |
- { l2out: "{{ fake_var | default(omit) }}", l3out: "ansible_test_l3out", external_epg: "ansible_test_external_epg", contract: "{{ fake_var | default(omit) }}", subject: "{{ fake_var | default(omit) }}", ap: "{{ fake_var | default(omit) }}", epg: "{{ fake_var | default(omit) }}", esg: "{{ fake_var | default(omit) }}"} |
| 158 |
- { l2out: "{{ fake_var | default(omit) }}", l3out: "ansible_test_l3out", external_epg: "ansible_test_external_epg", contract: "ansible_test_contract", subject: "{{ fake_var | default(omit) }}", ap: "{{ fake_var | default(omit) }}", epg: "{{ fake_var | default(omit) }}", esg: "{{ fake_var | default(omit) }}"} |
| 159 |
- { l2out: "{{ fake_var | default(omit) }}", l3out: "{{ fake_var | default(omit) }}", external_epg: "{{ fake_var | default(omit) }}", contract: "{{ fake_var | default(omit) }}", subject: "{{ fake_var | default(omit) }}", ap: "ansible_test_ap", epg: "ansible_test_epg", esg: "{{ fake_var | default(omit) }}"} |
| 160 |
- { l2out: "{{ fake_var | default(omit) }}", l3out: "{{ fake_var | default(omit) }}", external_epg: "{{ fake_var | default(omit) }}", contract: "ansible_test_contract", subject: "{{ fake_var | default(omit) }}", ap: "ansible_test_ap", epg: "ansible_test_epg", esg: "{{ fake_var | default(omit) }}"} |
| 161 |
loop_control: |
| 162 |
loop_var: parent_class |
| 163 |
|
| 164 |
- name: Execute tests for esg class which is only supported in 5+ |
| 165 |
ansible.builtin.include_tasks: subject_label.yml |
| 166 |
loop: |
| 167 |
- { l2out: "{{ fake_var | default(omit) }}", l3out: "{{ fake_var | default(omit) }}", external_epg: "{{ fake_var | default(omit) }}", contract: "{{ fake_var | default(omit) }}", subject: "{{ fake_var | default(omit) }}", ap: "ansible_test_ap", epg: "{{ fake_var | default(omit) }}", esg: "ansible_test_esg"} |
| 168 |
loop_control: |
| 169 |
loop_var: parent_class |
| 170 |
when: version.current.0.topSystem.attributes.version is version('5', '>=') |
| 171 |
|
| 172 |
|
| 173 |
- name: Mutually exclusive all provided (error) |
| 174 |
cisco.aci.aci_subject_label: |
| 175 |
<<: *aci_tenant_present |
| 176 |
l2out: ansible_test_l2out |
| 177 |
l3out: ansible_test_l3out |
| 178 |
subject: ansible_test_subject |
| 179 |
epg: ansible_test_epg |
| 180 |
esg: ansible_test_esg |
| 181 |
register: err_mutually_exclusive_all |
| 182 |
ignore_errors: true |
| 183 |
|
| 184 |
- name: Mutually exclusive two provided (error) |
| 185 |
cisco.aci.aci_subject_label: |
| 186 |
<<: *aci_tenant_present |
| 187 |
l2out: ansible_test_l2out |
| 188 |
l3out: ansible_test_l3out |
| 189 |
register: err_mutually_exclusive_two |
| 190 |
ignore_errors: true |
| 191 |
|
| 192 |
- name: Mutually exclusive esg with contract provided (error) |
| 193 |
cisco.aci.aci_subject_label: |
| 194 |
<<: *aci_tenant_present |
| 195 |
esg: ansible_test_esg |
| 196 |
contract: ansible_test_contract |
| 197 |
register: err_mutually_exclusive_esg |
| 198 |
ignore_errors: true |
| 199 |
|
| 200 |
- name: Missing required input one of L2Out, L3Out, EPG, ESG, subject (error) |
| 201 |
cisco.aci.aci_subject_label: |
| 202 |
<<: *aci_tenant_present |
| 203 |
subject_label: ansible_test_l2out |
| 204 |
subject_label_type: consumer |
| 205 |
register: err_missing_required_input_missing_one_of |
| 206 |
ignore_errors: true |
| 207 |
|
| 208 |
- name: Missing required input subject_type (error) |
| 209 |
cisco.aci.aci_subject_label: |
| 210 |
<<: *aci_tenant_present |
| 211 |
l2out: ansible_test_l2out |
| 212 |
register: err_missing_required_input_subject_type |
| 213 |
ignore_errors: true |
| 214 |
|
| 215 |
- name: Missing required input subject_label (error) |
| 216 |
cisco.aci.aci_subject_label: |
| 217 |
<<: *aci_tenant_present |
| 218 |
l2out: ansible_test_l2out |
| 219 |
subject_label_type: consumer |
| 220 |
register: err_missing_required_input_subject_label |
| 221 |
ignore_errors: true |
| 222 |
|
| 223 |
- name: Missing required input external_epg (error) |
| 224 |
cisco.aci.aci_subject_label: |
| 225 |
<<: *aci_tenant_present |
| 226 |
l2out: ansible_test_l2out |
| 227 |
subject_label_type: consumer |
| 228 |
subject_label: ansible_test_subject_label |
| 229 |
register: err_missing_required_input_external_epg |
| 230 |
ignore_errors: true |
| 231 |
|
| 232 |
- name: Assert input errors |
| 233 |
ansible.builtin.assert: |
| 234 |
that: |
| 235 |
- err_mutually_exclusive_all is failed |
| 236 |
- err_mutually_exclusive_all.msg == "parameters are mutually exclusive{{":"}} l2out|l3out|epg|esg|subject" |
| 237 |
- err_mutually_exclusive_two is failed |
| 238 |
- err_mutually_exclusive_two.msg == "parameters are mutually exclusive{{":"}} l2out|l3out|epg|esg|subject" |
| 239 |
- err_mutually_exclusive_esg is failed |
| 240 |
- err_mutually_exclusive_esg.msg == "parameters are mutually exclusive{{":"}} esg|contract" |
| 241 |
- err_missing_required_input_missing_one_of is failed |
| 242 |
- err_missing_required_input_missing_one_of.msg == "state is present but any of the following are missing{{":"}} l2out, l3out, epg, esg, subject" |
| 243 |
- err_missing_required_input_subject_type is failed |
| 244 |
- err_missing_required_input_subject_type.msg == "missing required arguments{{":"}} subject_label_type" |
| 245 |
- err_missing_required_input_subject_label is failed |
| 246 |
- err_missing_required_input_subject_label.msg == "state is present but all of the following are missing{{":"}} subject_label" |
| 247 |
- err_missing_required_input_external_epg is failed |
| 248 |
- err_missing_required_input_external_epg.msg == "missing parameter(s) required by 'l2out'{{":"}} external_epg" |
| 249 |
|
| 250 |
|
| 251 |
- name: Remove tenant |
| 252 |
cisco.aci.aci_tenant: |
| 253 |
<<: *aci_tenant_absent |