ansible version: 4.10.0
I am hoping to make this task async on a single host. When I use poll:0, I had expected it to fire off the task and move on, but it instead takes longer than when async is not used.
- name: "setup test databases on cluster"
block:
- name: "generate list of databases"
set_fact:
test_database_list: "{{ test_database_list | default([])+['test_db%02d'| format(item)] }}"
loop: "{{ range(1,10+1,1)| list }}"
- name: "create test database(s) on cluster"
postgresql_db:
name: "{{ item }}"
with_items: "{{ test_database_list }}"
become_user: postgres
- name: "install postgresql extensions"
postgresql_ext:
db: "{{ item[0] }}"
name: "{{ item[1] }}"
with_nested:
- "{{ test_database_list }}"
- - pageinspect
- pg_buffercache
- pg_freespacemap
- pg_prewarm
- pg_stat_statements
- pg_visibility
- pg_trgm
- pgrowlocks
- pgstattuple
become_user: postgres
async: 30
poll: 0
register: postgres_ext_install_status
- ansible.builtin.async_status:
jid: "{{ item.ansible_job_id }}"
loop: "{{ postgres_ext_install_status.results }}"
loop_control:
label: "{{ item.item }}"
register: job_result
until: job_result.finished
retries: 100
delay: 2
- debug:
msg: "{{ item.start }} -- {{ item.end }} -- {{ item.delta }}"
loop: "job_result.results"
loop_control:
label: "{{ item.item.item }}
Here is the output: https://pastebin.com/DTkbbqgR
The documentation clearly states that poll:0 will cause the play to move on from the task, but it instead stays on the task and slowly moves through each of the extensions for each database before moving onto the next task.
Am I misunderstanding the use of async / poll?
The following example works for running async on a single host and having it move on from the task.
- hosts: localhost
gather_facts: no
tasks:
- name: sleep 10s
command: "sleep 10"
loop: "{{range(3)|list}}"
async: 11
poll: 0
How is this different from what I am doing?
EDIT: Added more code and link to results