| 1 |
--- |
| 2 |
- block: |
| 3 |
- name: Define anchor for Intersight API login info |
| 4 |
ansible.builtin.set_fact: |
| 5 |
api_info: &api_info |
| 6 |
api_private_key: "{{ api_private_key }}" |
| 7 |
api_key_id: "{{ api_key_id }}" |
| 8 |
api_uri: "{{ api_uri | default(omit) }}" |
| 9 |
validate_certs: "{{ validate_certs | default(omit) }}" |
| 10 |
organization: "{{ organization }}" |
| 11 |
|
| 12 |
- name: Make sure Environment is clean |
| 13 |
cisco.intersight.intersight_bios_policy: |
| 14 |
<<: *api_info |
| 15 |
name: "{{ item }}" |
| 16 |
state: absent |
| 17 |
loop: |
| 18 |
- test_bios_policy_minimal |
| 19 |
- test_bios_policy_virtualization |
| 20 |
- test_bios_policy_performance |
| 21 |
|
| 22 |
- name: Create BIOS policy with minimal parameters - check-mode |
| 23 |
cisco.intersight.intersight_bios_policy: |
| 24 |
<<: *api_info |
| 25 |
name: test_bios_policy_minimal |
| 26 |
description: "Test BIOS policy with minimal parameters" |
| 27 |
check_mode: true |
| 28 |
register: creation_res_check_mode |
| 29 |
|
| 30 |
- name: Verify BIOS policy was not created - check-mode |
| 31 |
ansible.builtin.assert: |
| 32 |
that: |
| 33 |
- creation_res_check_mode is changed |
| 34 |
- creation_res_check_mode.api_response == {} |
| 35 |
|
| 36 |
- name: Create BIOS policy with minimal parameters |
| 37 |
cisco.intersight.intersight_bios_policy: |
| 38 |
<<: *api_info |
| 39 |
name: test_bios_policy_minimal |
| 40 |
description: "Test BIOS policy with minimal parameters" |
| 41 |
register: creation_res |
| 42 |
|
| 43 |
- name: Fetch info after creation |
| 44 |
cisco.intersight.intersight_bios_policy_info: |
| 45 |
<<: *api_info |
| 46 |
name: test_bios_policy_minimal |
| 47 |
register: creation_info_res |
| 48 |
|
| 49 |
- name: Verify BIOS policy creation by info |
| 50 |
ansible.builtin.assert: |
| 51 |
that: |
| 52 |
- creation_res.changed |
| 53 |
- creation_info_res.api_response[0].Name == 'test_bios_policy_minimal' |
| 54 |
- creation_info_res.api_response[0].ObjectType == 'bios.Policy' |
| 55 |
- creation_info_res.api_response[0].Description == 'Test BIOS policy with minimal parameters' |
| 56 |
|
| 57 |
- name: Verify BIOS policy creation response aligns with info response |
| 58 |
ansible.builtin.assert: |
| 59 |
that: |
| 60 |
- creation_res.api_response.Name == creation_info_res.api_response[0].Name |
| 61 |
- creation_res.api_response.Moid == creation_info_res.api_response[0].Moid |
| 62 |
|
| 63 |
- name: Create BIOS policy (idempotency check) |
| 64 |
cisco.intersight.intersight_bios_policy: |
| 65 |
<<: *api_info |
| 66 |
name: test_bios_policy_minimal |
| 67 |
description: "Test BIOS policy with minimal parameters" |
| 68 |
register: creation_res_ide |
| 69 |
|
| 70 |
- name: Verify BIOS policy creation (idempotency check) |
| 71 |
ansible.builtin.assert: |
| 72 |
that: |
| 73 |
- not creation_res_ide.changed |
| 74 |
|
| 75 |
- name: Update BIOS policy description |
| 76 |
cisco.intersight.intersight_bios_policy: |
| 77 |
<<: *api_info |
| 78 |
name: test_bios_policy_minimal |
| 79 |
description: "Updated BIOS policy description" |
| 80 |
register: update_res |
| 81 |
|
| 82 |
- name: Fetch info after update |
| 83 |
cisco.intersight.intersight_bios_policy_info: |
| 84 |
<<: *api_info |
| 85 |
name: test_bios_policy_minimal |
| 86 |
register: update_info_res |
| 87 |
|
| 88 |
- name: Verify BIOS policy update |
| 89 |
ansible.builtin.assert: |
| 90 |
that: |
| 91 |
- update_res.changed |
| 92 |
- update_info_res.api_response[0].Description == 'Updated BIOS policy description' |
| 93 |
|
| 94 |
- name: Create BIOS policy optimized for virtualization |
| 95 |
cisco.intersight.intersight_bios_policy: |
| 96 |
<<: *api_info |
| 97 |
name: test_bios_policy_virtualization |
| 98 |
description: "BIOS policy optimized for virtualization workloads" |
| 99 |
tags: |
| 100 |
- Key: Environment |
| 101 |
Value: Test |
| 102 |
- Key: Workload |
| 103 |
Value: Virtualization |
| 104 |
intel_hyper_threading_tech: enabled |
| 105 |
intel_virtualization_technology: enabled |
| 106 |
intel_vtd_coherency_support: enabled |
| 107 |
intel_vt_for_directed_io: enabled |
| 108 |
processor_c1e: disabled |
| 109 |
processor_c6report: disabled |
| 110 |
cpu_performance: enterprise |
| 111 |
register: creation_res_vm |
| 112 |
|
| 113 |
- name: Fetch info for virtualization BIOS policy |
| 114 |
cisco.intersight.intersight_bios_policy_info: |
| 115 |
<<: *api_info |
| 116 |
name: test_bios_policy_virtualization |
| 117 |
register: creation_info_res_vm |
| 118 |
|
| 119 |
- name: Verify virtualization BIOS policy creation |
| 120 |
ansible.builtin.assert: |
| 121 |
that: |
| 122 |
- creation_res_vm.changed |
| 123 |
- creation_info_res_vm.api_response[0].Name == 'test_bios_policy_virtualization' |
| 124 |
- creation_info_res_vm.api_response[0].IntelHyperThreadingTech == 'enabled' |
| 125 |
- creation_info_res_vm.api_response[0].IntelVirtualizationTechnology == 'enabled' |
| 126 |
- creation_info_res_vm.api_response[0].IntelVtdCoherencySupport == 'enabled' |
| 127 |
- creation_info_res_vm.api_response[0].IntelVtForDirectedIo == 'enabled' |
| 128 |
|
| 129 |
- name: Create BIOS policy optimized for performance |
| 130 |
cisco.intersight.intersight_bios_policy: |
| 131 |
<<: *api_info |
| 132 |
name: test_bios_policy_performance |
| 133 |
description: "BIOS policy optimized for high performance" |
| 134 |
intel_turbo_boost_tech: enabled |
| 135 |
enhanced_intel_speed_step_tech: enabled |
| 136 |
energy_efficient_turbo: disabled |
| 137 |
cpu_performance: hpc |
| 138 |
hardware_prefetch: enabled |
| 139 |
adjacent_cache_line_prefetch: enabled |
| 140 |
register: creation_res_perf |
| 141 |
|
| 142 |
- name: Fetch info for performance BIOS policy |
| 143 |
cisco.intersight.intersight_bios_policy_info: |
| 144 |
<<: *api_info |
| 145 |
name: test_bios_policy_performance |
| 146 |
register: creation_info_res_perf |
| 147 |
|
| 148 |
- name: Verify performance BIOS policy creation |
| 149 |
ansible.builtin.assert: |
| 150 |
that: |
| 151 |
- creation_res_perf.changed |
| 152 |
- creation_info_res_perf.api_response[0].Name == 'test_bios_policy_performance' |
| 153 |
- creation_info_res_perf.api_response[0].IntelTurboBoostTech == 'enabled' |
| 154 |
- creation_info_res_perf.api_response[0].CpuPerformance == 'hpc' |
| 155 |
|
| 156 |
- name: Fetch all BIOS policies under the organization |
| 157 |
cisco.intersight.intersight_bios_policy_info: |
| 158 |
<<: *api_info |
| 159 |
register: all_policies_res |
| 160 |
|
| 161 |
- name: Check that there are at least 3 BIOS policies under this organization |
| 162 |
ansible.builtin.assert: |
| 163 |
that: |
| 164 |
- all_policies_res.api_response | length >= 3 |
| 165 |
|
| 166 |
- name: Verify specific policies exist in the list |
| 167 |
ansible.builtin.assert: |
| 168 |
that: |
| 169 |
- all_policies_res.api_response | selectattr('Name', 'equalto', 'test_bios_policy_minimal') | list | length == 1 |
| 170 |
- all_policies_res.api_response | selectattr('Name', 'equalto', 'test_bios_policy_virtualization') | list | length == 1 |
| 171 |
- all_policies_res.api_response | selectattr('Name', 'equalto', 'test_bios_policy_performance') | list | length == 1 |
| 172 |
|
| 173 |
- name: Delete BIOS policy - test_bios_policy_performance |
| 174 |
cisco.intersight.intersight_bios_policy: |
| 175 |
<<: *api_info |
| 176 |
name: test_bios_policy_performance |
| 177 |
state: absent |
| 178 |
register: delete_res |
| 179 |
|
| 180 |
- name: Verify deletion |
| 181 |
ansible.builtin.assert: |
| 182 |
that: |
| 183 |
- delete_res.changed |
| 184 |
|
| 185 |
- name: Delete BIOS policy again (idempotency check) |
| 186 |
cisco.intersight.intersight_bios_policy: |
| 187 |
<<: *api_info |
| 188 |
name: test_bios_policy_performance |
| 189 |
state: absent |
| 190 |
register: delete_res_ide |
| 191 |
|
| 192 |
- name: Verify deletion idempotency |
| 193 |
ansible.builtin.assert: |
| 194 |
that: |
| 195 |
- not delete_res_ide.changed |
| 196 |
|
| 197 |
- name: Verify policy is deleted via info module |
| 198 |
cisco.intersight.intersight_bios_policy_info: |
| 199 |
<<: *api_info |
| 200 |
name: test_bios_policy_performance |
| 201 |
register: deleted_policy_info |
| 202 |
|
| 203 |
- name: Check that deleted policy is not found |
| 204 |
ansible.builtin.assert: |
| 205 |
that: |
| 206 |
- deleted_policy_info.api_response.Results | default(deleted_policy_info.api_response) | length == 0 |
| 207 |
|
| 208 |
always: |
| 209 |
- name: Remove BIOS policies |
| 210 |
cisco.intersight.intersight_bios_policy: |
| 211 |
<<: *api_info |
| 212 |
name: "{{ item }}" |
| 213 |
state: absent |
| 214 |
loop: |
| 215 |
- test_bios_policy_minimal |
| 216 |
- test_bios_policy_virtualization |
| 217 |
- test_bios_policy_performance |