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’
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?
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;
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.