Here is what I am trying to do:

   - Connect to [clientservers] and perform telnet mywebserver.com 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

  tasks:
  - name: Check all port numbers for current host
    wait_for:
      host: mywebserver.com
      port: "{{ item }}"
      state: started        # Port should be open
      delay: 0              # No wait before first check (sec)
      timeout: 3            # Stop checking after timeout (sec)
    with_items:
      - 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 
   <https://stackoverflow.com/a/14215034/992887>)
   - 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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a7f60e6a-de10-4e7a-9f86-8d7b85f0dfdd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to