Add representers so we can output yaml for all the types we read in from yaml

This commit is contained in:
Toshio Kuratomi 2015-12-06 22:12:48 -08:00
commit a8e015cc22

View file

@ -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,
)