From c65b7eb52e3f1999292f845bce19d7f541645f76 Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Fri, 22 Jun 2018 10:13:58 -0500 Subject: [PATCH] validate vars_files entries are string_type or list (#40985) * validate vars_files entries are string_type or list Fixes #17594 Signed-off-by: Adam Miller * use collections.Sequence to simplify if check Signed-off-by: Adam Miller --- lib/ansible/vars/manager.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ansible/vars/manager.py b/lib/ansible/vars/manager.py index 6aa3cd6397c..923c10dafd2 100644 --- a/lib/ansible/vars/manager.py +++ b/lib/ansible/vars/manager.py @@ -22,7 +22,7 @@ __metaclass__ = type import os import sys -from collections import defaultdict, MutableMapping +from collections import defaultdict, MutableMapping, Sequence try: from hashlib import sha1 @@ -340,6 +340,12 @@ class VariableManager: try: for vars_file in vars_file_list: vars_file = templar.template(vars_file) + if not (isinstance(vars_file, Sequence)): + raise AnsibleError( + "Invalid vars_files entry found: %r\n" + "vars_files entries should be either a string type or " + "a list of string types after template expansion" % vars_file + ) try: data = preprocess_vars(self._loader.load_from_file(vars_file, unsafe=True)) if data is not None: