Skip to content

OpenStack YAML output problem #38

@rickogg

Description

@rickogg

When running openstack commands (I was using server show action) if the output is in yaml format I attempt either
str( result() ) - or - '{{ result() | to_yaml_string }}' and I output this is a variable; however, I can not use
'{{ ctx().variable | from _yaml_string }}' to output this back to a json object, as it's throwing the following error.

"JinjaEvaluationException: Unable to evaluate expression '{{ ctx().variable | from_yaml_string }}'. ScannerError: mapping values are not allowed in this context\n in "", line 1, column 57"

if however, I send the yaml output to a file (action core.local command - server show > yaml.txt)
I'm able to "cat" the files contents and use '{{ result().stdout | from_yaml_string }}' and the output looks perfect.

Understood that I can output json instead of yaml from the original command; however, the json output does not provide access to the values within the object - for example (please ignore appropriate json formatting)

addresses = { network1: 1.1.1.1 network2: 2.2.2.2 etc...}
The object addresses just produces a long string of text that we need to parse through using regex

if I import from yaml I'm able to address sub-objects directly - for example

result().addresses.network1 = 1.1.1.1
result().addresses.network2 = 2.2.2.2

this would be much simpler to just reference the object directly as the network name never changes but openstack's output changes the order of the "networks" listed which make regex matching all the more difficult.

Certainly would welcome any guidance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions