| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 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: Verify Cloud and Non-Cloud Sites in use. |
| 23 |
ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml |
| 24 |
|
| 25 |
- name: Execute tasks only for non-cloud sites |
| 26 |
when: query_cloud.current == [] |
| 27 |
block: |
| 28 |
|
| 29 |
- name: Create Scheduler |
| 30 |
cisco.aci.aci_fabric_scheduler: &aci_fabric_scheduler_present |
| 31 |
<<: *aci_info |
| 32 |
name: anstest_scheduler |
| 33 |
state: present |
| 34 |
|
| 35 |
- name: Create maintenance policy |
| 36 |
cisco.aci.aci_maintenance_policy: &aci_maintenance_policy_present |
| 37 |
<<: *aci_info |
| 38 |
name: anstest_policy |
| 39 |
scheduler: anstest_scheduler |
| 40 |
state: present |
| 41 |
|
| 42 |
- name: Ensure first maintenance group does not exist |
| 43 |
cisco.aci.aci_maintenance_group: &aci_maintenance_group_absent |
| 44 |
<<: *aci_info |
| 45 |
group: anstest_group |
| 46 |
policy: anstest_policy |
| 47 |
firmware_nodes_type: controller |
| 48 |
type_group: all |
| 49 |
description: test for maintenance group |
| 50 |
state: absent |
| 51 |
|
| 52 |
- name: Ensure second maintenance group does not exist |
| 53 |
cisco.aci.aci_maintenance_group: &aci_maintenance_group_2_absent |
| 54 |
<<: *aci_info |
| 55 |
group: anstest_group_2 |
| 56 |
policy: anstest_policy_2 |
| 57 |
state: absent |
| 58 |
|
| 59 |
- name: Create first maintenance group (check_mode) |
| 60 |
cisco.aci.aci_maintenance_group: &aci_maintenance_group_present |
| 61 |
<<: *aci_maintenance_group_absent |
| 62 |
state: present |
| 63 |
check_mode: true |
| 64 |
register: cm_add_maintenance_group_1 |
| 65 |
|
| 66 |
- name: Create first maintenance group (normal_mode) |
| 67 |
cisco.aci.aci_maintenance_group: |
| 68 |
<<: *aci_maintenance_group_present |
| 69 |
register: nm_add_maintenance_group_1 |
| 70 |
|
| 71 |
- name: Create first maintenance group again - testing idempotency |
| 72 |
cisco.aci.aci_maintenance_group: |
| 73 |
<<: *aci_maintenance_group_present |
| 74 |
register: idempotency_add_maintenance_group_1 |
| 75 |
|
| 76 |
- name: Create second maintenance group |
| 77 |
cisco.aci.aci_maintenance_group: &aci_maintenance_group_2_present |
| 78 |
<<: *aci_maintenance_group_2_absent |
| 79 |
state: present |
| 80 |
register: nm_add_maintenance_group_2 |
| 81 |
|
| 82 |
- name: Asserts for creation tasks |
| 83 |
ansible.builtin.assert: |
| 84 |
that: |
| 85 |
- cm_add_maintenance_group_1 is changed |
| 86 |
- cm_add_maintenance_group_1.previous == [] |
| 87 |
- cm_add_maintenance_group_1.current == [] |
| 88 |
- nm_add_maintenance_group_1 is changed |
| 89 |
- nm_add_maintenance_group_1.current.0.maintMaintGrp.attributes.name == "anstest_group" |
| 90 |
- nm_add_maintenance_group_1.current.0.maintMaintGrp.attributes.fwtype == "controller" |
| 91 |
- nm_add_maintenance_group_1.current.0.maintMaintGrp.attributes.type == "ALL" |
| 92 |
- nm_add_maintenance_group_1.current.0.maintMaintGrp.children.0.maintRsMgrpp.attributes.tnMaintMaintPName == "anstest_policy" |
| 93 |
- idempotency_add_maintenance_group_1 is not changed |
| 94 |
- nm_add_maintenance_group_2 is changed |
| 95 |
- nm_add_maintenance_group_2.current.0.maintMaintGrp.attributes.name == "anstest_group_2" |
| 96 |
- nm_add_maintenance_group_2.current.0.maintMaintGrp.children.0.maintRsMgrpp.attributes.tnMaintMaintPName == "anstest_policy_2" |
| 97 |
- nm_add_maintenance_group_2.current.0.maintMaintGrp.attributes.fwtype == "switch" |
| 98 |
- nm_add_maintenance_group_2.current.0.maintMaintGrp.attributes.type == "range" |
| 99 |
|
| 100 |
|
| 101 |
- name: Query all maintenance groups |
| 102 |
cisco.aci.aci_maintenance_group: |
| 103 |
<<: *aci_info |
| 104 |
state: query |
| 105 |
register: query_all_maintenance_group |
| 106 |
|
| 107 |
- name: Query first maintenance group |
| 108 |
cisco.aci.aci_maintenance_group: |
| 109 |
<<: *aci_maintenance_group_present |
| 110 |
state: query |
| 111 |
register: query_first_maintenance_group |
| 112 |
|
| 113 |
- name: Asserts for query tasks |
| 114 |
ansible.builtin.assert: |
| 115 |
that: |
| 116 |
- query_all_maintenance_group is not changed |
| 117 |
- query_all_maintenance_group.current | length >= 2 |
| 118 |
- '"maintRsMgrpp" in query_all_maintenance_group.filter_string' |
| 119 |
- '"class/maintMaintGrp.json" in query_all_maintenance_group.url' |
| 120 |
- query_all_maintenance_group.current.0.maintMaintGrp.attributes.name == "anstest_group" |
| 121 |
- query_all_maintenance_group.current.1.maintMaintGrp.attributes.name == "anstest_group_2" |
| 122 |
- query_first_maintenance_group is not changed |
| 123 |
- query_first_maintenance_group.current.0.maintMaintGrp.attributes.name == "anstest_group" |
| 124 |
- query_first_maintenance_group.current.0.maintMaintGrp.children.0.maintRsMgrpp.attributes.tnMaintMaintPName == "anstest_policy" |
| 125 |
- query_first_maintenance_group.current.0.maintMaintGrp.attributes.fwtype == "controller" |
| 126 |
- query_first_maintenance_group.current.0.maintMaintGrp.attributes.type == "ALL" |
| 127 |
|
| 128 |
- name: Delete first maintenance group (check_mode) |
| 129 |
cisco.aci.aci_maintenance_group: |
| 130 |
<<: *aci_maintenance_group_present |
| 131 |
state: absent |
| 132 |
check_mode: true |
| 133 |
register: cm_delete_maintenance_group_1 |
| 134 |
|
| 135 |
- name: Delete first maintenance group (normal_mode) |
| 136 |
cisco.aci.aci_maintenance_group: |
| 137 |
<<: *aci_maintenance_group_present |
| 138 |
state: absent |
| 139 |
register: nm_delete_maintenance_group_1 |
| 140 |
|
| 141 |
- name: Delete first maintenance group again - testing idempotency |
| 142 |
cisco.aci.aci_maintenance_group: |
| 143 |
<<: *aci_maintenance_group_present |
| 144 |
state: absent |
| 145 |
register: idempotency_delete_maintenance_group_1 |
| 146 |
|
| 147 |
- name: Delete second maintenance group (normal_mode) |
| 148 |
cisco.aci.aci_maintenance_group: |
| 149 |
<<: *aci_maintenance_group_2_present |
| 150 |
state: absent |
| 151 |
register: nm_delete_maintenance_group_2 |
| 152 |
|
| 153 |
- name: Asserts for deletion tasks |
| 154 |
ansible.builtin.assert: |
| 155 |
that: |
| 156 |
- cm_delete_maintenance_group_1 is changed |
| 157 |
- cm_delete_maintenance_group_1.proposed == {} |
| 158 |
- nm_delete_maintenance_group_1 is changed |
| 159 |
- nm_delete_maintenance_group_1.previous != [] |
| 160 |
- nm_delete_maintenance_group_1.current == [] |
| 161 |
- idempotency_delete_maintenance_group_1 is not changed |
| 162 |
- idempotency_delete_maintenance_group_1.previous == [] |
| 163 |
- nm_delete_maintenance_group_2 is changed |
| 164 |
- nm_delete_maintenance_group_2.previous != [] |
| 165 |
- nm_delete_maintenance_group_2.current == [] |
| 166 |
|
| 167 |
- name: Delete maintenance policy - clean up the environment |
| 168 |
cisco.aci.aci_maintenance_policy: |
| 169 |
<<: *aci_maintenance_policy_present |
| 170 |
state: absent |
| 171 |
|
| 172 |
- name: Delete scheduler - clean up the environment |
| 173 |
cisco.aci.aci_fabric_scheduler: |
| 174 |
<<: *aci_fabric_scheduler_present |
| 175 |
state: absent |