cleanmgr is probably waiting for window to display progress, but winrm has no window available so that's probably why it hangs
See https://stackoverflow.com/questions/28852786/automate-process-of-disk-cleanup-cleanmgr-exe-without-user-intervention You might be able to use something like this, but I haven't tried it myself Start-Process -FilePath CleanMgr.exe -ArgumentList '/sagerun:1' -WindowStyle Hidden -Wait or perhaps Start-Process -FilePath CleanMgr.exe -ArgumentList '/sagerun:1' -NoNewWindow -Wait On Wednesday, August 22, 2018 at 1:43:24 PM UTC+1, SurferL wrote: > > Using Ansible 2.6.2, I've set `cleanmgr.exe /sagerun:3` to everything > possible manually on the Windows 10 machine. > > In my playbook I have the following task: > > - name: windows | disk cleanup > win_shell: "cmd.exe /c cleanmgr.exe /sagerun:3" > args: > chdir: "C:\\Windows\\system32" > > However it hangs on this task it seems, and I can't seem to figure out > why, or what I could be debugging. > > Running the command manually on the machine locally works fine. Also, the > command works fine for Windows 7 machine, so I'm not sure this could be a > configuration issue on the Windows 10 machine? > > Ansible debug (showing the ping task just before it hangs): > > TASK [cleanup : windows | verify connection] > *********************************** > task path: > /Users/ansible/builds/0/clean_base_vms/ansible/roles/cleanup/tasks/windows.yml:3 > ok: [win10_base] => { > "changed": false, > "ping": "pong" > } > Using module file > /Users/ansible/clean_base_vms/virtualenv/lib/python2.7/site-packages/ansible/modules/windows/win_shell.ps1 > <ip-address> ESTABLISH WINRM CONNECTION FOR USER: ansible on PORT 5985 TO > <ip-address> > checking if winrm_host <ip-address> is an IPv6 address > <ip-address> WINRM CONNECT: transport=plaintext > endpoint=http://<ip-address>:5985/wsman > <ip-address> WINRM OPEN SHELL: <shell-thing> > EXEC (via pipeline wrapper) > <ip-address> WINRM EXEC 'PowerShell' ['-NoProfile', '-NonInteractive', > '-ExecutionPolicy', 'Unrestricted', '-'] > > > I've left this task running for 5 hours before it fails... > > Any ideas would be greatly appreciated, thank you in advance :) > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/4d3dbfe5-4312-4a6a-b894-2f3c8bee7bc4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
