multi hosts in block/rescue

9 views
Skip to first unread message

syn...@gmail.com

unread,
Nov 12, 2020, 2:38:10 PM11/12/20
to Ansible Development
Hello,
We are writing a simple block/rescue playbook, where we see if a box is online and if its not we want to notify another box to this fact.
I apologize in advance but it look like another hosts parameters can not be defined in the rescue block, is there a way and i am a little dense?
Thanks

- name: Get Device Status
  hosts: pi_server
  gather_facts: False

  tasks:
  - name: Wait for system to become reachable
    block:
      - name: Wait wait_on_connection
        wait_for_connection:
           timeout: 10
      - name: Gather facts for first time
        setup:
     rescue:
       - name: there was a problem, lets notify another box
         hosts: another_device
         another_module_to_notify_a_device:
            msg: 'I caught an error'


Matt Martz

unread,
Nov 12, 2020, 2:48:40 PM11/12/20
to syn...@gmail.com, Ansible Development
You want to use `delegate_to`

     rescue:
       - name: there was a problem, lets notify another box
         another_module_to_notify_a_device:
            msg: 'I caught an error'
         delegate_to: another_device

--
You received this message because you are subscribed to the Google Groups "Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/b8eceaab-abd6-48d3-80e7-33b983f6421fn%40googlegroups.com.


--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages