mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 14:41:23 -07:00
Add representers so we can output yaml for all the types we read in from yaml
This commit is contained in:
parent
8607aa527d
commit
a8e015cc22
1 changed files with 11 additions and 1 deletions
|
@ -22,7 +22,7 @@ __metaclass__ = type
|
||||||
import yaml
|
import yaml
|
||||||
from ansible.compat.six import PY3
|
from ansible.compat.six import PY3
|
||||||
|
|
||||||
from ansible.parsing.yaml.objects import AnsibleUnicode
|
from ansible.parsing.yaml.objects import AnsibleUnicode, AnsibleSequence, AnsibleMapping
|
||||||
from ansible.vars.hostvars import HostVars
|
from ansible.vars.hostvars import HostVars
|
||||||
|
|
||||||
class AnsibleDumper(yaml.SafeDumper):
|
class AnsibleDumper(yaml.SafeDumper):
|
||||||
|
@ -50,3 +50,13 @@ AnsibleDumper.add_representer(
|
||||||
represent_hostvars,
|
represent_hostvars,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
AnsibleDumper.add_representer(
|
||||||
|
AnsibleSequence,
|
||||||
|
yaml.representer.SafeRepresenter.represent_list,
|
||||||
|
)
|
||||||
|
|
||||||
|
AnsibleDumper.add_representer(
|
||||||
|
AnsibleMapping,
|
||||||
|
yaml.representer.SafeRepresenter.represent_dict,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue