I’ve installed Win32 OpenSSH from Install Win32 OpenSSH · PowerShell/Win32-OpenSSH Wiki · GitHub on some Windows 2019 servers. Works fine so far. But now I’m stuck in the situation how to deploy a newer Win32 OpenSSH release via ansible itself on these servers. Since as soon as I start the update process the connection drops - sounds senible.
SSH is actually quite resilient when it comes to the service being restarted as Ansible will create a local socket to persist the connection between tasks and the connection doesn’t go down even if the main service is restarted. Even if it does fail you could look at using win_reboot to restart the host rather than restarting the service. It shouldn’t be needed but it’ll achieve the same thing just in a way that Ansible explicitly attempts to handle broken connections.
Thank you for your comment. Maybe I’ve not explained my problem correctly. It’s not only the connection drops but the update process fails at all. The installed version is stil lthe same.
That will disable the socket persistence I was talking about so if the connection goes down then you’ll struggle to get it back up again. Is there a reason why you have this? What is the error you get?
Granted I don’t know if the msi install will work if files are in use, there’s little you can really do about that scenario except to either use a different transport for the task or kick the task off in async or as a startup task and try and wait for it with something like wait_for_connection.
Honestly, I can’t remember why I set ControlMaster=no for Windows SSH connections in the ansible_ssh_args. I guess I adopted this from examples on the web. Anyway, changing the value doesn’t change the behaviour.
I’ll try to solve it by creating a windows task and which executes msiexec and check it again in another ansible task e few minutes later. Not graceful but functional… I guess.