From a4046d34248b1d7e2b9476fa1c0e7a3c7ae2943d Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 12 Apr 2018 09:37:04 -0400 Subject: [PATCH] better error when wrong type passed to import_play (#36592) fixes #36576 --- lib/ansible/playbook/playbook_include.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ansible/playbook/playbook_include.py b/lib/ansible/playbook/playbook_include.py index 54ca63f36fc..86532cca71a 100644 --- a/lib/ansible/playbook/playbook_include.py +++ b/lib/ansible/playbook/playbook_include.py @@ -21,8 +21,8 @@ __metaclass__ = type import os -from ansible.errors import AnsibleParserError, AnsibleError, AnsibleAssertionError -from ansible.module_utils.six import iteritems +from ansible.errors import AnsibleParserError, AnsibleAssertionError +from ansible.module_utils.six import iteritems, string_types from ansible.parsing.splitter import split_args, parse_kv from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject, AnsibleMapping from ansible.playbook.attribute import FieldAttribute @@ -135,6 +135,8 @@ class PlaybookInclude(Base, Conditional, Taggable): if v is None: raise AnsibleParserError("playbook import parameter is missing", obj=ds) + elif not isinstance(v, string_types): + raise AnsibleParserError("playbook import parameter must be a string indicating a file path, got %s instead" % type(v), obj=ds) # The import_playbook line must include at least one item, which is the filename # to import. Anything after that should be regarded as a parameter to the import