Don't treat host_pinned as lockstep (#73484)

* Don't treat host_pinned as lockstep. Fixes #73364

* Add intg tests
This commit is contained in:
Matt Martz 2021-02-05 09:06:19 -06:00 committed by GitHub
parent 8d6136eab9
commit d3f3784b86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 79 additions and 2 deletions

View file

@ -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)

View file

@ -188,8 +188,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:

View file

@ -0,0 +1,29 @@
PLAY [nonlockstep] *************************************************************
TASK [command] *****************************************************************
changed: [testhost10]
changed: [testhost11]
TASK [command] *****************************************************************
changed: [testhost10]
TASK [command] *****************************************************************
changed: [testhost12]
TASK [command] *****************************************************************
changed: [testhost10]
TASK [command] *****************************************************************
changed: [testhost11]
changed: [testhost12]
TASK [command] *****************************************************************
changed: [testhost11]
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

View file

@ -0,0 +1,29 @@
PLAY [nonlockstep] *************************************************************
TASK [command] *****************************************************************
changed: [testhost10]
changed: [testhost11]
TASK [command] *****************************************************************
changed: [testhost10]
TASK [command] *****************************************************************
changed: [testhost12]
TASK [command] *****************************************************************
changed: [testhost10]
TASK [command] *****************************************************************
changed: [testhost11]
changed: [testhost12]
TASK [command] *****************************************************************
changed: [testhost11]
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

View file

@ -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=1.0 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}"
testhost11 i=2.0 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}"
testhost12 i=3.0 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}"

View file

@ -192,3 +192,7 @@ ansible-playbook -i host1,host2 no_implicit_meta_banners.yml > meta_test.out
cat meta_test.out
[ "$(grep -c 'TASK \[meta\]' meta_test.out)" -eq 0 ]
rm -f meta_test.out
# Ensure free/host_pinned non-lockstep strategies display correctly
diff -u <(ANSIBLE_STRATEGY=free ansible-playbook -i inventory test_non_lockstep.yml 2>/dev/null) callback_default.out.free.stdout
diff -u <(ANSIBLE_STRATEGY=host_pinned ansible-playbook -i inventory test_non_lockstep.yml 2>/dev/null) callback_default.out.host_pinned.stdout

View file

@ -0,0 +1,7 @@
---
- hosts: nonlockstep
gather_facts: false
tasks:
- command: sleep {{ 2 * i }}
- command: sleep {{ 2 * i }}
- command: sleep {{ 2 * i }}