diff options
author | Matt Martz <matt@sivel.net> | 2020-08-27 11:09:35 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-27 11:09:35 -0500 |
commit | 35d3ed5f1014197ba906c37aee4af882b61a25ac (patch) | |
tree | d3f55a276ffa0ce554d49a7b2dcb6ae0a2685035 | |
parent | 48d99c0ff1c4b48d84e21b9c53303ef2bac055d1 (diff) | |
download | ansible-35d3ed5f1014197ba906c37aee4af882b61a25ac.tar.gz |
[stable-2.9] Allow the TOML inventory to dump unsafe. Fixes #71307 (#71309) (#71318)
(cherry picked from commit 9da8801)
Co-authored-by: Matt Martz <matt@sivel.net>
-rw-r--r-- | changelogs/fragments/71307-toml-dumps-unsafe.yml | 4 | ||||
-rw-r--r-- | lib/ansible/plugins/inventory/toml.py | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/changelogs/fragments/71307-toml-dumps-unsafe.yml b/changelogs/fragments/71307-toml-dumps-unsafe.yml new file mode 100644 index 0000000000..9b964fc141 --- /dev/null +++ b/changelogs/fragments/71307-toml-dumps-unsafe.yml @@ -0,0 +1,4 @@ +bugfixes: +- TOML inventory - Ensure we register dump functions for ``AnsibleUnsafe`` to support dumping unsafe values. + Note that the TOML format has no functionality to mark that the data is unsafe for re-consumption. + (https://github.com/ansible/ansible/issues/71307) diff --git a/lib/ansible/plugins/inventory/toml.py b/lib/ansible/plugins/inventory/toml.py index 31fe95fb56..054a3d0f97 100644 --- a/lib/ansible/plugins/inventory/toml.py +++ b/lib/ansible/plugins/inventory/toml.py @@ -101,6 +101,7 @@ from ansible.module_utils.six import string_types, text_type from ansible.parsing.yaml.objects import AnsibleSequence, AnsibleUnicode from ansible.plugins.inventory import BaseFileInventoryPlugin from ansible.utils.display import Display +from ansible.utils.unsafe_proxy import AnsibleUnsafeBytes, AnsibleUnsafeText try: import toml @@ -124,6 +125,8 @@ if HAS_TOML and hasattr(toml, 'TomlEncoder'): self.dump_funcs.update({ AnsibleSequence: self.dump_funcs.get(list), AnsibleUnicode: self.dump_funcs.get(str), + AnsibleUnsafeBytes: self.dump_funcs.get(str), + AnsibleUnsafeText: self.dump_funcs.get(str), }) toml_dumps = partial(toml.dumps, encoder=AnsibleTomlEncoder()) else: |