diff --git a/changelogs/fragments/73364-default-callback-host-pinned-not-lockstep.yml b/changelogs/fragments/73364-default-callback-host-pinned-not-lockstep.yml new file mode 100644 index 00000000000..bcfa35f1c17 --- /dev/null +++ b/changelogs/fragments/73364-default-callback-host-pinned-not-lockstep.yml @@ -0,0 +1,3 @@ +bugfixes: +- default callback - Ensure that the ``host_pinned`` strategy is not treated as lockstep + (https://github.com/ansible/ansible/issues/73364) diff --git a/lib/ansible/plugins/callback/default.py b/lib/ansible/plugins/callback/default.py index e735e0ad689..129e7eea8cd 100644 --- a/lib/ansible/plugins/callback/default.py +++ b/lib/ansible/plugins/callback/default.py @@ -186,8 +186,8 @@ class CallbackModule(CallbackBase): # Preserve task name, as all vars may not be available for templating # when we need it later - if self._play.strategy == 'free': - # Explicitly set to None for strategy 'free' to account for any cached + if self._play.strategy in ('free', 'host_pinned'): + # Explicitly set to None for strategy free/host_pinned to account for any cached # task title from a previous non-free play self._last_task_name = None else: diff --git a/test/integration/targets/callback_default/callback_default.out.free.stdout b/test/integration/targets/callback_default/callback_default.out.free.stdout new file mode 100644 index 00000000000..0ec0447978f --- /dev/null +++ b/test/integration/targets/callback_default/callback_default.out.free.stdout @@ -0,0 +1,35 @@ + +PLAY [nonlockstep] ************************************************************* + +TASK [command] ***************************************************************** +changed: [testhost10] + +TASK [command] ***************************************************************** +changed: [testhost10] + +TASK [command] ***************************************************************** +changed: [testhost10] + +TASK [command] ***************************************************************** +changed: [testhost11] + +TASK [command] ***************************************************************** +changed: [testhost11] + +TASK [command] ***************************************************************** +changed: [testhost11] + +TASK [command] ***************************************************************** +changed: [testhost12] + +TASK [command] ***************************************************************** +changed: [testhost12] + +TASK [command] ***************************************************************** +changed: [testhost12] + +PLAY RECAP ********************************************************************* +testhost10 : ok=3 changed=3 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 +testhost11 : ok=3 changed=3 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 +testhost12 : ok=3 changed=3 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 + diff --git a/test/integration/targets/callback_default/callback_default.out.host_pinned.stdout b/test/integration/targets/callback_default/callback_default.out.host_pinned.stdout new file mode 100644 index 00000000000..0ec0447978f --- /dev/null +++ b/test/integration/targets/callback_default/callback_default.out.host_pinned.stdout @@ -0,0 +1,35 @@ + +PLAY [nonlockstep] ************************************************************* + +TASK [command] ***************************************************************** +changed: [testhost10] + +TASK [command] ***************************************************************** +changed: [testhost10] + +TASK [command] ***************************************************************** +changed: [testhost10] + +TASK [command] ***************************************************************** +changed: [testhost11] + +TASK [command] ***************************************************************** +changed: [testhost11] + +TASK [command] ***************************************************************** +changed: [testhost11] + +TASK [command] ***************************************************************** +changed: [testhost12] + +TASK [command] ***************************************************************** +changed: [testhost12] + +TASK [command] ***************************************************************** +changed: [testhost12] + +PLAY RECAP ********************************************************************* +testhost10 : ok=3 changed=3 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 +testhost11 : ok=3 changed=3 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 +testhost12 : ok=3 changed=3 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 + diff --git a/test/integration/targets/callback_default/inventory b/test/integration/targets/callback_default/inventory index e75c585dc0f..6d9b302898a 100644 --- a/test/integration/targets/callback_default/inventory +++ b/test/integration/targets/callback_default/inventory @@ -3,3 +3,8 @@ testhost ansible_connection=local ansible_python_interpreter="{{ ansible_playboo [nonexistent] testhost5 ansible_host=169.254.199.200 # no connection is ever established with this host + +[nonlockstep] +testhost10 i=0.5 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +testhost11 i=3.0 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +testhost12 i=12.0 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" diff --git a/test/integration/targets/callback_default/runme.sh b/test/integration/targets/callback_default/runme.sh index 6e6983b115d..a8033d7d875 100755 --- a/test/integration/targets/callback_default/runme.sh +++ b/test/integration/targets/callback_default/runme.sh @@ -184,3 +184,7 @@ run_test_dryrun check_nomarkers_wet # Test the dry run without check markers run_test_dryrun check_nomarkers_dry --check + +# Ensure free/host_pinned non-lockstep strategies display correctly +diff -u callback_default.out.free.stdout <(ANSIBLE_STRATEGY=free ansible-playbook -i inventory test_non_lockstep.yml 2>/dev/null) +diff -u callback_default.out.host_pinned.stdout <(ANSIBLE_STRATEGY=host_pinned ansible-playbook -i inventory test_non_lockstep.yml 2>/dev/null) diff --git a/test/integration/targets/callback_default/test_non_lockstep.yml b/test/integration/targets/callback_default/test_non_lockstep.yml new file mode 100644 index 00000000000..b656ee91bf5 --- /dev/null +++ b/test/integration/targets/callback_default/test_non_lockstep.yml @@ -0,0 +1,7 @@ +--- +- hosts: nonlockstep + gather_facts: false + tasks: + - command: sleep {{ i }} + - command: sleep {{ i }} + - command: sleep {{ i }}