| 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: Ensure first maintenance policy does not exist |
| 36 |
cisco.aci.aci_maintenance_policy: &aci_maintenance_policy_absent |
| 37 |
<<: *aci_info |
| 38 |
name: anstest_policy |
| 39 |
description: test for maintenance policy |
| 40 |
run_mode: pause_never |
| 41 |
graceful: True |
| 42 |
scheduler: anstest_scheduler |
| 43 |
ignore_compat: true |
| 44 |
admin_state: untriggered |
| 45 |
download_state: untriggered |
| 46 |
notify_condition: notify_always_between_sets |
| 47 |
smu_operation: smu_install |
| 48 |
smu_operation_flags: smu_reload_skip |
| 49 |
state: absent |
| 50 |
|
| 51 |
- name: Ensure second maintenance policy does not exist |
| 52 |
cisco.aci.aci_maintenance_policy: &aci_maintenance_policy_2_absent |
| 53 |
<<: *aci_info |
| 54 |
name: anstest_policy_2 |
| 55 |
scheduler: anstest_scheduler |
| 56 |
state: absent |
| 57 |
|
| 58 |
- name: Create first maintenance policy (check_mode) |
| 59 |
cisco.aci.aci_maintenance_policy: &aci_maintenance_policy_present |
| 60 |
<<: *aci_maintenance_policy_absent |
| 61 |
state: present |
| 62 |
check_mode: true |
| 63 |
register: cm_add_maintenance_policy_1 |
| 64 |
|
| 65 |
- name: Create first maintenance policy (normal_mode) |
| 66 |
cisco.aci.aci_maintenance_policy: |
| 67 |
<<: *aci_maintenance_policy_present |
| 68 |
register: nm_add_maintenance_policy_1 |
| 69 |
|
| 70 |
- name: Create first maintenance policy again - testing idempotency |
| 71 |
cisco.aci.aci_maintenance_policy: |
| 72 |
<<: *aci_maintenance_policy_present |
| 73 |
register: idempotency_add_maintenance_policy_1 |
| 74 |
|
| 75 |
- name: Create second maintenance policy |
| 76 |
cisco.aci.aci_maintenance_policy: &aci_maintenance_policy_2_present |
| 77 |
<<: *aci_maintenance_policy_2_absent |
| 78 |
state: present |
| 79 |
register: nm_add_maintenance_policy_2 |
| 80 |
|
| 81 |
- name: Asserts for creation tasks |
| 82 |
ansible.builtin.assert: |
| 83 |
that: |
| 84 |
- cm_add_maintenance_policy_1 is changed |
| 85 |
- cm_add_maintenance_policy_1.previous == [] |
| 86 |
- cm_add_maintenance_policy_1.current == [] |
| 87 |
- nm_add_maintenance_policy_1 is changed |
| 88 |
- nm_add_maintenance_policy_1.current.0.maintMaintP.attributes.adminSt == "untriggered" |
| 89 |
- nm_add_maintenance_policy_1.current.0.maintMaintP.attributes.downloadSt == "untriggered" |
| 90 |
- nm_add_maintenance_policy_1.current.0.maintMaintP.attributes.notifCond == "notifyAlwaysBetweenSets" |
| 91 |
- nm_add_maintenance_policy_1.current.0.maintMaintP.attributes.smuOperation == "smuInstall" |
| 92 |
- nm_add_maintenance_policy_1.current.0.maintMaintP.attributes.smuOperationFlags == "smuReloadSkip" |
| 93 |
- nm_add_maintenance_policy_1.current.0.maintMaintP.attributes.graceful == "yes" |
| 94 |
- nm_add_maintenance_policy_1.current.0.maintMaintP.attributes.ignoreCompat == "yes" |
| 95 |
- nm_add_maintenance_policy_1.current.0.maintMaintP.attributes.name == "anstest_policy" |
| 96 |
- nm_add_maintenance_policy_1.current.0.maintMaintP.attributes.runMode == "pauseNever" |
| 97 |
- nm_add_maintenance_policy_1.current.0.maintMaintP.children.0.maintRsPolScheduler.attributes.tnTrigSchedPName == "anstest_scheduler" |
| 98 |
- idempotency_add_maintenance_policy_1 is not changed |
| 99 |
- nm_add_maintenance_policy_2 is changed |
| 100 |
- nm_add_maintenance_policy_2.current.0.maintMaintP.attributes.adminSt == "untriggered" |
| 101 |
- nm_add_maintenance_policy_2.current.0.maintMaintP.attributes.graceful == "no" |
| 102 |
- nm_add_maintenance_policy_2.current.0.maintMaintP.attributes.ignoreCompat == "no" |
| 103 |
- nm_add_maintenance_policy_2.current.0.maintMaintP.attributes.downloadSt == "untriggered" |
| 104 |
- nm_add_maintenance_policy_2.current.0.maintMaintP.attributes.notifCond == "notifyOnlyOnFailures" |
| 105 |
- nm_add_maintenance_policy_2.current.0.maintMaintP.attributes.smuOperation == "smuInstall" |
| 106 |
- nm_add_maintenance_policy_2.current.0.maintMaintP.attributes.smuOperationFlags == "smuReloadImmediate" |
| 107 |
- nm_add_maintenance_policy_2.current.0.maintMaintP.attributes.name == "anstest_policy_2" |
| 108 |
- nm_add_maintenance_policy_2.current.0.maintMaintP.attributes.runMode == "pauseOnlyOnFailures" |
| 109 |
- nm_add_maintenance_policy_2.current.0.maintMaintP.children.0.maintRsPolScheduler.attributes.tnTrigSchedPName == "anstest_scheduler" |
| 110 |
|
| 111 |
- name: Query all maintenance policies |
| 112 |
cisco.aci.aci_maintenance_policy: |
| 113 |
<<: *aci_info |
| 114 |
state: query |
| 115 |
register: query_all_maintenance_policy |
| 116 |
|
| 117 |
- name: Query first maintenance policy |
| 118 |
cisco.aci.aci_maintenance_policy: |
| 119 |
<<: *aci_maintenance_policy_present |
| 120 |
state: query |
| 121 |
register: query_first_maintenance_policy |
| 122 |
|
| 123 |
- name: Asserts for query tasks |
| 124 |
ansible.builtin.assert: |
| 125 |
that: |
| 126 |
- query_all_maintenance_policy is not changed |
| 127 |
- query_all_maintenance_policy.current | length >= 2 |
| 128 |
- '"maintRsPolScheduler" in query_all_maintenance_policy.filter_string' |
| 129 |
- '"class/maintMaintP.json" in query_all_maintenance_policy.url' |
| 130 |
- query_first_maintenance_policy is not changed |
| 131 |
- query_first_maintenance_policy.current.0.maintMaintP.attributes.adminSt == "untriggered" |
| 132 |
- query_first_maintenance_policy.current.0.maintMaintP.attributes.downloadSt == "untriggered" |
| 133 |
- query_first_maintenance_policy.current.0.maintMaintP.attributes.notifCond == "notifyAlwaysBetweenSets" |
| 134 |
- query_first_maintenance_policy.current.0.maintMaintP.attributes.smuOperation == "smuInstall" |
| 135 |
- query_first_maintenance_policy.current.0.maintMaintP.attributes.smuOperationFlags == "smuReloadSkip" |
| 136 |
- query_first_maintenance_policy.current.0.maintMaintP.attributes.graceful == "yes" |
| 137 |
- query_first_maintenance_policy.current.0.maintMaintP.attributes.ignoreCompat == "yes" |
| 138 |
- query_first_maintenance_policy.current.0.maintMaintP.attributes.name == "anstest_policy" |
| 139 |
- query_first_maintenance_policy.current.0.maintMaintP.attributes.runMode == "pauseNever" |
| 140 |
- query_first_maintenance_policy.current.0.maintMaintP.children.0.maintRsPolScheduler.attributes.tnTrigSchedPName == "anstest_scheduler" |
| 141 |
|
| 142 |
- name: Delete first maintenance policy (check_mode) |
| 143 |
cisco.aci.aci_maintenance_policy: |
| 144 |
<<: *aci_maintenance_policy_present |
| 145 |
state: absent |
| 146 |
check_mode: true |
| 147 |
register: cm_delete_maintenance_policy_1 |
| 148 |
|
| 149 |
- name: Delete first maintenance policy (normal_mode) |
| 150 |
cisco.aci.aci_maintenance_policy: |
| 151 |
<<: *aci_maintenance_policy_present |
| 152 |
state: absent |
| 153 |
register: nm_delete_maintenance_policy_1 |
| 154 |
|
| 155 |
- name: Delete first maintenance policy again - testing idempotency |
| 156 |
cisco.aci.aci_maintenance_policy: |
| 157 |
<<: *aci_maintenance_policy_present |
| 158 |
state: absent |
| 159 |
register: idempotency_delete_maintenance_policy_1 |
| 160 |
|
| 161 |
- name: Delete second maintenance policy (normal_mode) |
| 162 |
cisco.aci.aci_maintenance_policy: |
| 163 |
<<: *aci_maintenance_policy_2_present |
| 164 |
state: absent |
| 165 |
register: nm_delete_maintenance_policy_2 |
| 166 |
|
| 167 |
- name: Asserts for deletion tasks |
| 168 |
ansible.builtin.assert: |
| 169 |
that: |
| 170 |
- cm_delete_maintenance_policy_1 is changed |
| 171 |
- cm_delete_maintenance_policy_1.proposed == {} |
| 172 |
- nm_delete_maintenance_policy_1 is changed |
| 173 |
- nm_delete_maintenance_policy_1.previous != [] |
| 174 |
- nm_delete_maintenance_policy_1.current == [] |
| 175 |
- idempotency_delete_maintenance_policy_1 is not changed |
| 176 |
- idempotency_delete_maintenance_policy_1.previous == [] |
| 177 |
- nm_delete_maintenance_policy_2 is changed |
| 178 |
- nm_delete_maintenance_policy_2.previous != [] |
| 179 |
- nm_delete_maintenance_policy_2.current == [] |
| 180 |
|
| 181 |
- name: Delete scheduler - clean up the environment |
| 182 |
cisco.aci.aci_fabric_scheduler: |
| 183 |
<<: *aci_fabric_scheduler_present |
| 184 |
state: absent |