On Tue, Apr 07, 2020 at 06:24:04AM +0200, Vladimir Botka wrote:
> 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:

Or just set "any_errors_fatal: true" on the play.
https://docs.ansible.com/ansible/latest/user_guide/playbooks_error_handling.html#aborting-the-play


-- 
Kai Stian Olstad

-- 
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/20200410065034.72lo7ljy7kzsnxl5%40olstad.com.

Reply via email to