mirror of
https://github.com/ansible/ansible.git
synced 2026-08-03 08:03:05 +02:00
* Allow check mode async task disabling check_mode
Allows running an async task with check_mode: False when the playbook is
being run in check mode.
* Add check_mode attribute to internal cleanup task
(cherry picked from commit c9086061ca)
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
bugfixes:
|
||||||
|
- >-
|
||||||
|
async - Fix bug that stopped running async task in ``--check`` when ``check_mode: False`` was set as a task attribute
|
||||||
|
- https://github.com/ansible/ansible/issues/82811
|
||||||
@@ -841,7 +841,12 @@ class TaskExecutor:
|
|||||||
# that (with a sleep for "poll" seconds between each retry) until the
|
# that (with a sleep for "poll" seconds between each retry) until the
|
||||||
# async time limit is exceeded.
|
# async time limit is exceeded.
|
||||||
|
|
||||||
async_task = Task.load(dict(action='async_status', args={'jid': async_jid}, environment=self._task.environment))
|
async_task = Task.load(dict(
|
||||||
|
action='async_status',
|
||||||
|
args={'jid': async_jid},
|
||||||
|
check_mode=self._task.check_mode,
|
||||||
|
environment=self._task.environment,
|
||||||
|
))
|
||||||
|
|
||||||
# FIXME: this is no longer the case, normal takes care of all, see if this can just be generalized
|
# FIXME: this is no longer the case, normal takes care of all, see if this can just be generalized
|
||||||
# Because this is an async task, the action handler is async. However,
|
# Because this is an async task, the action handler is async. However,
|
||||||
@@ -913,6 +918,7 @@ class TaskExecutor:
|
|||||||
'jid': async_jid,
|
'jid': async_jid,
|
||||||
'mode': 'cleanup',
|
'mode': 'cleanup',
|
||||||
},
|
},
|
||||||
|
'check_mode': self._task.check_mode,
|
||||||
'environment': self._task.environment,
|
'environment': self._task.environment,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
- hosts: localhost
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- name: Async in check mode task disabled test
|
||||||
|
command: sleep 5
|
||||||
|
async: 6
|
||||||
|
poll: 1
|
||||||
|
check_mode: False
|
||||||
@@ -298,3 +298,15 @@
|
|||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- '"ASYNC POLL on localhost" in callback_output.stdout'
|
- '"ASYNC POLL on localhost" in callback_output.stdout'
|
||||||
|
|
||||||
|
- name: run playbook in --check with task disabling check mode
|
||||||
|
command: ansible-playbook {{ role_path }}/check_task_test.yml --check
|
||||||
|
register: check_task_disabled_output
|
||||||
|
delegate_to: localhost
|
||||||
|
environment:
|
||||||
|
ANSIBLE_NOCOLOR: 'true'
|
||||||
|
ANSIBLE_FORCE_COLOR: 'false'
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- '"ASYNC OK on localhost" in check_task_disabled_output.stdout'
|
||||||
|
|||||||
Reference in New Issue
Block a user