---
 - name: Identifying System ROM device
   shell: hp-conrep -s | grep -i family | awk '{print $NF}' | tr A-Z a-z
   register: systemrom

 - name: Installing firmware RPM for System ROM
   yum: name=hp-firmware-system-{{ systemrom.stdout }} state=latest

 - name: Firmware path lookup
   shell: rpm -ql hp-firmware-system-"{{ systemrom.stdout }}" | grep '\.scexe'
   register: FirmwarePath

 - name: Clearing previous log entries
   shell: "> /var/cpq/Component.log"
   ignore_errors: true

 - name: Install firmware
   expect:
     command: "{{ FirmwarePath.stdout }}"
     responses:
       'Do you want to upgrade the software to a newer version (y/n) ?': 'y'

# - name: Installing System ROM firmware
#   script: ../files/firmware_installer.sh --some-arguments "{{ FirmwarePath.stdout }}"
#   ignore_errors: true

 - name: Displaying Firmware installation logs
   shell: "cat /var/cpq/Component.log"
   register: InstallLog

 - debug: var=InstallLog.stdout_lines

 - name: System ROM firmware Cleanup
   yum: name=hp-firmware-{{ systemrom.stdout }} state=absent


---
 - name: Identifying System ROM device
   shell: hp-conrep -s | grep -i family | awk '{print $NF}' | tr A-Z a-z
   register: systemrom

 - name: Installing firmware RPM for System ROM
   yum: name=hp-firmware-system-{{ systemrom.stdout }} state=latest

 - name: Firmware path lookup
   shell: rpm -ql hp-firmware-system-"{{ systemrom.stdout }}" | grep '\.scexe'
   register: FirmwarePath

 - name: Clearing previous log entries
   shell: "> /var/cpq/Component.log"
   ignore_errors: true

 - name: Install firmware
   expect:
     command: "{{ FirmwarePath.stdout }}"
     timeout: 600
     responses:
       'Do you want to upgrade the software to a newer version.*': 'y'
       'Do you want to reboot your system now.*': 'n'

# - name: Installing System ROM firmware
#   script: ../files/firmware_installer.sh --some-arguments "{{ FirmwarePath.stdout }}"
#   ignore_errors: true

 - name: Displaying Firmware installation logs
   shell: "cat /var/cpq/Component.log"
   register: InstallLog

 - debug: var=InstallLog.stdout_lines

 - name: System ROM firmware Cleanup
   yum: name=hp-firmware-{{ systemrom.stdout }} state=absent


Handle reboot question by sending "n"
Handle reboot question by sending "n"

We really need to have an optional handler to do the reboot here, but
obviously this is risky! Ideally this would happen only when the machine
is first kickstarted.
