selective tasks in playbook

I’m looking for a way to run the tasks that inside the block by node by node but in other hand I need to send email once in the beginning and end of the activity - after all nodes were reboot

in my code example email was sent for each node the tasks are exec

note: I run the playbook via AWX

Screen Shot 2023-05-15 at 16.47.12.png

  • name : restart app
    hosts: webserver
    serial: 1
    tasks:
  • name: send email activity start
    mail:

block:

  • name: Task 1

  • name: Task 2 - reboot node
    reboot:

  • name: check node is up and running
    uri:
    url: http://SomeURL
    method: GET
    status_code: 200
    register: _result
    until: (_result.status == 200)
    retries: 720 # 720 * 5 seconds = 1hour (60*60/5)
    delay: 5 # Every 5 seconds

  • name: send email activity completed
    run_once: true
    mail:

  • name : restart app
    hosts: DBserver
    serial: 1
    tasks:

  • name: send email activity start
    run_once: true
    mail:

block:

  • name: Task 1

  • name: Task 2 - reboot node

  • name: check node is up and running
    uri:
    url: http://SomeURL
    method: GET
    status_code: 200
    register: _result
    until: (_result.status == 200)
    retries: 720 # 720 * 5 seconds = 1hour (60*60/5)
    delay: 5 # Every 5 seconds

  • name: send email activity completed
    run_once: true
    mail:

serial might not be the best option for your case. I’d consider using throttle, and consider using free strategy, so each server which reboots are checked immediately.

I’d use the throttle on the block level.

I wrote this some time back, which might be relevant to what you’re looking for.

Come to think of it, the reason you’re trying to throttle is to manage each reboot and check individually, rt?.. actually free strategy will allow you to do that, in a parallel queue. If I may be presumptuous, free strategy might be the thing you’re after in your case :).