| 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 |
|
| 14 |
- name: Set vars |
| 15 |
ansible.builtin.set_fact: |
| 16 |
aci_info: &aci_info |
| 17 |
host: "{{ aci_hostname }}" |
| 18 |
username: "{{ aci_username }}" |
| 19 |
password: "{{ aci_password }}" |
| 20 |
validate_certs: '{{ aci_validate_certs | default(false) }}' |
| 21 |
use_ssl: '{{ aci_use_ssl | default(true) }}' |
| 22 |
use_proxy: '{{ aci_use_proxy | default(true) }}' |
| 23 |
output_level: debug |
| 24 |
|
| 25 |
|
| 26 |
- name: Ensure Fabric Setup Pod 77 is absent before testing |
| 27 |
cisco.aci.aci_fabric_pod: |
| 28 |
<<: *aci_info |
| 29 |
pod_id: 77 |
| 30 |
state: absent |
| 31 |
register: cleaned |
| 32 |
|
| 33 |
- name: Sleep for 15 seconds and continue |
| 34 |
ansible.builtin.wait_for: |
| 35 |
timeout: 15 |
| 36 |
delegate_to: localhost |
| 37 |
when: cleaned is changed |
| 38 |
|
| 39 |
|
| 40 |
- name: Create ansible_fabric_pod_setup with check mode |
| 41 |
cisco.aci.aci_fabric_pod: |
| 42 |
<<: *aci_info |
| 43 |
pod_id: 77 |
| 44 |
pool: 10.77.0.0/16 |
| 45 |
type: physical |
| 46 |
description: Ansible test pod setup |
| 47 |
state: present |
| 48 |
check_mode: true |
| 49 |
register: add_fabric_pod_setup_cm |
| 50 |
|
| 51 |
- name: Create ansible_fabric_pod_setup |
| 52 |
cisco.aci.aci_fabric_pod: |
| 53 |
<<: *aci_info |
| 54 |
pod_id: 77 |
| 55 |
pool: 10.77.0.0/16 |
| 56 |
type: physical |
| 57 |
description: Ansible test pod setup |
| 58 |
state: present |
| 59 |
register: add_fabric_pod_setup |
| 60 |
|
| 61 |
- name: Sleep for 15 seconds and continue |
| 62 |
ansible.builtin.wait_for: |
| 63 |
timeout: 15 |
| 64 |
delegate_to: localhost |
| 65 |
|
| 66 |
- name: Verify profile creation |
| 67 |
ansible.builtin.assert: |
| 68 |
that: |
| 69 |
- add_fabric_pod_setup is changed |
| 70 |
- add_fabric_pod_setup.current.0.fabricSetupP.attributes.dn == "uni/controller/setuppol/setupp-77" |
| 71 |
- add_fabric_pod_setup.current.0.fabricSetupP.attributes.podId == "77" |
| 72 |
- add_fabric_pod_setup.current.0.fabricSetupP.attributes.podType == "physical" |
| 73 |
- add_fabric_pod_setup.current.0.fabricSetupP.attributes.tepPool == "10.77.0.0/16" |
| 74 |
- add_fabric_pod_setup.current.0.fabricSetupP.attributes.descr == "Ansible test pod setup" |
| 75 |
- add_fabric_pod_setup.current.0.fabricSetupP.attributes.annotation == 'orchestrator:ansible' |
| 76 |
- add_fabric_pod_setup_cm is changed |
| 77 |
- add_fabric_pod_setup_cm.previous == [] |
| 78 |
- add_fabric_pod_setup_cm.current == [] |
| 79 |
- add_fabric_pod_setup_cm.proposed.fabricSetupP.attributes.dn == "uni/controller/setuppol/setupp-77" |
| 80 |
- add_fabric_pod_setup_cm.proposed.fabricSetupP.attributes.podId == "77" |
| 81 |
- add_fabric_pod_setup_cm.proposed.fabricSetupP.attributes.podType == "physical" |
| 82 |
- add_fabric_pod_setup_cm.proposed.fabricSetupP.attributes.tepPool == "10.77.0.0/16" |
| 83 |
- add_fabric_pod_setup_cm.proposed.fabricSetupP.attributes.descr == "Ansible test pod setup" |
| 84 |
- add_fabric_pod_setup_cm.proposed.fabricSetupP.attributes.annotation == 'orchestrator:ansible' |
| 85 |
|
| 86 |
|
| 87 |
- name: Create ansible_fabric_pod_setup again |
| 88 |
cisco.aci.aci_fabric_pod: |
| 89 |
<<: *aci_info |
| 90 |
pod_id: 77 |
| 91 |
pool: 10.77.0.0/16 |
| 92 |
type: physical |
| 93 |
description: Ansible test pod setup |
| 94 |
state: present |
| 95 |
register: add_fabric_pod_setup_again |
| 96 |
|
| 97 |
- name: Verify profile creation idempotence |
| 98 |
ansible.builtin.assert: |
| 99 |
that: |
| 100 |
- add_fabric_pod_setup_again is not changed |
| 101 |
- add_fabric_pod_setup_again.current.0.fabricSetupP.attributes.dn == "uni/controller/setuppol/setupp-77" |
| 102 |
- add_fabric_pod_setup_again.current.0.fabricSetupP.attributes.podId == "77" |
| 103 |
- add_fabric_pod_setup_again.current.0.fabricSetupP.attributes.podType == "physical" |
| 104 |
- add_fabric_pod_setup_again.current.0.fabricSetupP.attributes.tepPool == "10.77.0.0/16" |
| 105 |
- add_fabric_pod_setup_again.current.0.fabricSetupP.attributes.descr == "Ansible test pod setup" |
| 106 |
|
| 107 |
|
| 108 |
- name: Query fabric setup pod |
| 109 |
cisco.aci.aci_fabric_pod: |
| 110 |
<<: *aci_info |
| 111 |
pod_id: 77 |
| 112 |
state: query |
| 113 |
register: query_pod_profile |
| 114 |
|
| 115 |
- name: Verify profile query |
| 116 |
ansible.builtin.assert: |
| 117 |
that: |
| 118 |
- query_pod_profile is not changed |
| 119 |
- query_pod_profile.current.0.fabricSetupP.attributes.dn == "uni/controller/setuppol/setupp-77" |
| 120 |
- query_pod_profile.current.0.fabricSetupP.attributes.podId == "77" |
| 121 |
- query_pod_profile.current.0.fabricSetupP.attributes.podType == "physical" |
| 122 |
- query_pod_profile.current.0.fabricSetupP.attributes.tepPool == "10.77.0.0/16" |
| 123 |
- query_pod_profile.current.0.fabricSetupP.attributes.descr == "Ansible test pod setup" |
| 124 |
|
| 125 |
|
| 126 |
- name: Query all fabric pod setups |
| 127 |
cisco.aci.aci_fabric_pod: |
| 128 |
<<: *aci_info |
| 129 |
state: query |
| 130 |
register: query_pod_profile_all |
| 131 |
|
| 132 |
- name: Verify profile query idempotence |
| 133 |
ansible.builtin.assert: |
| 134 |
that: |
| 135 |
- query_pod_profile_all is not changed |
| 136 |
|
| 137 |
|
| 138 |
- name: Delete pod setup with check mode |
| 139 |
cisco.aci.aci_fabric_pod: |
| 140 |
<<: *aci_info |
| 141 |
pod_id: 77 |
| 142 |
state: absent |
| 143 |
check_mode: true |
| 144 |
register: delete_pod_setup_cm |
| 145 |
|
| 146 |
- name: Delete pod setup |
| 147 |
cisco.aci.aci_fabric_pod: |
| 148 |
<<: *aci_info |
| 149 |
pod_id: 77 |
| 150 |
state: absent |
| 151 |
register: delete_pod_setup |
| 152 |
|
| 153 |
- name: Sleep for 15 seconds and continue |
| 154 |
ansible.builtin.wait_for: |
| 155 |
timeout: 15 |
| 156 |
delegate_to: localhost |
| 157 |
|
| 158 |
- name: Verify pod setup deletion |
| 159 |
ansible.builtin.assert: |
| 160 |
that: |
| 161 |
- delete_pod_setup is changed |
| 162 |
- delete_pod_setup.current == [] |
| 163 |
- delete_pod_setup.previous.0.fabricSetupP.attributes.dn == "uni/controller/setuppol/setupp-77" |
| 164 |
- delete_pod_setup.previous.0.fabricSetupP.attributes.podId == "77" |
| 165 |
- delete_pod_setup.previous.0.fabricSetupP.attributes.podType == "physical" |
| 166 |
- delete_pod_setup.previous.0.fabricSetupP.attributes.tepPool == "10.77.0.0/16" |
| 167 |
- delete_pod_setup.previous.0.fabricSetupP.attributes.descr == "Ansible test pod setup" |
| 168 |
- delete_pod_setup_cm is changed |
| 169 |
- delete_pod_setup_cm.current != [] |
| 170 |
- delete_pod_setup_cm.previous.0.fabricSetupP.attributes.dn == "uni/controller/setuppol/setupp-77" |
| 171 |
- delete_pod_setup_cm.previous.0.fabricSetupP.attributes.podId == "77" |
| 172 |
- delete_pod_setup_cm.previous.0.fabricSetupP.attributes.podType == "physical" |
| 173 |
- delete_pod_setup_cm.previous.0.fabricSetupP.attributes.tepPool == "10.77.0.0/16" |
| 174 |
- delete_pod_setup_cm.previous.0.fabricSetupP.attributes.descr == "Ansible test pod setup" |
| 175 |
- delete_pod_setup_cm.proposed == {} |
| 176 |
|
| 177 |
|
| 178 |
- name: Delete pod setup again |
| 179 |
cisco.aci.aci_fabric_pod: |
| 180 |
<<: *aci_info |
| 181 |
pod_id: 77 |
| 182 |
state: absent |
| 183 |
register: delete_pod_setup_again |
| 184 |
|
| 185 |
- name: Verify profile deletion idempotence |
| 186 |
ansible.builtin.assert: |
| 187 |
that: |
| 188 |
- delete_pod_setup_again is not changed |
| 189 |
- delete_pod_setup_again.current == [] |
| 190 |
|
| 191 |
|
| 192 |
- name: Create pod setup with out of range pod_id |
| 193 |
cisco.aci.aci_fabric_pod: |
| 194 |
<<: *aci_info |
| 195 |
pod_id: 300 |
| 196 |
pool: 10.123.0.0/24 |
| 197 |
state: present |
| 198 |
register: pod_setup_id_error |
| 199 |
ignore_errors: true |
| 200 |
|
| 201 |
- name: Verify errors of Fabric Setup Pod |
| 202 |
ansible.builtin.assert: |
| 203 |
that: |
| 204 |
- pod_setup_id_error is not changed |
| 205 |
- pod_setup_id_error is failed |
| 206 |
- pod_setup_id_error.msg == "Pod ID{{":"}} 300 is invalid; it must be in the range of 1 to 254." |