Make noop tasks implicit ()

Signed-off-by: Rick Elrod <rick@elrod.me>
Co-authored-by: Rick Elrod <rick@elrod.me>
This commit is contained in:
Martin Krizek 2020-08-19 20:10:54 +02:00 committed by GitHub
parent f8aa307659
commit 2675768e3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 0 deletions
lib/ansible/plugins/strategy
test/integration/targets/callback_default

View file

@ -74,6 +74,7 @@ class StrategyModule(StrategyBase):
self.noop_task = Task()
self.noop_task.action = 'meta'
self.noop_task.args['_raw_params'] = 'noop'
self.noop_task.implicit = True
self.noop_task.set_loader(iterator._play._loader)
return self._create_noop_block_from(original_block, parent)
@ -88,6 +89,7 @@ class StrategyModule(StrategyBase):
noop_task = Task()
noop_task.action = 'meta'
noop_task.args['_raw_params'] = 'noop'
noop_task.implicit = True
noop_task.set_loader(iterator._play._loader)
host_tasks = {}

View file

@ -0,0 +1,11 @@
# This playbooks generates a noop task in the linear strategy, the output is tested that the banner for noop task is not printed https://github.com/ansible/ansible/pull/71344
- hosts: all
gather_facts: no
tasks:
- block:
- name: EXPECTED FAILURE # sate shippable
fail:
when: inventory_hostname == 'host1'
rescue:
- name: rescue
debug:

View file

@ -178,3 +178,9 @@ run_test_dryrun check_nomarkers_wet
# Test the dry run without check markers
run_test_dryrun check_nomarkers_dry --check
# Make sure implicit meta tasks are not printed
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