| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
- name: Test that we have an ACI MultiSite host, username and password |
| 7 |
ansible.builtin.fail: |
| 8 |
msg: "Please define the following variables: mso_hostname, mso_username and mso_password." |
| 9 |
when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined |
| 10 |
|
| 11 |
|
| 12 |
- name: Set vars |
| 13 |
ansible.builtin.set_fact: |
| 14 |
mso_info: &mso_info |
| 15 |
host: "{{ mso_hostname }}" |
| 16 |
username: "{{ mso_username }}" |
| 17 |
password: "{{ mso_password }}" |
| 18 |
validate_certs: "{{ mso_validate_certs | default(false) }}" |
| 19 |
use_ssl: "{{ mso_use_ssl | default(true) }}" |
| 20 |
use_proxy: "{{ mso_use_proxy | default(true) }}" |
| 21 |
output_level: '{{ mso_output_level | default("debug") }}' |
| 22 |
|
| 23 |
|
| 24 |
- name: Query MSO version |
| 25 |
cisco.mso.mso_version: |
| 26 |
<<: *mso_info |
| 27 |
state: query |
| 28 |
register: version |
| 29 |
|
| 30 |
- name: Execute tasks only for MSO version >= 4.3 |
| 31 |
when: version.current.version is version('4.3', '>=') |
| 32 |
block: |
| 33 |
- name: Ensure templates do not exist |
| 34 |
cisco.mso.ndo_template: &template_absent |
| 35 |
<<: *mso_info |
| 36 |
name: ansible_fabric_policy_template |
| 37 |
template_type: fabric_policy |
| 38 |
state: absent |
| 39 |
|
| 40 |
- name: Ensure templates exist |
| 41 |
cisco.mso.ndo_template: |
| 42 |
<<: *template_absent |
| 43 |
state: present |
| 44 |
|
| 45 |
- name: Create two vlan pools |
| 46 |
cisco.mso.ndo_vlan_pool: |
| 47 |
<<: *mso_info |
| 48 |
template: ansible_fabric_policy_template |
| 49 |
vlan_pool: "{{ item.name }}" |
| 50 |
vlan_ranges: |
| 51 |
- from_vlan: "{{ item.from_vlan }}" |
| 52 |
to_vlan: "{{ item.to_vlan }}" |
| 53 |
state: present |
| 54 |
loop: |
| 55 |
- { name: ansible_test_vlan_pool_1, from_vlan: 100, to_vlan: 200 } |
| 56 |
- { name: ansible_test_vlan_pool_2, from_vlan: 300, to_vlan: 400 } |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
- name: Create a new physical domain (check_mode) |
| 61 |
cisco.mso.ndo_physical_domain: &create_physical_domain |
| 62 |
<<: *mso_info |
| 63 |
template: ansible_fabric_policy_template |
| 64 |
physical_domain: ansible_test_physical_domain |
| 65 |
pool: ansible_test_vlan_pool_1 |
| 66 |
state: present |
| 67 |
check_mode: true |
| 68 |
register: cm_create_new_physical_domain |
| 69 |
|
| 70 |
- name: Create a new physical domain |
| 71 |
cisco.mso.ndo_physical_domain: |
| 72 |
<<: *create_physical_domain |
| 73 |
register: nm_create_new_physical_domain |
| 74 |
|
| 75 |
- name: Create a new physical domain again |
| 76 |
cisco.mso.ndo_physical_domain: |
| 77 |
<<: *create_physical_domain |
| 78 |
register: nm_create_new_physical_domain_again |
| 79 |
|
| 80 |
- name: Assert physical domain was created |
| 81 |
assert: |
| 82 |
that: |
| 83 |
- cm_create_new_physical_domain is changed |
| 84 |
- cm_create_new_physical_domain.previous == {} |
| 85 |
- cm_create_new_physical_domain.current.name == "ansible_test_physical_domain" |
| 86 |
- cm_create_new_physical_domain.current.pool == "ansible_test_vlan_pool_1" |
| 87 |
- nm_create_new_physical_domain is changed |
| 88 |
- nm_create_new_physical_domain.previous == {} |
| 89 |
- nm_create_new_physical_domain.current.name == "ansible_test_physical_domain" |
| 90 |
- nm_create_new_physical_domain.current.pool == "ansible_test_vlan_pool_1" |
| 91 |
- nm_create_new_physical_domain_again is not changed |
| 92 |
- nm_create_new_physical_domain_again.previous.name == "ansible_test_physical_domain" |
| 93 |
- nm_create_new_physical_domain_again.previous.description == "" |
| 94 |
- nm_create_new_physical_domain_again.previous.uuid is defined |
| 95 |
- nm_create_new_physical_domain_again.previous.pool == "ansible_test_vlan_pool_1" |
| 96 |
- nm_create_new_physical_domain_again.current.name == "ansible_test_physical_domain" |
| 97 |
- nm_create_new_physical_domain_again.current.description == "" |
| 98 |
- nm_create_new_physical_domain_again.current.uuid is defined |
| 99 |
- nm_create_new_physical_domain_again.current.pool == "ansible_test_vlan_pool_1" |
| 100 |
- cm_create_new_physical_domain.current.poolRef == nm_create_new_physical_domain.current.poolRef == nm_create_new_physical_domain_again.previous.poolRef == nm_create_new_physical_domain_again.current.poolRef |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
- name: Update a physical domain description (check_mode) |
| 105 |
cisco.mso.ndo_physical_domain: &update_physical_domain |
| 106 |
<<: *create_physical_domain |
| 107 |
description: changed_description |
| 108 |
check_mode: true |
| 109 |
register: cm_update_physical_domain_description |
| 110 |
|
| 111 |
- name: Update a physical domain description |
| 112 |
cisco.mso.ndo_physical_domain: |
| 113 |
<<: *update_physical_domain |
| 114 |
register: nm_update_physical_domain_description |
| 115 |
|
| 116 |
- name: Update a physical domain description again |
| 117 |
cisco.mso.ndo_physical_domain: |
| 118 |
<<: *update_physical_domain |
| 119 |
register: nm_update_physical_domain_description_again |
| 120 |
|
| 121 |
- name: Assert physical domain was updated |
| 122 |
assert: |
| 123 |
that: |
| 124 |
- cm_update_physical_domain_description is changed |
| 125 |
- cm_update_physical_domain_description.previous.description == "" |
| 126 |
- cm_update_physical_domain_description.current.description == "changed_description" |
| 127 |
- nm_update_physical_domain_description is changed |
| 128 |
- nm_update_physical_domain_description.previous.description == "" |
| 129 |
- nm_update_physical_domain_description.current.description == "changed_description" |
| 130 |
- nm_update_physical_domain_description_again is not changed |
| 131 |
- nm_update_physical_domain_description_again.previous.description == "changed_description" |
| 132 |
- nm_update_physical_domain_description_again.current.description == "changed_description" |
| 133 |
|
| 134 |
- name: Update a physical domain name |
| 135 |
cisco.mso.ndo_physical_domain: &update_physical_domain_name |
| 136 |
<<: *update_physical_domain |
| 137 |
physical_domain_uuid: "{{ nm_update_physical_domain_description.current.uuid }}" |
| 138 |
physical_domain: ansible_test_physical_domain_changed |
| 139 |
register: nm_update_physical_domain_name |
| 140 |
|
| 141 |
- name: Update a physical domain pool |
| 142 |
cisco.mso.ndo_physical_domain: |
| 143 |
<<: *update_physical_domain_name |
| 144 |
pool: ansible_test_vlan_pool_2 |
| 145 |
register: nm_update_physical_domain_pool |
| 146 |
|
| 147 |
- name: Query a physical domain to check the poolRef value |
| 148 |
cisco.mso.ndo_physical_domain: |
| 149 |
<<: *update_physical_domain_name |
| 150 |
state: query |
| 151 |
register: query_physical_domain_pool_2 |
| 152 |
|
| 153 |
- name: Query all physical domain in the template to check the poolRef value |
| 154 |
cisco.mso.ndo_physical_domain: |
| 155 |
<<: *mso_info |
| 156 |
template: ansible_fabric_policy_template |
| 157 |
state: query |
| 158 |
register: query_all_1 |
| 159 |
|
| 160 |
- name: Remove a physical domain pool |
| 161 |
cisco.mso.ndo_physical_domain: |
| 162 |
<<: *update_physical_domain_name |
| 163 |
pool: "" |
| 164 |
register: nm_update_physical_domain_pool_remove |
| 165 |
|
| 166 |
- name: Assert physical domain was updated |
| 167 |
assert: |
| 168 |
that: |
| 169 |
- nm_update_physical_domain_name is changed |
| 170 |
- nm_update_physical_domain_name.previous.name == "ansible_test_physical_domain" |
| 171 |
- nm_update_physical_domain_name.current.name == "ansible_test_physical_domain_changed" |
| 172 |
- nm_update_physical_domain_pool is changed |
| 173 |
- nm_update_physical_domain_pool.previous.pool == "ansible_test_vlan_pool_1" |
| 174 |
- nm_update_physical_domain_pool.current.pool == "ansible_test_vlan_pool_2" |
| 175 |
- nm_update_physical_domain_pool_remove is changed |
| 176 |
- nm_update_physical_domain_pool_remove.previous.pool == "ansible_test_vlan_pool_2" |
| 177 |
- nm_update_physical_domain_pool_remove.current.pool is not defined |
| 178 |
- query_physical_domain_pool_2 is not changed |
| 179 |
- query_all_1 is not changed |
| 180 |
- query_all_1.current | length == 1 |
| 181 |
- query_all_1.current.0.name == "ansible_test_physical_domain_changed" |
| 182 |
- query_all_1.current.0.pool == "ansible_test_vlan_pool_2" |
| 183 |
- nm_update_physical_domain_pool.current.poolRef == nm_update_physical_domain_pool_remove.previous.poolRef == query_physical_domain_pool_2.current.poolRef == query_all_1.current.0.poolRef |
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
- name: Create another physical domain |
| 188 |
cisco.mso.ndo_physical_domain: &create_physical_domain_2 |
| 189 |
<<: *create_physical_domain |
| 190 |
physical_domain: ansible_test_physical_domain_2 |
| 191 |
pool: "{{ fakevar | default(omit)}}" |
| 192 |
description: "This is a test physical domain 2" |
| 193 |
|
| 194 |
- name: Query a physical domain with template_name |
| 195 |
cisco.mso.ndo_physical_domain: |
| 196 |
<<: *create_physical_domain_2 |
| 197 |
state: query |
| 198 |
register: query_one |
| 199 |
|
| 200 |
- name: Query a physical domain with uuid |
| 201 |
cisco.mso.ndo_physical_domain: |
| 202 |
<<: *mso_info |
| 203 |
template: ansible_fabric_policy_template |
| 204 |
physical_domain_uuid: '{{ query_one.current.uuid }}' |
| 205 |
state: query |
| 206 |
register: query_with_uuid |
| 207 |
|
| 208 |
- name: Query all physical domain in the template |
| 209 |
cisco.mso.ndo_physical_domain: |
| 210 |
<<: *mso_info |
| 211 |
template: ansible_fabric_policy_template |
| 212 |
state: query |
| 213 |
register: query_all |
| 214 |
|
| 215 |
- name: Assert physical domain was queried |
| 216 |
assert: |
| 217 |
that: |
| 218 |
- query_one is not changed |
| 219 |
- query_with_uuid is not changed |
| 220 |
- query_one.current.name == query_with_uuid.current.name == "ansible_test_physical_domain_2" |
| 221 |
- query_one.current.uuid == query_with_uuid.current.uuid |
| 222 |
- query_all is not changed |
| 223 |
- query_all.current | length == 2 |
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
- name: Delete a physical domain (check_mode) |
| 228 |
cisco.mso.ndo_physical_domain: &delete_physical_domain |
| 229 |
<<: *update_physical_domain_name |
| 230 |
state: absent |
| 231 |
check_mode: true |
| 232 |
register: cm_delete_physical_domain |
| 233 |
|
| 234 |
- name: Delete a physical domain |
| 235 |
cisco.mso.ndo_physical_domain: |
| 236 |
<<: *delete_physical_domain |
| 237 |
register: nm_delete_physical_domain |
| 238 |
|
| 239 |
- name: Delete a physical domain again |
| 240 |
cisco.mso.ndo_physical_domain: |
| 241 |
<<: *delete_physical_domain |
| 242 |
register: nm_delete_physical_domain_again |
| 243 |
|
| 244 |
- name: Assert physical domain was deleted |
| 245 |
assert: |
| 246 |
that: |
| 247 |
- cm_delete_physical_domain is changed |
| 248 |
- cm_delete_physical_domain.previous.name == 'ansible_test_physical_domain_changed' |
| 249 |
- cm_delete_physical_domain.previous.pool is not defined |
| 250 |
- cm_delete_physical_domain.current == {} |
| 251 |
- nm_delete_physical_domain is changed |
| 252 |
- nm_delete_physical_domain.previous.name == 'ansible_test_physical_domain_changed' |
| 253 |
- nm_delete_physical_domain.previous.pool is not defined |
| 254 |
- nm_delete_physical_domain.current == {} |
| 255 |
- nm_delete_physical_domain_again is not changed |
| 256 |
- nm_delete_physical_domain_again.previous == {} |
| 257 |
- nm_delete_physical_domain_again.current == {} |
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
- name: Ensure templates do not exist |
| 262 |
cisco.mso.ndo_template: |
| 263 |
<<: *template_absent |