From cfdaec0c22e8d9a2410031e586719571e4b68b0f Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Tue, 15 Sep 2015 12:17:18 -0400 Subject: [PATCH] Make sure string attributes are strings from YAML to avoid bad type conversions Fixes #12367 --- lib/ansible/playbook/base.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ansible/playbook/base.py b/lib/ansible/playbook/base.py index 6b2205e7b10..44630144938 100644 --- a/lib/ansible/playbook/base.py +++ b/lib/ansible/playbook/base.py @@ -231,6 +231,12 @@ class Base: method = getattr(self, '_validate_%s' % name, None) if method: method(attribute, name, getattr(self, name)) + else: + # and make sure the attribute is of the type it should be + value = getattr(self, name) + if value is not None: + if attribute.isa == 'string' and not isinstance(value, string_types): + raise AnsibleParserError("The field '%s' is supposed to be a string type, however the incoming data structure is a %s" % (name, type(value)), obj=self.get_ds()) def copy(self): '''