Ansible Error while executing adhoc commands/playbook in windows remote

ansible-error

Error – Failed to connect to the host via ssh

Solution – You need to set ansible_connection=winrm to connect to windows


[windows]
13.233.160.153
[windows:vars]
ansible_connection=winrm

Error – auth method ssl requires a username

Solution – You need to set ansible_user and ansible_password to connect to windows remote


[windows]
13.233.160.153
[windows:vars]
ansible_connection=winrm
ansible_user=administrator
ansible_password=”w$y%O.ubjQhQhfa&ME@5=TeEd4Yhfy”

ansible_winrm_scheme=http
ansible_winrm_scheme=https
#Reference
https://docs.ansible.com/ansible/latest/user_guide/windows_winrm.html

Error – certificate verify failed

Solution – You need to set ansible_winrm_transport=basic and ansible_winrm_server_cert_validation=ignore


[windows]
13.233.160.153
[windows:vars]
ansible_user=LocalUsername
ansible_password=Password
ansible_connection=winrm
ansible_winrm_transport=basic
ansible_winrm_server_cert_validation=ignore