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 <admiller@redhat.com>

* use collections.Sequence to simplify if check

Signed-off-by: Adam Miller <admiller@redhat.com>
pull/41844/head
Adam Miller 6 years ago committed by ansibot
parent 0d4e113975
commit c65b7eb52e

@ -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:

Loading…
Cancel
Save