|
|
@ -229,9 +229,29 @@ def parse_yaml_from_file(path):
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
data = file(path).read()
|
|
|
|
data = file(path).read()
|
|
|
|
|
|
|
|
return parse_yaml(data)
|
|
|
|
except IOError:
|
|
|
|
except IOError:
|
|
|
|
raise errors.AnsibleError("file not found: %s" % path)
|
|
|
|
raise errors.AnsibleError("file not found: %s" % path)
|
|
|
|
return parse_yaml(data)
|
|
|
|
except yaml.YAMLError, exc:
|
|
|
|
|
|
|
|
if hasattr(exc, 'problem_mark'):
|
|
|
|
|
|
|
|
mark = exc.problem_mark
|
|
|
|
|
|
|
|
if mark.line -1 >= 0:
|
|
|
|
|
|
|
|
before_probline = data.split("\n")[mark.line-1]
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
before_probline = ''
|
|
|
|
|
|
|
|
probline = data.split("\n")[mark.line]
|
|
|
|
|
|
|
|
arrow = " " * mark.column + "^"
|
|
|
|
|
|
|
|
msg = """Syntax Error while loading YAML script, %s
|
|
|
|
|
|
|
|
Note: The error may actually appear before this position: line %s, column %s
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%s
|
|
|
|
|
|
|
|
%s
|
|
|
|
|
|
|
|
%s""" % (path, mark.line + 1, mark.column + 1, before_probline, probline, arrow)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
# No problem markers means we have to throw a generic
|
|
|
|
|
|
|
|
# "stuff messed up" type message. Sry bud.
|
|
|
|
|
|
|
|
msg = "Could not parse YAML. Check over %s again." % path
|
|
|
|
|
|
|
|
raise errors.AnsibleYAMLValidationFailed(msg)
|
|
|
|
|
|
|
|
|
|
|
|
def parse_kv(args):
|
|
|
|
def parse_kv(args):
|
|
|
|
''' convert a string of key/value items to a dict '''
|
|
|
|
''' convert a string of key/value items to a dict '''
|
|
|
|