Template value of debugger and then check for validity (#53587)

* Template value of debugger and then check for validity

* Removed if/else and forcing failure on undefined as per comments

* Added changelog

* changed colon to brackets so it appears as a string
This commit is contained in:
Jack Parsons 2019-08-27 18:02:26 +01:00 committed by Matt Martz
parent c1c6e9f008
commit 80b73712a9
2 changed files with 4 additions and 1 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- Allow debugger to take a templated value (https://github.com/ansible/ansible/pull/53587)

View file

@ -254,7 +254,8 @@ class FieldAttributeBase(with_metaclass(BaseMeta, object)):
def get_variable_manager(self): def get_variable_manager(self):
return self._variable_manager return self._variable_manager
def _validate_debugger(self, attr, name, value): def _post_validate_debugger(self, attr, value, templar):
value = templar.template(value)
valid_values = frozenset(('always', 'on_failed', 'on_unreachable', 'on_skipped', 'never')) valid_values = frozenset(('always', 'on_failed', 'on_unreachable', 'on_skipped', 'never'))
if value and isinstance(value, string_types) and value not in valid_values: if value and isinstance(value, string_types) and value not in valid_values:
raise AnsibleParserError("'%s' is not a valid value for debugger. Must be one of %s" % (value, ', '.join(valid_values)), obj=self.get_ds()) raise AnsibleParserError("'%s' is not a valid value for debugger. Must be one of %s" % (value, ', '.join(valid_values)), obj=self.get_ds())