From fcb033b9e442e7e49921817729169a14ba53d99d Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Tue, 15 Nov 2016 11:57:57 -0600 Subject: [PATCH] Add `name` field for Blocks Fixes #18420 --- CHANGELOG.md | 1 + lib/ansible/playbook/block.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5bcb12290..06ba07090f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Ansible Changes By Release the release. * removed 'package' from default squash actions as not all package managers support it and it creates errors when using loops, any user can add back via config options if they don't use those package managers or othewise avoid the errors. +* Blocks can now have a `name` field, to aid in playbook readability. ###Deprecations: * Specifying --tags (or --skip-tags) multiple times on the command line diff --git a/lib/ansible/playbook/block.py b/lib/ansible/playbook/block.py index be04963704..bbb287420b 100644 --- a/lib/ansible/playbook/block.py +++ b/lib/ansible/playbook/block.py @@ -30,12 +30,16 @@ from ansible.playbook.taggable import Taggable class Block(Base, Become, Conditional, Taggable): - _block = FieldAttribute(isa='list', default=[], inherit=False) - _rescue = FieldAttribute(isa='list', default=[], inherit=False) - _always = FieldAttribute(isa='list', default=[], inherit=False) - _delegate_to = FieldAttribute(isa='list') - _delegate_facts = FieldAttribute(isa='bool', default=False) + # main block fields containing the task lists + _block = FieldAttribute(isa='list', default=[], inherit=False) + _rescue = FieldAttribute(isa='list', default=[], inherit=False) + _always = FieldAttribute(isa='list', default=[], inherit=False) + + # other fields _any_errors_fatal = FieldAttribute(isa='bool') + _delegate_to = FieldAttribute(isa='list') + _delegate_facts = FieldAttribute(isa='bool', default=False) + _name = FieldAttribute(isa='string', default='') # for future consideration? this would be functionally # similar to the 'else' clause for exceptions