best location for async_status tasks in a playbook with multiple roles

45 views
Skip to first unread message

Frank Ly

unread,
Nov 5, 2015, 6:03:49 PM11/5/15
to Ansible Project
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.
Reply all
Reply to author
Forward
0 new messages