Handle incorrect data type in list lookup plugin (#35483)

handle incorrect data type in list lookup plugin
Fixes #35481
test to ensure that loops properly handle incorrect datatypes

Signed-off-by: Adam Miller <admiller@redhat.com>
This commit is contained in:
Adam Miller 2018-05-17 15:29:36 -05:00 committed by GitHub
parent 6a4f3fb729
commit 98a198a777
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View file

@ -3,6 +3,7 @@
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = """
@ -27,10 +28,15 @@ RETURN = """
_list:
description: basically the same as you fed in
"""
import collections
from ansible.plugins.lookup import LookupBase
from ansible.errors import AnsibleError
class LookupModule(LookupBase):
def run(self, terms, **kwargs):
if not isinstance(terms, collections.Sequence):
raise AnsibleError("with_list expects a list")
return terms