Which method use 'wait_for' to check open ports?

Hi !

i’m making a playbook like this:

  • name: Check all port numbers are accessible from current host
    wait_for:
    host: “{{ item[0] }}”
    port: “{{ item[1] }}”
    state: started
    delay: 0
    timeout: 3
    delegate_to: localhost
    become: false
    ignore_errors: no
    ignore_unreachable: yes
    register: result
    failed_when: not result.failed
    with_nested:
  • “{{ ansible_default_ipv4.address }}”
  • [443,80,9200,9300,22,5432,6432]

The result informs that 1 of my ports in public ip it’s open, i’ll check in my host and its true, but it has an rule to drop all the trafic over port 22. Beyond it, the playbook informs ok, but when i’ll try to scan this por with nmap or telnet the result its the port its close. My question is ¿what is the method used for ‘wait_for’ to check the ports?

thanks a lot !

The code is open source. You can read the ansible modules on GitHub.

https://github.com/ansible/ansible/blob/stable-2.14/lib/ansible/modules/wait_for.py

Walter