wait_for + mail with host down

7 views
Skip to first unread message

Adrian Paraschiv

unread,
Mar 16, 2016, 6:40:23 AM3/16/16
to Ansible Project
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

Reply all
Reply to author
Forward
0 new messages