From 80711570f1f5dfdb3f14bb94db28024bac8bf504 Mon Sep 17 00:00:00 2001 From: David Galloway Date: Fri, 14 Oct 2016 16:28:55 -0400 Subject: [PATCH] firmware: Add BMC update support for smithi Signed-off-by: David Galloway --- roles/firmware/tasks/main.yml | 5 ++++ roles/firmware/tasks/smithi/bmc-update.yml | 31 ++++++++++++++++++++++ roles/firmware/tasks/smithi/bmc.yml | 27 +++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 roles/firmware/tasks/smithi/bmc-update.yml create mode 100644 roles/firmware/tasks/smithi/bmc.yml diff --git a/roles/firmware/tasks/main.yml b/roles/firmware/tasks/main.yml index fe7f71fe..8215db7b 100644 --- a/roles/firmware/tasks/main.yml +++ b/roles/firmware/tasks/main.yml @@ -13,6 +13,11 @@ tags: - areca +- include: smithi/bmc.yml + tags: + - bmc + when: '"smithi" in ansible_hostname' + # This won't get run if a previous playbook fails. So if a backup of a BIOS is # needed to restore, it'll still be there - name: Clean up firmware update directory diff --git a/roles/firmware/tasks/smithi/bmc-update.yml b/roles/firmware/tasks/smithi/bmc-update.yml new file mode 100644 index 00000000..77e06139 --- /dev/null +++ b/roles/firmware/tasks/smithi/bmc-update.yml @@ -0,0 +1,31 @@ +--- +# This file is only called when current_bmc_version +# and latest_bmc_version do not match + +- name: Install unzip + package: + name: unzip + state: latest + +- name: Create BMC update working directory structure + file: + path: "{{ firmware_update_path }}/bmc-update" + state: directory + +# Download the archive and rename to something the playbook can consume +- name: Download BMC archive + get_url: + url: "{{ bmc_location }}" + dest: "{{ firmware_update_path }}/bmc-update/bmc.zip" + force: yes + +# Extract only the binary blob and the Linux flashing executable +- name: Extract IPMI archive + shell: "cd {{ firmware_update_path }}/bmc-update && unzip -j bmc.zip *.bin */linux/x64/AlUpdate" + +- name: Flash new BMC (Takes around 11 minutes) + shell: "cd {{ firmware_update_path }}/bmc-update && chmod +x AlUpdate && ./AlUpdate -f *.bin -i kcs -r y" + register: bmc_flash_output + +# Print output of flash script +- debug: var=bmc_flash_output.stdout_lines|last diff --git a/roles/firmware/tasks/smithi/bmc.yml b/roles/firmware/tasks/smithi/bmc.yml new file mode 100644 index 00000000..e733de43 --- /dev/null +++ b/roles/firmware/tasks/smithi/bmc.yml @@ -0,0 +1,27 @@ +--- +- name: Install ipmitool + package: + name: ipmitool + state: latest + +- name: Enable IPMI kernel modules + modprobe: + name: "{{ item }}" + state: present + with_items: + - ipmi_devintf + - ipmi_si + +- name: Determine current BMC firmware version + shell: ipmitool mc info | grep "Firmware Revision" | awk '{ print $4 }' + register: current_bmc_version + changed_when: False + +- name: Determine if BMC update is needed + set_fact: + need_bmc_update: true + when: current_bmc_version.stdout != latest_bmc_version + +- name: Include BMC update logic + include: roles/firmware/tasks/smithi/bmc-update.yml + when: need_bmc_update is defined and need_bmc_update == true -- 2.47.3