Using the wait_for module to check ports from one windows host to another windows host

22 views
Skip to first unread message

marcalfa1

unread,
Mar 7, 2018, 11:24:24 PM3/7/18
to Ansible Project
Not sure if i'm using the wait_for module correctly on two windows host.  I'm getting the error below when trying to check if a port is open from a source windows host to a target windows host.
Wondering if i'm using the module correctly or if this even possible when both hosts are windows.  I've tried the same playbook on two unix host and it worked.
 
---
- hosts: win-host1
  tasks:
    - wait_for:
        host: 192.168.70.13
        port: 9443
        timeout: 10
      ignore_errors: true
      register: result

    - debug: var=result



PLAY [win-host1] ***********************************************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************************************************
ok: [win-host1]

TASK [wait_for] **************************************************************************************************************************************************************************************
 [WARNING]: FATAL ERROR DURING FILE TRANSFER: Traceback (most recent call last):   File "/usr/lib/python2.6/site-packages/ansible/plugins/connection/winrm.py", line 276, in _winrm_exec
self._winrm_send_input(self.protocol, self.shell_id, command_id, data, eof=is_last)   File "/usr/lib/python2.6/site-packages/ansible/plugins/connection/winrm.py", line 256, in _winrm_send_input
protocol.send_message(xmltodict.unparse(rq))   File "/usr/lib/python2.6/site-packages/winrm/protocol.py", line 207, in send_message     return self.transport.send_message(message)   File
"/usr/lib/python2.6/site-packages/winrm/transport.py", line 202, in send_message     raise WinRMTransportError('http', error_message) WinRMTransportError: (u'http', u'Bad HTTP response returned
from server. Code 500')

fatal: [win-host1]: FAILED! => {"msg": "winrm send_input failed"}
...ignoring

TASK [debug] *****************************************************************************************************************************************************************************************
ok: [win-host1] => {
    "result": {
        "failed": true,
        "msg": "winrm send_input failed"
    }
}

PLAY RECAP *******************************************************************************************************************************************************************************************
win-host1    : ok=3    changed=0    unreachable=0    failed=0

Jordan Borean

unread,
Mar 8, 2018, 12:38:31 AM3/8/18
to Ansible Project
The wait_for module is a Python module and can't be run on a Windows host. You can either delegate to the localhost (Ansible controller) and run it from there, or use the win_wait_for module which was added in Ansible 2.4 https://docs.ansible.com/ansible/2.4/win_wait_for_module.html.

Thanks

Jordan
Reply all
Reply to author
Forward
0 new messages