Make sure role parsing can handle a few more types in includes/defs

pull/11357/head
James Cammarata 10 years ago
parent aa53212a9b
commit 24d2202591

@ -55,8 +55,12 @@ class RoleDefinition(Base, Become, Conditional, Taggable):
raise AnsibleError("not implemented") raise AnsibleError("not implemented")
def preprocess_data(self, ds): def preprocess_data(self, ds):
# role names that are simply numbers can be parsed by PyYAML
# as integers even when quoted, so turn it into a string type
if isinstance(ds, int):
ds = "%s" % ds
assert isinstance(ds, dict) or isinstance(ds, string_types) assert isinstance(ds, dict) or isinstance(ds, string_types) or isinstance(ds, AnsibleBaseYAMLObject)
if isinstance(ds, dict): if isinstance(ds, dict):
ds = super(RoleDefinition, self).preprocess_data(ds) ds = super(RoleDefinition, self).preprocess_data(ds)

@ -24,6 +24,7 @@ from six import iteritems, string_types
import os import os
from ansible.errors import AnsibleError, AnsibleParserError from ansible.errors import AnsibleError, AnsibleParserError
from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject
from ansible.playbook.attribute import Attribute, FieldAttribute from ansible.playbook.attribute import Attribute, FieldAttribute
from ansible.playbook.role.definition import RoleDefinition from ansible.playbook.role.definition import RoleDefinition
@ -42,7 +43,8 @@ class RoleInclude(RoleDefinition):
@staticmethod @staticmethod
def load(data, current_role_path=None, parent_role=None, variable_manager=None, loader=None): def load(data, current_role_path=None, parent_role=None, variable_manager=None, loader=None):
assert isinstance(data, string_types) or isinstance(data, dict)
assert isinstance(data, string_types) or isinstance(data, dict) or isinstance(data, AnsibleBaseYAMLObject)
ri = RoleInclude(role_basedir=current_role_path) ri = RoleInclude(role_basedir=current_role_path)
return ri.load_data(data, variable_manager=variable_manager, loader=loader) return ri.load_data(data, variable_manager=variable_manager, loader=loader)

Loading…
Cancel
Save