From 72148b358d6286adcdf91db67d841ecc432986b4 Mon Sep 17 00:00:00 2001 From: Sloane Hertel Date: Wed, 4 Oct 2017 15:52:27 -0400 Subject: [PATCH] Allow any_errors_fatal to be set in playbook - fixes #30691 (#30839) * Allow any_errors_fatal to be set in playbook. * Default to the config file value for any_errors_fatal only if it isn't already provided. * add _get_attr method (cherry picked from commit aa658c64ecf23aa858e49fba99252bd443fb4a10) --- lib/ansible/playbook/base.py | 2 +- lib/ansible/playbook/task.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/ansible/playbook/base.py b/lib/ansible/playbook/base.py index 4c1c669fdfb..518dc1fd4d1 100644 --- a/lib/ansible/playbook/base.py +++ b/lib/ansible/playbook/base.py @@ -165,7 +165,7 @@ class Base(with_metaclass(BaseMeta, object)): _ignore_errors = FieldAttribute(isa='bool') _check_mode = FieldAttribute(isa='bool') _diff = FieldAttribute(isa='bool') - _any_errors_fatal = FieldAttribute(isa='bool', default=C.ANY_ERRORS_FATAL, always_post_validate=True) + _any_errors_fatal = FieldAttribute(isa='bool') # param names which have been deprecated/removed DEPRECATED_ATTRIBUTES = [ diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index 34de600de9f..e7311550397 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -21,6 +21,7 @@ __metaclass__ = type import os +from ansible import constants as C from ansible.errors import AnsibleError, AnsibleParserError, AnsibleUndefinedVariable from ansible.module_utils.six import iteritems, string_types from ansible.module_utils._text import to_native @@ -422,6 +423,14 @@ class Task(Base, Conditional, Taggable, Become): return value + def _get_attr_any_errors_fatal(self): + value = self._attributes['any_errors_fatal'] + if value is None: + value = self._get_parent_attribute('any_errors_fatal') + if value is None: + value = C.ANY_ERRORS_FATAL + return value + def _get_attr_environment(self): ''' Override for the 'tags' getattr fetcher, used from Base.