Unable to get module for managing windows system working in ansible

ansible

I am learning ansible. My laptop is running Windows 7 and is part of a domain. I have installed Ubuntu linux inside a VM on my laptop and installed Ansible in it, and other python and kerberos packages. Have also configured kerberos but unable to use windows modules to even ping my laptop using win_ping. Ansible I think is still trying to use ssh instead of winrm.

Have added user and password info in group_vars/windows.yml file. Domain is lab.test.com

The message I get when running the command ansible laptop -m win_ping -vvvvv

Loaded callback minimal of type stdout, v2.0
<laptop.lab.test.com> ESTABLISH SSH CONNECTION FOR USER: None
<laptop.lab.test.com> SSH: ansible.cfg set ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=60s)
<laptop.lab.test.com> SSH: ansible_password/ansible_ssh_pass not set: (-o)(KbdInteractiveAuthentication=no)(-o)(PreferredA
uthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey)(-o)(PasswordAuthentication=no)
<laptop.lab.test.com> SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=10)
<laptop.lab.test.com> SSH: PlayContext set ssh_common_args: ()
<laptop.lab.test.com> SSH: PlayContext set ssh_extra_args: ()
<laptop.lab.test.com> SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/home/vagrant/.ansible/cp/ansibl
e-ssh-%h-%p-%r)
<laptop.lab.test.com> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no
 -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPa
th=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r U0128159-TPL-B.ten.thomsonreuters.com '/bin/sh -c '"'"'( umask 22 && mkdir -p "` echo $HOM
E/.ansible/tmp/ansible-tmp-1462196365.95-235238773027827 `" && echo "` echo $HOME/.ansible/tmp/ansible-tmp-1462196365.95-235238773027827 `"
)'"'"''

laptop.lab.test.com | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh.",
    "unreachable": true
}

The web page I am following is How To Setup An Ansible Test Lab For Windows Managed Nodes & Custom Windows Modules

I have googled but unable to find, yet, the issue I am facing. Please help.

Thanks

Best Answer

To Solve this error, you have to specify few arguments in all.yml file to authenticate user in windows. also you need to install pywinrm module using pip.

pip install pywinrm

This is a must package to be installed on your controller machine.

ansible_user: Administrator
ansible_password: SecretPasswordGoesHere
ansible_port: 5986
ansible_connection: winrm

But as you are using kerberos for authentication, you can remove ansible_password and user kinit for creating ticket.

if your org. using a domain then you need to add that in your ansible_user:user@domain.com to work.