mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-23 08:40:22 -07:00
Add from_yaml_all to support multi document yaml strings (#43037)
* Support multi-doc yaml in the from_yaml filter * Most automatic method of handling multidoc * Only use safe_load_all * Implement separate filter * Update plugin docs and changelog
This commit is contained in:
parent
19dc267e4c
commit
d27de6acd9
3 changed files with 28 additions and 0 deletions
|
@ -47,6 +47,22 @@ for example::
|
|||
- set_fact:
|
||||
myvar: "{{ result.stdout | from_json }}"
|
||||
|
||||
|
||||
.. versionadded:: 2.7
|
||||
|
||||
To parse multi-document yaml strings, the ``from_yaml_all`` filter is provided.
|
||||
The ``from_yaml_all`` filter will return a generator of parsed yaml documents.
|
||||
|
||||
for example::
|
||||
|
||||
tasks:
|
||||
- shell: cat /some/path/to/multidoc-file.yaml
|
||||
register: result
|
||||
- debug:
|
||||
msg: '{{ item }}'
|
||||
loop: '{{ result.stdout | from_yaml_all | list }}'
|
||||
|
||||
|
||||
.. _forcing_variables_to_be_defined:
|
||||
|
||||
Forcing Variables To Be Defined
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue