On Mon, 6 Apr 2020 14:10:18 -0700 (PDT)
דודו דודו <[email protected]> wrote:

> I'm checking ping on a few of my groups. I wish to abort the playbook if 
> one of the IPs is not reachable
> 
> - hosts:  
>       - postgres1
>       - kafka
>       - repository
>   become: true
>   gather_facts: False
>   tasks:
>   - name: Verify that all hosts are reachable
>     ping:

Try this

- hosts:
    - postgres1
    - kafka
    - repository
  become: true
  gather_facts: False
  tasks:
    - block:
        - wait_for_connection:
            timeout: 5
      rescue:
        - debug:
            msg: "{{ inventory_hostname }} not available. End play."
        - meta: end_play
    - debug:
        msg: All hosts available. Continue play.
    - setup:

HTH,

        -vlado

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200407062404.533f7697%40gmail.com.

Attachment: pgpUwasp5dscd.pgp
Description: OpenPGP digital signature

Reply via email to