@ -33,7 +33,7 @@ poll value is 10 seconds if you do not specify a value for `poll`::
default.
default.
Alternatively, if you do not need to wait on the task to complete, you may
Alternatively, if you do not need to wait on the task to complete, you may
"fire and forget" by specifying a poll value of 0::
run the task asynchronously by specifying a poll value of 0::
---
---
@ -48,28 +48,30 @@ Alternatively, if you do not need to wait on the task to complete, you may
poll: 0
poll: 0
.. note ::
.. note ::
You shouldn't "fire and forget" with operations that require
You shouldn't attempt run a task asynchronously by specifying a poll value of 0:: to with operations that require
exclusive locks, such as yum transactions, if you expect to run other
exclusive locks (such as yum transactions) if you expect to run other
commands later in the playbook against those same resources.
commands later in the playbook against those same resources.
.. note ::
.. note ::
Using a higher value for `` --forks `` will result in kicking off asynchronous
Using a higher value for `` --forks `` will result in kicking off asynchronous
tasks even faster. This also increases the efficiency of polling.
tasks even faster. This also increases the efficiency of polling.
If you would like to perform a variation of the "fire and forget" where you
If you would like to perform a task asynchroniusly and check on it later you can perform a task similar to the
"fire and forget, check on it later" you can perform a task similar to the
following::
following::
---
---
# Requires ansible 1.8+
# Requires ansible 1.8+
- name: 'YUM - fire and forget task'
- name: 'YUM - async task'
yum: name=docker-io state=installed
yum:
name: docker-io
state: installed
async: 1000
async: 1000
poll: 0
poll: 0
register: yum_sleeper
register: yum_sleeper
- name: 'YUM - check on fire and forget task'
- name: 'YUM - check on async task'
async_status: jid={{ yum_sleeper.ansible_job_id }}
async_status:
jid: "{{ yum_sleeper.ansible_job_id }}"
register: job_result
register: job_result
until: job_result.finished
until: job_result.finished
retries: 30
retries: 30