| 1 | --- |
| 2 | - name: Dell OpenManage Ansible device inventory details. |
| 3 | hosts: ome |
| 4 | gather_facts: false |
| 5 | tasks: |
| 6 | - name: Immediately update the firmware of a single component for a |
| 7 | specific host |
| 8 | dellemc.openmanage.omevv_firmware: |
| 9 | hostname: "{{ hostname }}" |
| 10 | vcenter_uuid: "{{ vcenter_uuid }}" |
| 11 | vcenter_username: "{{ vcenter_username }}" |
| 12 | vcenter_password: "{{ vcenter_password }}" |
| 13 | ca_path: "{{ ca_path }}" |
| 14 | run_now: false |
| 15 | date_time: "2024-09-10T20:50:00Z" |
| 16 | enter_maintenance_mode_timeout: 60 |
| 17 | enter_maintenance_mode_options: FULL_DATA_MIGRATION |
| 18 | drs_check: true |
| 19 | evacuate_VMs: true |
| 20 | exit_maintenance_mode: true |
| 21 | reboot_options: NEXTREBOOT |
| 22 | maintenance_mode_count_check: true |
| 23 | check_vSAN_health: truet |
| 24 | reset_idrac: true |
| 25 | delete_job_queue: true |
| 26 | targets: |
| 27 | - servicetag: SVCTAG1 |
| 28 | firmware_components: |
| 29 | - "DCIM:INSTALLED#802__Diagnostics.Embedded.1:LC.Embedded.1" |
| 30 | delegate_to: localhost |
| 31 | |
| 32 | - name: Update the firmware of multiple components at scheduled time for a |
| 33 | specific host |
| 34 | dellemc.openmanage.omevv_firmware: |
| 35 | hostname: "{{ hostname }}" |
| 36 | vcenter_uuid: "{{ vcenter_uuid }}" |
| 37 | vcenter_username: "{{ vcenter_username }}" |
| 38 | vcenter_password: "{{ vcenter_password }}" |
| 39 | ca_path: "{{ ca_path }}" |
| 40 | run_now: false |
| 41 | date_time: "2024-09-10T20:50:00+05:30" |
| 42 | enter_maintenance_mode_timeout: 60 |
| 43 | enter_maintenance_mode_options: ENSURE_ACCESSIBILITY |
| 44 | drs_check: true |
| 45 | evacuate_VMs: true |
| 46 | exit_maintenance_mode: true |
| 47 | reboot_options: FORCEREBOOT |
| 48 | maintenance_mode_count_check: true |
| 49 | check_vSAN_health: true |
| 50 | reset_idrac: false |
| 51 | delete_job_queue: false |
| 52 | targets: |
| 53 | - host: "XXX.XXX.XXX.XZ" |
| 54 | firmware_components: |
| 55 | - "DCIM:INSTALLED#iDRAC.Embedded.1-1#IDRACinfo" |
| 56 | - "DCIM:INSTALLED#301_C_BOSS.SL.14-1" |
| 57 | - "DCIM:INSTALLED#807__TPM.Integrated.1-1" |
| 58 | delegate_to: localhost |
| 59 | |
| 60 | - name: Update the firmware of multiple components at scheduled time for a |
| 61 | cluster |
| 62 | dellemc.openmanage.omevv_firmware: |
| 63 | hostname: "{{ hostname }}" |
| 64 | vcenter_uuid: "{{ vcenter_uuid }}" |
| 65 | vcenter_username: "{{ vcenter_username }}" |
| 66 | vcenter_password: "{{ vcenter_password }}" |
| 67 | ca_path: "{{ ca_path }}" |
| 68 | run_now: false |
| 69 | date_time: "2024-09-10T20:50:00+05:30" |
| 70 | enter_maintenance_mode_timeout: 60 |
| 71 | enter_maintenance_mode_options: ENSURE_ACCESSIBILITY |
| 72 | drs_check: true |
| 73 | evacuate_VMs: true |
| 74 | exit_maintenance_mode: true |
| 75 | reboot_options: SAFEREBOOT |
| 76 | maintenance_mode_count_check: true |
| 77 | check_vSAN_health: true |
| 78 | reset_idrac: false |
| 79 | delete_job_queue: false |
| 80 | targets: |
| 81 | - cluster: cluster_a |
| 82 | firmware_components: |
| 83 | - "DCIM:INSTALLED#iDRAC.Embedded.1-1#IDRACinfo" |
| 84 | - "DCIM:INSTALLED#301_C_BOSS.SL.14-1" |
| 85 | - "DCIM:INSTALLED#807__TPM.Integrated.1-1" |
| 86 | delegate_to: localhost |
| 87 | |
| 88 | - name: Retrieve firmware compliance report of all the hosts in the specific |
| 89 | cluster |
| 90 | dellemc.openmanage.omevv_firmware_compliance_info: |
| 91 | hostname: "{{ hostname }}" |
| 92 | vcenter_uuid: "{{ vcenter_uuid }}" |
| 93 | vcenter_username: "{{ vcenter_username }}" |
| 94 | vcenter_password: "{{ vcenter_password }}" |
| 95 | ca_path: "{{ ca_path }}" |
| 96 | clusters: |
| 97 | - cluster_name: cluster_a |
| 98 | register: compliance_data |
| 99 | delegate_to: localhost |
| 100 | |
| 101 | - name: Initialize compliance status results |
| 102 | ansible.builtin.set_fact: |
| 103 | source_names: [] |
| 104 | service_tag: "" |
| 105 | delegate_to: localhost |
| 106 | |
| 107 | - name: Flatten host compliance reports |
| 108 | ansible.builtin.set_fact: |
| 109 | host_reports: "{{ |
| 110 | compliance_data.firmware_compliance_info | |
| 111 | map(attribute='hostComplianceReports') | |
| 112 | flatten(levels=1) }}" |
| 113 | delegate_to: localhost |
| 114 | |
| 115 | - name: Flatten and filter concompliant components |
| 116 | ansible.builtin.set_fact: |
| 117 | non_compliant_components: >- |
| 118 | {{ |
| 119 | host_reports |
| 120 | | map(attribute='componentCompliances') |
| 121 | | flatten(levels=1) |
| 122 | | selectattr('driftStatus', 'equalto', 'NonCompliant') |
| 123 | }} |
| 124 | delegate_to: localhost |
| 125 | |
| 126 | - name: Gather components source name and set service tag |
| 127 | ansible.builtin.set_fact: |
| 128 | source_names: "{{ source_names + [item.sourceName] }}" |
| 129 | service_tag: "{{ host_report.serviceTag }}" |
| 130 | loop: "{{ non_compliant_components }}" |
| 131 | vars: |
| 132 | host_report: >- |
| 133 | {{ |
| 134 | host_reports |
| 135 | | selectattr('componentCompliances', 'contains', item) |
| 136 | | first |
| 137 | }} |
| 138 | delegate_to: localhost |
| 139 | |
| 140 | - name: Combine the final non compliance report |
| 141 | ansible.builtin.set_fact: |
| 142 | noncompliance_report: |
| 143 | sourceNames: "{{ source_names }}" |
| 144 | serviceTag: "{{ service_tag }}" |
| 145 | |
| 146 | - name: Update firmware at the scheduled time for all non compliant |
| 147 | components of a specific host using service tag |
| 148 | dellemc.openmanage.omevv_firmware: |
| 149 | hostname: "{{ hostname }}" |
| 150 | vcenter_uuid: "{{ vcenter_uuid }}" |
| 151 | vcenter_username: "{{ vcenter_username }}" |
| 152 | vcenter_password: "{{ vcenter_password }}" |
| 153 | ca_path: "{{ ca_path }}" |
| 154 | run_now: false |
| 155 | date_time: "2024-09-10T20:50:00Z" |
| 156 | enter_maintenance_mode_timeout: 60 |
| 157 | enter_maintenance_mode_options: NO_DATA_MIGRATION |
| 158 | drs_check: true |
| 159 | evacuate_VMs: false |
| 160 | exit_maintenance_mode: true |
| 161 | reboot_options: SAFEREBOOT |
| 162 | maintenance_mode_count_check: true |
| 163 | check_vSAN_health: true |
| 164 | reset_idrac: true |
| 165 | delete_job_queue: true |
| 166 | targets: |
| 167 | - servicetag: "{{ noncompliance_report.serviceTag }}" |
| 168 | firmware_components: "{{ noncompliance_report.sourceNames }}" |
| 169 | delegate_to: localhost |