Hi all,
I would like to receive an email with the hosts that don't have port 22 (for example) open
How can I do this ?
I though of something like this:
---
- name: check if ssh port is opened
hosts: ANSIBLE
tasks:
- wait_for: port=22 host="{{ item }}" search_regex=OpenSSH delay=1 timeout=5
register: output
with_items: "{{ groups['TRAINING'] }}"
ignore_errors: true
- mail:
host='{{ IP }}'
port=25
subject="[ERROR] Ansible-report from the dark side"
body="{{ output.????? }}"
from="
ans...@qualcom.com (Ansible)"
to="
dssd...@fsafdsaf.us"
charset=utf8
when: output|failed