Make sure role parsing can handle a few more types in includes/defs
This commit is contained in:
parent
aa53212a9b
commit
24d2202591
2 changed files with 8 additions and 2 deletions
|
@ -55,8 +55,12 @@ class RoleDefinition(Base, Become, Conditional, Taggable):
|
|||
raise AnsibleError("not implemented")
|
||||
|
||||
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):
|
||||
ds = super(RoleDefinition, self).preprocess_data(ds)
|
||||
|
|
|
@ -24,6 +24,7 @@ from six import iteritems, string_types
|
|||
import os
|
||||
|
||||
from ansible.errors import AnsibleError, AnsibleParserError
|
||||
from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject
|
||||
from ansible.playbook.attribute import Attribute, FieldAttribute
|
||||
from ansible.playbook.role.definition import RoleDefinition
|
||||
|
||||
|
@ -42,7 +43,8 @@ class RoleInclude(RoleDefinition):
|
|||
|
||||
@staticmethod
|
||||
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)
|
||||
return ri.load_data(data, variable_manager=variable_manager, loader=loader)
|
||||
|
|
Loading…
Reference in a new issue