diff options
author | Matt Martz <matt@sivel.net> | 2021-03-08 03:14:02 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-08 03:14:02 -0600 |
commit | d720a5e42c0e8f44966898f2697a87551a282fdb (patch) | |
tree | 27c49e3b098c4c971bc5eab32ab6cdcf6beae3e5 | |
parent | 0a6004d9ca4c42a1fa090b2b38d96406ae5e1652 (diff) | |
download | ansible-d720a5e42c0e8f44966898f2697a87551a282fdb.tar.gz |
[stable-2.10] Don't treat host_pinned as lockstep (#73484) (#73504)
* [stable-2.10] Don't treat host_pinned as lockstep (#73484)
* Don't treat host_pinned as lockstep. Fixes #73364
* Add intg tests.
(cherry picked from commit d3f3784b86789b7b55782b0af4fba6d6bb935f19)
Co-authored-by: Matt Martz <matt@sivel.net>
* Make non-lockstep callback tests more deterministic (#73511)
(cherry picked from commit 125c220343deb60ad64f4a412e6f670ddb511f4c)
7 files changed, 91 insertions, 2 deletions
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 0000000000..bcfa35f1c1 --- /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 e735e0ad68..129e7eea8c 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 0000000000..0ec0447978 --- /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 0000000000..0ec0447978 --- /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 e75c585dc0..6d9b302898 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 6e6983b115..a8033d7d87 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 0000000000..b656ee91bf --- /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 }} |