# BIOS update succeeds, but shows as ansible failure

**URL:** <https://forum.ansible.com/t/bios-update-succeeds-but-shows-as-ansible-failure/26483>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [January 15, 2018, 8:18pm UTC](https://forum.ansible.com/t/bios-update-succeeds-but-shows-as-ansible-failure/26483 "2018-01-15T20:18:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [January 15, 2018, 8:18pm UTC](https://forum.ansible.com/t/bios-update-succeeds-but-shows-as-ansible-failure/26483/1 "2018-01-15T20:18:24Z")

</div>

Hello all.

Here’s a simple one, I think, which is non-fatal, but I’d like to clean it up. I want to push BIOS updates to our Dell desktops, and have created a playbook for that purpose:

- hosts: all

gather\_facts: false

tasks:

- name: Copy Dell BIOS update to desktop  
win\_copy: src=/etc/ansible/files/OptiPlex\_7040\_1.8.1.exe dest=‘C:/temp/OptiPlex\_7040\_1.8.1.exe’
- name: Install Dell BIOS update  
raw: c:\windows\system32\cmd.exe /C “c:\temp\OptiPlex\_7040\_1.8.1.exe /s /r /f”

When I run it, BIOS does get updated. However, since the update really happens after the desktops reboot, Ansible sees it as a failure:

fatal: [conference03]: FAILED! =\> {“changed”: true, “failed”: true, “rc”: 6, “stderr”: “”, “stdout”: “”, “stdout\_lines”: }

Is there a way for this not to show as a failure?

Also, I’d like to extend the playbook to delete the BIOS update executable from the desktops. Again, since the desktops have rebooted, the playbook end before the delete can happen. How can I deal with that?

Thanks.

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [January 15, 2018, 9:44pm UTC](https://forum.ansible.com/t/bios-update-succeeds-but-shows-as-ansible-failure/26483/2 "2018-01-15T21:44:48Z")

</div>

A few different things

- I would avoid using the key=value options for Windows, it screws around with paths and you are forces to either escape backslashes with \ or use forward slashes which don’t work in all cases
- I would use win\_command to execute commands instead of raw (unless you are on a version older than 2.2)
- No need to call cmd.exe when you are executing a variable, just another interpreter that can mess up your arguments
- It is failing as the return code is not 0, in this case you are getting 6 as the rc

Obviously the rc of 6 means something and you probably need to find out what it is but if it is valid you can do;

`

- name; Copy Dell BIOS update to desktop  
win\_copy:  
src: /etc/ansible/files/OptiPlex\_7040\_1.8.1.exe  
dest: C:\temp\OptiPlex\_7040\_1.8.1.exe

- name: Install Dell BIOS update  
win\_command: C:\temp\OptiPlex\_7040\_1.8.1.exe /s /r /f  
register: bios\_result  
failed\_when: bios\_result.rc != 6  
`

You could also have the following failed\_when so it doesn’t fail if the RC is 0 or 6: ‘failed\_when: bios\_result.rc not in [0, 6]’

Thanks

Jordan

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [January 15, 2018, 10:59pm UTC](https://forum.ansible.com/t/bios-update-succeeds-but-shows-as-ansible-failure/26483/3 "2018-01-15T22:59:03Z")

</div>

Jordan, thanks for the reply!

I’ll try the suggestions you mentioned:

- I’ll consider taking a different approach vis-a-vis key-value pairs (just sticking with what I’ve used for a long time);
- use win\_command instead of raw (again, I’ve been using raw for so long the it’s etched in my mind);
- OK on the use of cmd.exe;
- I have no idea what an rc of 6 means. The ansible-playbook man page doesn’t list a return code of 6. Googling hasn’t turned up anything.

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [January 16, 2018, 1:01am UTC](https://forum.ansible.com/t/bios-update-succeeds-but-shows-as-ansible-failure/26483/4 "2018-01-16T01:01:43Z")

</div>

No worries, they were merely suggestions, the raw/win\_command side is probably more important once you get into setting environment variables or using become (they don’t work with raw).

The return code is completely independent of Ansible and is what the executable returned, usually 0 means that is was successful and non 0 is a failure. Unfortunately there is no standard what each return code means and it is completely based on the executable you are running. In this case I would probably contact dell to see what it may mean.

One thing that may have muddied the water a bit was that it was running through cmd, while I believe it just passes through the return value, it might be a good idea to check what the RC is when running it without cmd.exe /c.

Thanks

Jordan
