| 1 |
--- |
| 2 |
- name: "Ansible Module for Simple Firmware Rollback" |
| 3 |
hosts: redfish_hosts |
| 4 |
gather_facts: false |
| 5 |
tasks: |
| 6 |
- name: Rollback firmware components for 17G |
| 7 |
block: |
| 8 |
- name: Get all firmware inventory |
| 9 |
ansible.builtin.uri: |
| 10 |
url: "{{ 'https://' + baseuri + '/redfish/v1/UpdateService/' + |
| 11 |
'FirmwareInventory?$expand=*($levels=1)' }}" |
| 12 |
method: GET |
| 13 |
ca_path: "/path/to/ca_cert.pem" |
| 14 |
url_username: "{{ username }}" |
| 15 |
url_password: "{{ password }}" |
| 16 |
headers: |
| 17 |
Content-Type: "application/json" |
| 18 |
return_content: true |
| 19 |
register: redfish_response |
| 20 |
|
| 21 |
- name: Extract all 'Name' attributes from the response |
| 22 |
ansible.builtin.set_fact: |
| 23 |
firmware_names: "{{ redfish_response.json.Members |
| 24 |
| map(attribute='Name') | list }}" |
| 25 |
|
| 26 |
- name: Find the firmware name that contains 'BIOS' |
| 27 |
ansible.builtin.set_fact: |
| 28 |
bios_firmware_name: "{{ firmware_names |
| 29 |
| select('contains', 'BIOS') | first }}" |
| 30 |
|
| 31 |
- name: Rollback the BIOS component firmware |
| 32 |
dellemc.openmanage.redfish_firmware_rollback: |
| 33 |
baseuri: "{{ baseuri }}" |
| 34 |
username: "{{ username }}" |
| 35 |
password: "{{ password }}" |
| 36 |
ca_path: "/path/to/ca_cert.pem" |
| 37 |
name: "{{ bios_firmware_name }}" |
| 38 |
delegate_to: localhost |
| 39 |
tags: rollback-bios-17g |
| 40 |
|
| 41 |
- name: Find the firmware name that contains 'NIC' |
| 42 |
ansible.builtin.set_fact: |
| 43 |
network_firmware_name: "{{ firmware_names |
| 44 |
| select('contains', 'NIC') | first }}" |
| 45 |
|
| 46 |
- name: Rollback all NIC cards with a name starting from 'NIC' for 17G. |
| 47 |
dellemc.openmanage.redfish_firmware_rollback: |
| 48 |
baseuri: "{{ baseuri }}" |
| 49 |
username: "{{ username }}" |
| 50 |
password: "{{ password }}" |
| 51 |
ca_path: "/path/to/ca_cert.pem" |
| 52 |
name: "{{ network_firmware_name }}" |
| 53 |
delegate_to: localhost |
| 54 |
tags: rollback-match-17g |
| 55 |
|
| 56 |
- name: Rollback all the component firmware except |
| 57 |
BIOS component for 17G. |
| 58 |
dellemc.openmanage.redfish_firmware_rollback: |
| 59 |
baseuri: "{{ baseuri }}" |
| 60 |
username: "{{ username }}" |
| 61 |
password: "{{ password }}" |
| 62 |
ca_path: "/path/to/ca_cert.pem" |
| 63 |
name: "(?!{{ bios_firmware_name }}).*" |
| 64 |
delegate_to: localhost |
| 65 |
tags: rollback-except-17g |
| 66 |
|
| 67 |
- name: Rollback a BIOS component firmware for 16G |
| 68 |
dellemc.openmanage.redfish_firmware_rollback: |
| 69 |
baseuri: "{{ baseuri }}" |
| 70 |
username: "{{ username }}" |
| 71 |
password: "{{ password }}" |
| 72 |
ca_path: "/path/to/ca_cert.pem" |
| 73 |
name: "BIOS" |
| 74 |
delegate_to: localhost |
| 75 |
tags: rollback-bios |
| 76 |
|
| 77 |
- name: Rollback all NIC cards with a name starting from ' |
| 78 |
Broadcom Gigabit' for 16G. |
| 79 |
dellemc.openmanage.redfish_firmware_rollback: |
| 80 |
baseuri: "{{ baseuri }}" |
| 81 |
username: "{{ username }}" |
| 82 |
password: "{{ password }}" |
| 83 |
ca_path: "/path/to/ca_cert.pem" |
| 84 |
name: "Broadcom Gigabit Ethernet.*" |
| 85 |
delegate_to: localhost |
| 86 |
tags: rollback-match |
| 87 |
|
| 88 |
- name: Rollback all the component firmware except BIOS component for 16G. |
| 89 |
dellemc.openmanage.redfish_firmware_rollback: |
| 90 |
baseuri: "{{ baseuri }}" |
| 91 |
username: "{{ username }}" |
| 92 |
password: "{{ password }}" |
| 93 |
ca_path: "/path/to/ca_cert.pem" |
| 94 |
name: "(?!BIOS).*" |
| 95 |
delegate_to: localhost |
| 96 |
tags: rollback-except |
| 97 |
|
| 98 |
- name: Rollback all the available firmware component for 16G and 17G. |
| 99 |
dellemc.openmanage.redfish_firmware_rollback: |
| 100 |
baseuri: "{{ baseuri }}" |
| 101 |
username: "{{ username }}" |
| 102 |
password: "{{ password }}" |
| 103 |
ca_path: "/path/to/ca_cert.pem" |
| 104 |
name: ".*" |
| 105 |
delegate_to: localhost |
| 106 |
tags: rollback-all |