Skip to content

Commit

Permalink
import_tasks: Raise an error when applying notify
Browse files Browse the repository at this point in the history
notify is not valid import_tasks attribute. Raise an error
when user specifies it.

Fixes: ansible#64935

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
  • Loading branch information
Akasurde committed Nov 26, 2019
1 parent a15fb26 commit 3c71bce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/64935_import_tasks.yml
@@ -0,0 +1,2 @@
bugfixes:
- Raise an error when including notify in import tasks (https://github.com/ansible/ansible/issues/64935).
10 changes: 10 additions & 0 deletions lib/ansible/playbook/task_include.py
Expand Up @@ -91,6 +91,16 @@ def preprocess_data(self, ds):
else:
display.warning("Ignoring invalid attribute: %s" % k)

# VALID_INCLUDE_KEYWORDS does not contain check_mode, which is supported by import_tasks
if ds['action'] in ('import_tasks'):
invalid_import_keywords = ('notify', 'register')
for key in invalid_import_keywords:
if key in ds:
if C.INVALID_TASK_ATTRIBUTE_FAILED:
raise AnsibleParserError("'%s' is not a valid attribute for a import_tasks" % key, obj=ds)
else:
display.warning("Ignoring invalid attribute: '%s'" % key)

return ds

def copy(self, exclude_parent=False, exclude_tasks=False):
Expand Down

0 comments on commit 3c71bce

Please sign in to comment.