(cherry picked from commit 30a651bca3
)
This commit is contained in:
parent
132346cb6a
commit
843ebcc436
1 changed files with 9 additions and 9 deletions
|
@ -46,8 +46,8 @@ To avoid timeouts on a task, specify its maximum runtime and how frequently you
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
- name: simulate long running op (15 sec), wait for up to 45 sec, poll every 5 sec
|
- name: Simulate long running op (15 sec), wait for up to 45 sec, poll every 5 sec
|
||||||
command: /bin/sleep 15
|
ansible.builtin.command: /bin/sleep 15
|
||||||
async: 45
|
async: 45
|
||||||
poll: 5
|
poll: 5
|
||||||
|
|
||||||
|
@ -76,8 +76,8 @@ To run a playbook task asynchronously::
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
- name: simulate long running op, allow to run for 45 sec, fire and forget
|
- name: Simulate long running op, allow to run for 45 sec, fire and forget
|
||||||
command: /bin/sleep 15
|
ansible.builtin.command: /bin/sleep 15
|
||||||
async: 45
|
async: 45
|
||||||
poll: 0
|
poll: 0
|
||||||
|
|
||||||
|
@ -85,19 +85,19 @@ To run a playbook task asynchronously::
|
||||||
Do not specify a poll value of 0 with operations that require exclusive locks (such as yum transactions) if you expect to run other commands later in the playbook against those same resources.
|
Do not specify a poll value of 0 with operations that require exclusive locks (such as yum transactions) if you expect to run other commands later in the playbook against those same resources.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
Using a higher value for ``--forks`` will result in kicking off asynchronous tasks even faster. This also increases the efficiency of polling.
|
Using a higher value for ``--forks`` will result in kicking off asynchronous tasks even faster. This also increases the efficiency of polling.
|
||||||
|
|
||||||
If you need a synchronization point with an async task, you can register it to obtain its job ID and use the :ref:`async_status <async_status_module>` module to observe it in a later task. For example::
|
If you need a synchronization point with an async task, you can register it to obtain its job ID and use the :ref:`async_status <async_status_module>` module to observe it in a later task. For example::
|
||||||
|
|
||||||
- name: 'YUM - async task'
|
- name: Run an async task
|
||||||
yum:
|
ansible.builtin.yum:
|
||||||
name: docker-io
|
name: docker-io
|
||||||
state: present
|
state: present
|
||||||
async: 1000
|
async: 1000
|
||||||
poll: 0
|
poll: 0
|
||||||
register: yum_sleeper
|
register: yum_sleeper
|
||||||
|
|
||||||
- name: 'YUM - check on async task'
|
- name: Check on an async task
|
||||||
async_status:
|
async_status:
|
||||||
jid: "{{ yum_sleeper.ansible_job_id }}"
|
jid: "{{ yum_sleeper.ansible_job_id }}"
|
||||||
register: job_result
|
register: job_result
|
||||||
|
@ -131,7 +131,7 @@ To run multiple asynchronous tasks while limiting the number of tasks running co
|
||||||
# execute_batch.yml
|
# execute_batch.yml
|
||||||
#####################
|
#####################
|
||||||
- name: Async sleeping for batched_items
|
- name: Async sleeping for batched_items
|
||||||
command: sleep {{ async_item }}
|
ansible.builtin.command: sleep {{ async_item }}
|
||||||
async: 45
|
async: 45
|
||||||
poll: 0
|
poll: 0
|
||||||
loop: "{{ durations }}"
|
loop: "{{ durations }}"
|
||||||
|
|
Loading…
Reference in a new issue