| 1 |
--- |
| 2 |
- name: ensure vxlan pool anstest does not exist for tests to kick off |
| 3 |
cisco.aci.aci_encap_pool: &aci_vxlan_absent |
| 4 |
host: "{{ aci_hostname }}" |
| 5 |
username: "{{ aci_username }}" |
| 6 |
password: "{{ aci_password }}" |
| 7 |
validate_certs: '{{ aci_validate_certs | default(false) }}' |
| 8 |
use_ssl: '{{ aci_use_ssl | default(true) }}' |
| 9 |
use_proxy: '{{ aci_use_proxy | default(true) }}' |
| 10 |
output_level: debug |
| 11 |
state: absent |
| 12 |
pool: anstest |
| 13 |
pool_type: vxlan |
| 14 |
|
| 15 |
- name: ensure vxlan pool anstest_2 does not exist for tests to kick off |
| 16 |
cisco.aci.aci_encap_pool: |
| 17 |
<<: *aci_vxlan_absent |
| 18 |
pool: anstest_2 |
| 19 |
|
| 20 |
- name: ensure vxlan pool anstest_3 does not exist for tests to kick off |
| 21 |
cisco.aci.aci_encap_pool: |
| 22 |
<<: *aci_vxlan_absent |
| 23 |
pool: anstest_3 |
| 24 |
|
| 25 |
- name: create vxlan pool - check mode works |
| 26 |
cisco.aci.aci_encap_pool: &aci_vxlan_present |
| 27 |
<<: *aci_vxlan_absent |
| 28 |
state: present |
| 29 |
descr: Ansible Test |
| 30 |
check_mode: true |
| 31 |
register: create_vxlan_check_mode |
| 32 |
|
| 33 |
- name: assertion test - present |
| 34 |
ansible.builtin.assert: |
| 35 |
that: |
| 36 |
- create_vxlan_check_mode is changed |
| 37 |
- create_vxlan_check_mode.sent.fvnsVxlanInstP.attributes.descr == 'Ansible Test' |
| 38 |
- create_vxlan_check_mode.sent.fvnsVxlanInstP.attributes.name == 'anstest' |
| 39 |
|
| 40 |
- name: create vxlan pool - creation works |
| 41 |
cisco.aci.aci_encap_pool: |
| 42 |
<<: *aci_vxlan_present |
| 43 |
register: create_vxlan |
| 44 |
|
| 45 |
- name: assertion test - present |
| 46 |
ansible.builtin.assert: |
| 47 |
that: |
| 48 |
- create_vxlan is changed |
| 49 |
- create_vxlan.previous == [] |
| 50 |
- create_vxlan.sent == create_vxlan_check_mode.sent |
| 51 |
- create_vxlan.current.0.fvnsVxlanInstP.attributes.annotation == 'orchestrator:ansible' |
| 52 |
|
| 53 |
- name: create vxlan pool again - idempotency works |
| 54 |
cisco.aci.aci_encap_pool: |
| 55 |
<<: *aci_vxlan_present |
| 56 |
register: idempotent_vxlan |
| 57 |
|
| 58 |
- name: assertion test - present |
| 59 |
ansible.builtin.assert: |
| 60 |
that: |
| 61 |
- idempotent_vxlan is not changed |
| 62 |
- idempotent_vxlan.previous.0.fvnsVxlanInstP.attributes.name == 'anstest' |
| 63 |
- idempotent_vxlan.sent == {} |
| 64 |
|
| 65 |
- name: update vxlan pool - update works |
| 66 |
cisco.aci.aci_encap_pool: |
| 67 |
<<: *aci_vxlan_present |
| 68 |
descr: Ansible Test Change |
| 69 |
register: update_vxlan |
| 70 |
|
| 71 |
- name: assertion test - present |
| 72 |
ansible.builtin.assert: |
| 73 |
that: |
| 74 |
- update_vxlan is changed |
| 75 |
- update_vxlan.sent.fvnsVxlanInstP.attributes.descr == 'Ansible Test Change' |
| 76 |
|
| 77 |
- name: create vxlan pool - used for query |
| 78 |
cisco.aci.aci_encap_pool: |
| 79 |
<<: *aci_vxlan_present |
| 80 |
name: anstest_2 |
| 81 |
register: create_vxlan_2 |
| 82 |
|
| 83 |
- name: assertion test - present |
| 84 |
ansible.builtin.assert: |
| 85 |
that: |
| 86 |
- create_vxlan_2 is changed |
| 87 |
|
| 88 |
- name: create vxlan pool with pool allocation mode - failure message works |
| 89 |
cisco.aci.aci_encap_pool: |
| 90 |
<<: *aci_vxlan_present |
| 91 |
name: anstest_3 |
| 92 |
pool_allocation_mode: dynamic |
| 93 |
ignore_errors: true |
| 94 |
register: create_vxlan_alloc_mode |
| 95 |
|
| 96 |
- name: assertion test - present |
| 97 |
ansible.builtin.assert: |
| 98 |
that: |
| 99 |
- create_vxlan_alloc_mode is failed |
| 100 |
- "create_vxlan_alloc_mode.msg == 'vxlan pools do not support setting the \\'pool_allocation_mode\\'; please remove this parameter from the task'" |
| 101 |
|
| 102 |
- name: get vxlan pool - get object works |
| 103 |
cisco.aci.aci_encap_pool: &aci_vxlan_query |
| 104 |
<<: *aci_vxlan_present |
| 105 |
state: query |
| 106 |
register: query_vxlan |
| 107 |
|
| 108 |
- name: assertion test - query |
| 109 |
ansible.builtin.assert: |
| 110 |
that: |
| 111 |
- query_vxlan is not changed |
| 112 |
- query_vxlan.current | length == 1 |
| 113 |
- '"infra/vxlanns-anstest.json" in query_vxlan.url' |
| 114 |
|
| 115 |
- name: get created static vlan pool - get class works |
| 116 |
cisco.aci.aci_encap_pool: |
| 117 |
<<: *aci_vxlan_query |
| 118 |
pool: "{{ fake_var | default(omit) }}" |
| 119 |
register: query_vxlan_all |
| 120 |
|
| 121 |
- name: assertion test - query |
| 122 |
ansible.builtin.assert: |
| 123 |
that: |
| 124 |
- query_vxlan_all is not changed |
| 125 |
- query_vxlan_all.current | length > 1 |
| 126 |
- '"class/fvnsVxlanInstP.json" in query_vxlan_all.url' |
| 127 |
|
| 128 |
- name: delete vxlan pool - check mode works |
| 129 |
cisco.aci.aci_encap_pool: |
| 130 |
<<: *aci_vxlan_absent |
| 131 |
check_mode: true |
| 132 |
register: delete_vxlan_check_mode |
| 133 |
|
| 134 |
- name: assertion test - absent |
| 135 |
ansible.builtin.assert: |
| 136 |
that: |
| 137 |
- delete_vxlan_check_mode is changed |
| 138 |
- delete_vxlan_check_mode.previous != [] |
| 139 |
|
| 140 |
- name: delete vxlan pool - deletion works |
| 141 |
cisco.aci.aci_encap_pool: |
| 142 |
<<: *aci_vxlan_absent |
| 143 |
register: delete_vxlan |
| 144 |
|
| 145 |
- name: assertion test - absent |
| 146 |
ansible.builtin.assert: |
| 147 |
that: |
| 148 |
- delete_vxlan is changed |
| 149 |
- delete_vxlan.previous == delete_vxlan_check_mode.previous |
| 150 |
- delete_vxlan.previous.0.fvnsVxlanInstP.attributes.name == "anstest" |
| 151 |
|
| 152 |
- name: delete vxlan pool again - idempotency works |
| 153 |
cisco.aci.aci_encap_pool: |
| 154 |
<<: *aci_vxlan_absent |
| 155 |
register: delete_vxlan_idempotent |
| 156 |
|
| 157 |
- name: missing param - failure message works |
| 158 |
cisco.aci.aci_encap_pool: |
| 159 |
<<: *aci_vxlan_absent |
| 160 |
pool: "{{ fake_var | default(omit) }}" |
| 161 |
ignore_errors: true |
| 162 |
register: delete_vxlan_pool_fail |
| 163 |
|
| 164 |
- name: assertion test - absent |
| 165 |
ansible.builtin.assert: |
| 166 |
that: |
| 167 |
- delete_vxlan_idempotent is not changed |
| 168 |
- delete_vxlan_idempotent.previous == [] |
| 169 |
|
| 170 |
- name: delete vxlan pool - cleanup |
| 171 |
cisco.aci.aci_encap_pool: |
| 172 |
<<: *aci_vxlan_absent |
| 173 |
pool: anstest_2 |
| 174 |
|
| 175 |
- name: assertion test - absent |
| 176 |
ansible.builtin.assert: |
| 177 |
that: |
| 178 |
- delete_vxlan_pool_fail is failed |
| 179 |
- 'delete_vxlan_pool_fail.msg == "state is absent but all of the following are missing: pool"' |