Here is what I am trying to do:

   - Connect to [clientservers] and perform telnet on port 
   443, 80, 8443
   - if result = ok (meaning if that port is open), then do nothing.
   - if result = fail,  then send output to failed-clients.txt listing 
   hostname, ip and port that was unreachable

I have successfully completed the first task using this playbook:

- hosts: clientservers

  - name: Check all port numbers for current host
      port: "{{ item }}"
      state: started        # Port should be open
      delay: 0              # No wait before first check (sec)
      timeout: 3            # Stop checking after timeout (sec)
      - 443
      - 80
      - 8443
     ignore_errors: yes

I have researched many forums and sites, and I am currently looking at the 
wait_for and register module.  After reading the following advice:

Fine-tuning output 

If you want more specific output for the success and failure cases, the 
code must be more complex, adding a second task:

   - wait_for task must register a variable
   - the second task produces output using debug based on success/failure 
   condition (e.g. using Jinja2 conditional expression 
   - then you need to put both these tasks in an include file (without any 
   with_items loop), and write a main playbook task that uses an include 
   ... with_items to call the include file once per port.

I'm not sure how to put all this together.  Is it even possible?

You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To post to this group, send email to
To view this discussion on the web visit
For more options, visit

Reply via email to