best location for async_status tasks in a playbook with multiple roles

Say you have a playbook with multiple roles, for example:

roles:

  • A
  • B
  • C

in role A’s or B’s tasks/main.yml, there are a few tasks which are asynchronous fire and forget, do not poll tasks, for example:

`

  • name: do the thing (asynchronously)
    shell: Zhu Li do the thing
    args:
    creates: /etc/thething
    async: 300
    poll: 0
    register: thething_created
    `

these tasks need to be checked on at the end of the playbook run before the handlers execute like so:

`

  • name: verify that the thing was done
    async_status: jid={{ thething_created.ansible_job_id }}
    register: thething_result
    until: thething_result.finished
    retries: 100
    `

currently I have these async_status tasks at the end of C’s tasks/main.yml. If role C is removed or conditionally executed, it will cause the entire playbook to fail.

Where is the best location to put these kind of tasks? I could always create another role called D that contains just these tasks but I’m interested to learn how the rest of you are handling this.