Prototype: parseyaml(yaml_data)

Return type: data

Description: Parses YAML data directly from an inlined string and returns the result as a data variable

Arguments:

  • yaml_data: string, in the range: .*

Please note that it's usually most convenient to use single quotes for the string (CFEngine allows both types of quotes around a string).

Example:

vars:

  "loadthis"

  data =>  parseyaml('
- arrayentry1
- arrayentry2
- key1: 1
  key2: 2
');

  # inline syntax since 3.7
  # note the --- preamble is required with inline data
  "loadthis_inline"

  data =>  '---
- arrayentry1
- arrayentry2
- key1: 1
  key2: 2
';

See also: readjson(), readyaml(), mergedata(), Inline YAML and JSON data, and data documentation.