As ansible tries to remove temp files after executing the module and the server is not running, it always gives an error (cannot connect to server).
It can be verified that
export ANSIBLE_KEEP_REMOTE_FILES=1
fixes the issue and the module runs correctly.
But of course user cannot always set this in his configurations.
Is there a way to tell the module not to keep remote files always?