Description
SUMMARY
During Windows Update, Ansible failed to finish the playbook due to connection error.
However, Windows Update are well launched and the system is updated.
This error doesn't appears each time and doesn't depends on the OS version of Windows Server.
All servers are configured in the same way.
ISSUE TYPE
- Bug Report
COMPONENT NAME
ansible.windows.win_updates
ANSIBLE VERSION
ansible [core 2.13.10]
config file = None
configured module search path = ['/home/rundeck/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/rundeck/.local/lib/python3.8/site-packages/ansible
ansible collection location = /home/rundeck/.ansible/collections:/usr/share/ansible/collections
executable location = /home/rundeck/.local/bin/ansible
python version = 3.8.10 (default, May 26 2023, 14:05:08) [GCC 9.4.0]
jinja version = 3.1.2
libyaml = True
COLLECTION VERSION
# /home/rundeck/.ansible/collections/ansible_collections
Collection Version
--------------- -------
ansible.windows 2.0.0
CONFIGURATION
LOCALHOST_WARNING(/home/rundeck/ansible.cfg) = False
OS / ENVIRONMENT
Targets are Windows Server (from 2012R2 to 2022) configured with Win32-OpenSSH.
STEPS TO REPRODUCE
Execute this playbook.
Ansible playbook:
- name: Update Windows Server
hosts: windows
gather_facts: true
ignore_errors: false
tasks:
- name: Install all updates (logs in C:\Temp\ansible_wu.txt). Reboot = "{{ reboot }}".
ansible.windows.win_updates:
category_names: '*'
reboot: "{{ reboot }}"
log_path: C:\Temp\ansible_wu.txt
reboot_timeout: 5400 # 90 minutes
Inventory:
[windows]
192.168.134.6
[windows:vars]
ansible_port=2222
ansible_user=svc-ssh
ansible_connection=ssh
ansible_shell_type=powershell
ansible_ssh_common_args='-o StrictHostKeyChecking=no'
EXPECTED RESULTS
No errors in Ansible output:
TASK [Install all updates (logs in C:\Temp\ansible_wu.txt). Reboot = "True".] ***
ok: [192.168.134.6]
ACTUAL RESULTS
Errors in Ansible output:
TASK [Install all updates (logs in C:\Temp\ansible_wu.txt). Reboot = "False".] ***
[WARNING]: Unknown failure when polling update result - attempting to cancel
task: Failed to connect to the host via ssh: #< CLIXML
[WARNING]: Error deleting remote temporary files (rc: 1, stderr: Remove-Item :
Cannot remove item C:\Users\svc-ssh\AppData\Local\Temp\ansible-
tmp-1690444971.0486283 -23240-145060149894651\output.txt: The process cannot
access the file 'output.txt' because it is being used by another process. At
line:2 char:1 + Remove-Item 'C:\Users\svc-ssh\AppData\Local\Temp\ansible-
tmp-16904449 ... +
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
CategoryInfo : WriteError: (output.txt:FileInfo) [Remove-Item],
IOException + FullyQualifiedErrorId :
RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItem
Command Remove-Item : Cannot remove item C:\Users\svc-
ssh\AppData\Local\Temp\ansible-tmp-1690444971.0486283-23240-145060149894651:
The directory is not empty. At line:2 char:1 + Remove-Item 'C:\Users\svc-
ssh\AppData\Local\Temp\ansible-tmp-16904449 ... +
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
CategoryInfo : WriteError: (C:\Users\svc-
ss...145060149894651:DirectoryInfo) [Remov e-Item], IOException +
FullyQualifiedErrorId :
RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItem
Command})
fatal: [192.168.134.6]: UNREACHABLE! => {"changed": false, "failed_update_count": 0, "filtered_updates": {}, "found_update_count": 0, "installed_update_count": 0, "msg": "Failed to connect to the host via ssh: #< CLIXML", "unreachable": true, "updates": {}}
COMMENTS
First, I was thinking of network drivers update (VMware Net, as all virtual machines are in VMware infrastructure), which can cause a down of the network connection. But in the example provided (real use case), there was no kind of update: only Cumulative Update, Windows Malicious Software Removal Tool, etc.