From 8aea8901c353a18b3a58156eb1d5cb7e24825af0 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Sun, 8 Jul 2018 21:11:39 +0300 Subject: [PATCH] Add config to fail on invalid task attributes. Fixes #42479 --- lib/ansible/config/base.yml | 11 +++++++++++ lib/ansible/playbook/task.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/ansible/config/base.yml b/lib/ansible/config/base.yml index 341c7699095..ddf00490d42 100644 --- a/lib/ansible/config/base.yml +++ b/lib/ansible/config/base.yml @@ -1375,6 +1375,17 @@ HOST_KEY_CHECKING: ini: - {key: host_key_checking, section: defaults} type: boolean +INVALID_TASK_ATTRIBUTE_FAILED: + name: Controls whether invalid attributes for a task result in errors instead of warnings + default: false + description: If 'true', invalid attributes for a task will result in errors instead of warnings + type: boolean + env: + - name: ANSIBLE_INVALID_TASK_ATTRIBUTE_FAILED + ini: + - key: invalid_task_attribute_failed + section: defaults + version_added: "2.7" INVENTORY_ANY_UNPARSED_IS_FAILED: name: Controls whether any unparseable inventory source is a fatal error default: False diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index b300f3c7201..b58e7767bf8 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -231,7 +231,7 @@ class Task(Base, Conditional, Taggable, Become): " Please see:\nhttps://docs.ansible.com/ansible/playbooks_roles.html#task-include-files-and-encouraging-reuse\n\n" " for currently supported syntax regarding included files and variables", version="2.7") new_ds['vars'][k] = v - elif k in self._valid_attrs: + elif C.INVALID_TASK_ATTRIBUTE_FAILED or k in self._valid_attrs: new_ds[k] = v else: display.warning("Ignoring invalid attribute: %s" % k)