From RHEL not able to connect to windows VM

Hi Team ,

I am trying to do a POC on Ansible first time.I am using RHEL as a master and Windows 2012 as a client .Installed ansible 2.7 in RHEL and winrm in windows and done inventory entries in RHEL .

i am getting below error.Kindly help …

ERROR

[root@Amaster group_vars]# ansible web -i inventory.yml -m win_ping
18.224.135.4 | UNREACHABLE! => {
“changed”: false,
“msg”: “Failed to connect to the host via ssh: ssh: connect to host 18.224.135.4 port 22: Connection timed out\r\n”,
“unreachable”: true

Thanks & Regards,
Suma

By default ansible will use ssh connection which tries to connect to port 22 even if the target host is windows.

In order to tell ansible to connect using winrm which uses port 5985(non-ssl)/5986(ssl), you have to add these variable/settings to your inventory file

ansible_port: 5986
ansible_connection: winrm
ansible_winrm_server_cert_validation: ignore
ansible_winrm_transport: ntlm
ansible_user: user@windows_domain.com
ansible_password: xxxxxxx

Also, make sure you have ran ConfigureRemotingForAnsible.ps1 on your windows host

–Tony

Hi Tony,

Thanks for your mail.I tried the one which you suggested still not working.actually our windows are using public ip and its not in domain.will that cause issue?

Thanks & Regards,
Suma