From 1e439ac11c2270fe08b05f8b0f8f2d966e184e47 Mon Sep 17 00:00:00 2001 From: David Galloway Date: Thu, 3 Nov 2016 16:43:19 -0400 Subject: [PATCH] firmware: Add NVMe firmware update support for smithi Signed-off-by: David Galloway --- roles/firmware/tasks/main.yml | 6 ++++++ roles/firmware/tasks/smithi/nvme.yml | 29 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 roles/firmware/tasks/smithi/nvme.yml diff --git a/roles/firmware/tasks/main.yml b/roles/firmware/tasks/main.yml index 8215db7b..c679df44 100644 --- a/roles/firmware/tasks/main.yml +++ b/roles/firmware/tasks/main.yml @@ -18,6 +18,12 @@ - bmc when: '"smithi" in ansible_hostname' +# NVMe firmware flashing is only supported on RHEL/CentOS +- include: smithi/nvme.yml + tags: + - nvme + when: '"smithi" in ansible_hostname and ansible_pkg_mgr == "yum"' + # 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/nvme.yml b/roles/firmware/tasks/smithi/nvme.yml new file mode 100644 index 00000000..60bd3ba0 --- /dev/null +++ b/roles/firmware/tasks/smithi/nvme.yml @@ -0,0 +1,29 @@ +--- +- name: Install Intel SSD Data Center Tool + yum: + name: "{{ nvme_firmware_package }}" + state: present + +# This will gather a list of serial numbers in case there are multiple NVMe drives. +- name: Gather list of NVMe device serial numbers + shell: isdct show -d SerialNumber -intelssd | grep SerialNumber | awk '{ print $3 }' + register: nvme_serial_list_raw + +- name: Store ansible-friendly list of NVMe device Serial Numbers + set_fact: + nvme_device_list: "{{ nvme_serial_list_raw.stdout.split('\n') }}" + +# Despite the -force flag, this command won't flash firmware on a device that +# already has the latest firmware. It'll just return 3 as the exit code. +# Ansible fails a task with an rc of 3 hence the added failed_when logic. +# A successful firmware update return code is 0. +- name: Update each NVMe device's firmware + shell: "isdct load -force -intelssd {{ item }}" + with_items: "{{ nvme_device_list|default([]) }}" + register: nvme_update_output + failed_when: "'Error' in nvme_update_output.stdout" + changed_when: nvme_update_output.rc == 0 + +# Print firmware flash output +# Syntax discovered here: https://github.com/ansible/ansible/issues/5564 +- debug: var=nvme_update_output.results|map(attribute='stdout_lines')|list -- 2.47.3